命令行 tab 自动补全
Unlike other popular package managers, which usually require plugins, pnpm supports command line tab-completion for Bash, Fish, PowerShell, and Zsh.
pnpm completion <shell> prints completion code to standard output. Supported
shell names are bash, fish, pwsh, and zsh.
Tab completion suggests project scripts after pnpm run and as shortcuts such
as pnpm build.
要为 Bash 设置自动补全,运行:
pnpm completion bash > ~/completion-for-pnpm.bash
echo 'source ~/completion-for-pnpm.bash' >> ~/.bashrc
要为 Fish 设置自动补全,运行:
pnpm completion fish > ~/.config/fish/completions/pnpm.fish
To setup autocompletion for Zsh, run:
pnpm completion zsh > ~/completion-for-pnpm.zsh
echo 'source ~/completion-for-pnpm.zsh' >> ~/.zshrc
To setup autocompletion for PowerShell, run:
pnpm completion pwsh >> $PROFILE
Any other shell name fails with ERR_PNPM_UNSUPPORTED_SHELL.
Since v12.4.0, the generated completions cover the pn alias as well, in Bash, Fish, PowerShell, and Zsh.
g-plane/pnpm-shell-completion#
pnpm-shell-completion is a shell plugin maintained by Pig Fang on GitHub.
特性:
- 提供
pnpm remove命令的补全,甚至在工作区的包中(通过指定--filter选项)。