Skip to main content
Version: 9.x

命令行 tab 补全

信息

pnpm v9 的完成与旧 pnpm 版本的完成不兼容。如果你已经安装了 v9 之前版本的 pnpm Completion,则必须先将其卸载,以确保 v9 的补全功能正常工作。你可以通过删除点文件中包含 __tabtab 的代码部分来完成此操作。

¥Completion for pnpm v9 is incompatible with completion for older pnpm versions. If you have already installed pnpm completion for a version older than v9, you must uninstall it first to ensure that completion for v9 works properly. You can do this by removing the section of code that contains __tabtab in your dot files.

与其他通常需要插件的流行包管理器不同,pnpm 支持 Bash、Zsh、Fish 和类似 shell 的命令行制表符补全。

¥Unlike other popular package managers, which usually require plugins, pnpm supports command line tab-completion for Bash, Zsh, Fish, and similar shells.

要为 Bash 设置自动补齐功能,请运行:

¥To setup autocompletion for Bash, run:

pnpm completion bash > ~/completion-for-pnpm.bash
echo 'source ~/completion-for-pnpm.bash' >> ~/.bashrc

要为 Fish 设置自动补齐,请运行:

¥To setup autocompletion for Fish, run:

pnpm completion fish > ~/.config/fish/completions/pnpm.fish

g-plane/pnpm-shell-completion

pnpm-shell-completion 是 Pig Fang 在 Github 上维护的一个 shell 插件。

¥pnpm-shell-completion is a shell plugin maintained by Pig Fang on Github.

特性:

¥Features:

  • 完成 pnpm --filter <package>

    ¥Provide completion for pnpm --filter <package>.

  • 提供 pnpm remove 命令的补全,即使在工作区的包中(通过指定 --filter 选项)。

    ¥Provide completion for pnpm remove command, even in workspace's packages (by specifying --filter option).

  • package.json 中的脚本提供补全。

    ¥Provide completion for scripts in package.json.