选择命令行版本:
🌐 Synopsis
npm completion
注意:此命令不支持工作区。
🌐 Note: This command is unaware of workspaces.
🌐 Description
在所有 npm 命令中启用制表符补全。
🌐 Enables tab-completion in all npm commands.
上面的摘要会将补全加载到你当前的 shell 中。将其添加到你的 ~/.bashrc 或 ~/.zshrc 中,将使补全在所有地方都可用:
🌐 The synopsis above loads the completions into your current shell. Adding it to your ~/.bashrc or ~/.zshrc will make the completions available everywhere:
npm completion >> ~/.bashrcnpm completion >> ~/.zshrc
当然,如果你有一个可以读取该文件的系统,也可以将 npm completion 的输出转到像 /usr/local/etc/bash_completion.d/npm 或 /etc/bash_completion.d/npm 这样的文件中。
🌐 You may of course also pipe the output of npm completion to a file such as /usr/local/etc/bash_completion.d/npm or /etc/bash_completion.d/npm if you have a system that will read that file for you.
当环境中定义了 COMP_CWORD、COMP_LINE 和 COMP_POINT 时,npm completion 会以“管道模式”运行,并根据参数输出补全结果。
🌐 When COMP_CWORD, COMP_LINE, and COMP_POINT are defined in the environment, npm completion acts in "plumbing mode", and outputs completions based on the arguments.
🌐 See Also