依赖:
- scoop
- PowerShell 5 (或更新,包括 PowerShell Core)
通过 scoop 安装:
# add auto-update bucket
scoop bucket add scoop-completion https://github.com/Moeologist/scoop-completion
# install
scoop install scoop-completion
在当前 shell 启用补全:
# enable completion in current shell
Import-Module "$($(Get-Item $(Get-Command scoop).Path).Directory.Parent.FullName)\modules\scoop-completion"
自动加载,请手动修改 $Profile。如果希望补全为 所有用户 | 所有host 工作,请阅读 Docs
# create profile if not exist
if (!(Test-Path $profile)) { New-Item -Path $profile -ItemType "file" -Force }
# print $profile path
$profile
在文本编辑器打开 $profile,然后添加启用代码(Import-Module 行)到该文件。
用法: 输入 "scoop [想补全的内容]" 然后按 Tab 键将循环补全项,Ctrl+Space 将触发菜单式的补全
例子:
scoop ins[Press Tab]
scoop install py[Press Ctrl+Space]
scoop uninstall [Press Ctrl+Space]
卸载:
scoop uninstall scoop-completion
scoop bucket rm scoop-completion
然后手动修改 $Profile (移除启用代码)
通过 PSGallery 安装 (已弃用):
Install-Module -AllowClobber -Name scoop-completion -Scope CurrentUser
Import-Module scoop-completion