English | 简体中文 | Github | Gitee
喜欢这个项目?请给它一个 ⭐️ 或 赞赏 💰
[!Tip]
PowerShell(pwsh)
: 跨平台的 PowerShell。运行pwsh
/pwsh.exe
启动Windows PowerShell
: Windows 系统内置的 PowerShell。运行powershell
/powershell.exe
启动- 它们都可以使用
PSCompletions
, 但是更推荐PowerShell(pwsh)
PowerShell
补全管理模块,更好、更简单、更方便的使用和管理补全en-US
,zh-CN
,… 多语言切换[!Tip]
- 如果这里无法正常显示,可前往官网查看
- 点击查看 Bilibili 中的介绍及教学视频
[!Warning]
PowerShell(pwsh)
: 除非你确定始终会使用管理员权限,否则不要添加-Scope AllUsers
Windows PowerShell
: 除非你确定始终会使用管理员权限,否则不要省略-Scope CurrentUser
PowerShell
安装模块:
Import-Module PSCompletions
PowerShell
Uninstall-Module PSCompletions
[!Tip]
- 可用补全列表
- 如果补全列表里没有你想要的补全,你可以 提交 issues
- 也可以 与 argc-completions 结合使用
以 git
补全为例
psc add git
git
, 按下 Space
(空格键) Tab
键来获得命令补全psc
的更多命令用法,你只需要输入 psc
然后按下 Space
(空格键) Tab
键触发补全,通过 补全提示信息 来了解Tab
键作为补全菜单触发按键psc menu config trigger_key <key>
去设置它[!Warning]
- 如果需要指定
Set-PSReadLineKeyHandler -Key <key> -Function <MenuComplete|Complete>
- 请放在
Import-Module PSCompletions
之前例如:
Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete Import-Module PSCompletions
PowerShell
并导入 PSCompletions
模块后,PSCompletions
会开启一个后台作业去检查远程仓库中补全的状态PowerShell
并导入 PSCompletions
后显示补全更新提示-*
的命令补全,例如 git config --global
中的 --global
git
补全为例,如果你想要输入 git config user.name --global xxx
--global
,然后再补全 user.name
,最后输入名称 xxx
=
结尾的选项,如果有相关补全定义,则可以直接按下 Tab
键触发补全PowerShell
内置的补全菜单,PSCompletions
模块还提供了一个更强大的补全菜单。
psc menu config enable_menu 1
(默认开启)PowerShell
Windows PowerShell
Windows PowerShell
渲染问题,补全菜单的边框样式无法自定义PowerShell
模块提供的补全菜单中的按键
Enter
(回车) / Space
(空格)
Tab
Backspace
(退格)Esc
/ Ctrl + c
Backspace
(退格) 退出补全菜单选择补全项:
选择上一项 | 选择下一项 |
---|---|
Up |
Down |
Left |
Right |
Shift + Tab |
Tab |
Ctrl + u |
Ctrl + d |
Ctrl + p |
Ctrl + n |
psc menu
然后按下 Space
(空格键) Tab
键触发补全,通过 补全提示信息 来了解
1
表示 true
,0
表示 false
(这适用于 PSCompletions
的所有配置)psc menu config enable_menu_enhance 1
(默认开启)PSCompletions
对于补全有两种实现
enable_menu
和 enable_menu_enhance
同时为 1
Register-ArgumentCompleter
,理论上加载速度会更快TabExpansion2
全局管理补全,不局限于 psc add
添加的补全
cd
/.\
/..\
/~\
/…Get-*
/Set-*
/New-*
/…Register-ArgumentCompleter
注册的补全psc menu config enable_menu_enhance 0
来使用它PSCompletions
只对通过 psc add
添加的补全生效Set-PSReadLineKeyHandler -Key <key> -Function <MenuComplete|Complete>
控制[!Tip]
- 由于未来的 Windows Terminal 的变化,将导致在补全菜单中无法正常显示 😄🤔😎,因此这三个默认特殊符号将改变。
- 相关的 issue: https://github.com/microsoft/terminal/issues/18242
- 变化如下:
😄
=>~
🤔
=>?
😎
=>!
补全项后面的特殊符号用于在按下 Tab
键之前提前感知是否有可用的补全项
只有通过 psc add
添加的补全中才存在
你可以将它们替换成空字符串来隐藏它们
psc menu symbol SpaceTab ""
psc menu symbol OptionTab ""
psc menu symbol WriteSpaceTab ""
~
,?
,!
: 如果出现多个, 表示符合多个条件, 可以选择其中一个效果
Normal Completions
: 子命令,例如在 git
中的 add
/pull
/push
/commit
/…Optional Completions
: 可选参数,例如在 git add
中的 -g
/-u
/…General Optional Completions
: 可以用在任何地方的通用可选参数,例如在 git
中的 --help
/…Current Completions
: 当前的补全项列表~
: 表示选用当前选中的补全后, 可以按下 Space
(空格键) 和 Tab
键继续获取补全
psc menu symbol SpaceTab <symbol>
自定义此符号?
: 表示选用当前选中的补全(Optional Completions
或 General Optional Completions
)后, 可以按下 Space
(空格键) 和 Tab
键继续获取 Current Completions
psc menu symbol OptionTab <symbol>
自定义此符号!
: 表示选用当前选中的补全(Optional Completions
或 General Optional Completions
)后, 你可以按下 Space
(空格键), 再输入一个字符串, 然后按下 Space
(空格键) 和 Tab
键继续获取补全
"
(引号) 或 '
(单引号) 包裹,如 "test content"
~
, 表示有预设的补全项, 你可以不输入字符串, 直接按下 Space
(空格键) 和 Tab
键继续获取它们psc menu symbol WriteSpaceTab <symbol>
自定义此符号Tab
键触发补全补全提示信息只是辅助, 你也可以使用 psc menu config enable_tip 0
来禁用补全提示信息
psc menu config enable_tip 1
psc
psc completion psc enable_tip 0
U: install|add [-g|-u] [options] <app>
这里是命令的描述说明
(在 U: 和 E: 之间的内容都是命令描述)
E: install xxx
add -g xxx
示例解析:
用法: 以 U:
开头(Usage)
install
add
<app>
app
是对必填参数的简要概括-g
-u
[options]
表示泛指一些选项类参数U:
和 E:
之间的内容E:
开头(Example)Global language
: 默认为当前的系统语言
psc config language
可以查看全局的语言配置psc config language zh-CN
可以更改全局的语言配置Completion language
: 为指定的补全设置的语言
psc completion git language en-US
Available language
: 每一个补全的 config.json
文件中有一个 language
属性,它的值是一个可用的语言列表Completion language
,优先使用它,没有则使用 Global language
Available language
中Available language
中的第一种语言(一般为 en-US
)git
为例,当输入 git add
,此时按下 Space
和 Tab
键,不会触发路径补全,只会触发模块提供的命令补全^(?:\.\.?|~)?(?:[/\\]).*
比如:
./
或 .\
后按下 Tab
以获取 子目录 或 文件 的路径补全../
或 ..\
后按下 Tab
以获取 父级目录 或 文件 的路径补全/
或 \
后按下 Tab
以获取 同级目录 的路径补全~/
/ ../../
…git add ./
这样的命令再按下 Tab
键来获取路径补全说明
Completion
:可添加的补全。点击跳转命令官方网站,按照数字字母排序(0-9,a-z)。Language
: 支持的语言,以及完成进度
config.json
中定义的第一个语言相比,一般是 en-US
Description
: 命令描述|Completion|Language|Description|
|:-:|-|-|
|7z|en-US
zh-CN(100%)|7-Zip 的命令行 cli 程序。|
|arch|en-US
zh-CN(100%)|显示当前系统架构。
补全基于 uutils/coreutils 编写。|
|b2sum|en-US
zh-CN(13.33%)|Compute and check message digests.
Completion was written based on uutils/coreutils.|
|b3sum|en-US
zh-CN(13.33%)|Compute and check message digests.
Completion was written based on uutils/coreutils.|
|base32|en-US
zh-CN(28.57%)|Encode/decode data and print to standard output.
Completion was written based on uutils/coreutils.|
|base64|en-US
zh-CN(28.57%)|Encode/decode data and print to standard output.
Completion was written based on uutils/coreutils.|
|basename|en-US
zh-CN(28.57%)|Print NAME with any leading directory components removed.
Completion was written based on uutils/coreutils.|
|basenc|en-US
zh-CN(13.33%)|Encode/decode data and print to standard output.
Completion was written based on uutils/coreutils.|
|bun|en-US
zh-CN(100%)|Bun - JavaScript 运行时和工具包。|
|cargo|en-US
zh-CN(100%)|cargo - Rust 包管理器。|
|chfs|en-US
zh-CN(100%)|CuteHttpFileServer - 一个免费的、HTTP协议的文件共享服务器。|
|choco|en-US
zh-CN(100%)|choco(chocolatey) - 软件管理。|
|cksum|en-US
zh-CN(20%)|Print CRC and size for each file.
Completion was written based on uutils/coreutils.|
|comm|en-US
zh-CN(20%)|Compare two sorted files line by line.
Completion was written based on uutils/coreutils.|
|conda|en-US
zh-CN(100%)|conda - 二进制包和环境管理器。|
|csplit|en-US
zh-CN(18.18%)|Split a file into sections determined by context lines.
Completion was written based on uutils/coreutils.|
|cut|en-US
zh-CN(15.38%)|Print specified byte or field columns from each line of stdin or the input files.
Completion was written based on uutils/coreutils.|
|date|en-US
zh-CN(14.29%)|Print or set the system date and time.
Completion was written based on uutils/coreutils.|
|dd|en-US
zh-CN(100%)|复制并转换文件系统资源。
补全基于 uutils/coreutils 编写。|
|deno|en-US
zh-CN(100%)|Deno - 安全的 JavaScript 和 TypeScript 运行时。|
|df|en-US
zh-CN(5.71%)|Show information about the file system on which each FILE resides, or all file systems by default.
Completion was written based on uutils/coreutils.|
|dircolors|en-US
zh-CN(25%)|Output commands to set the LS_COLORS environment variable.
Completion was written based on uutils/coreutils.|
|dirname|en-US
zh-CN(40%)|Strip last component from file name.
Completion was written based on uutils/coreutils.|
|docker|en-US
zh-CN(100%)|docker - 容器应用开发。|
|du|en-US
zh-CN(2.17%)|Estimate file space usage.
Completion was written based on uutils/coreutils.|
|env|en-US
zh-CN(16.67%)|Set each NAME to VALUE in the environment and run COMMAND.
Completion was written based on uutils/coreutils.|
|factor|en-US
zh-CN(20%)|Print the prime factors of the given NUMBER(s).
Completion was written based on uutils/coreutils.|
|fmt|en-US
zh-CN(11.76%)|Reformat paragraphs from input files (or stdin) to stdout.
Completion was written based on uutils/coreutils.|
|fnm|en-US
zh-CN(8.33%)|快速、简单的 Node.js 版本管理器,使用 Rust 构建。|
|fold|en-US
zh-CN(28.57%)|Writes each file (or standard input if no files are given) to standard output whilst breaking long lines.
Completion was written based on uutils/coreutils.|
|git|en-US
zh-CN(94.93%)|Git - 版本控制系统。|
|hashsum|en-US
zh-CN(6.45%)|Compute and check message digests.
Completion was written based on uutils/coreutils.|
|head|en-US
zh-CN(22.22%)|Print the first 10 lines of each ‘FILE’ to standard output.
Completion was written based on uutils/coreutils.|
|join|en-US
zh-CN(11.11%)|For each pair of input lines with identical join fields, write a line to standard output.
The default join field is the first, delimited by blanks.
Completion was written based on uutils/coreutils.|
|kubectl|en-US
zh-CN(100%)|Kubernetes 又称 K8s,是一个开源系统,用于自动化部署、扩展和管理容器化应用程序。
kubectl 是它的命令行工具|
|link|en-US
zh-CN(100%)|调用 link 函数为现有的 FILE1 创建名为 FILE2 的链接。
补全基于 uutils/coreutils 编写。|
|ln|en-US
zh-CN(11.76%)|Make links between files.
Completion was written based on uutils/coreutils.|
|md5sum|en-US
zh-CN(14.29%)|Compute and check message digests.
Completion was written based on uutils/coreutils.|
|mise|en-US
zh-CN(3.39%)|mise is a task runner and dev tools manager for any language.|
|mktemp|en-US
zh-CN(20%)|Create a temporary file or directory.
Completion was written based on uutils/coreutils.|
|ngrok|en-US
zh-CN(100%)|ngrok - 面向开发人员的统一入口平台。
将 localhost 连接到 Internet 以测试应用程序和 API。|
|nl|en-US
zh-CN(6.67%)|Number lines of files.
Completion was written based on uutils/coreutils.|
|npm|en-US
zh-CN(100%)|npm - 软件包管理器。|
|nproc|en-US
zh-CN(33.33%)|Print the number of cores available to the current process.
Completion was written based on uutils/coreutils.|
|nrm|en-US
zh-CN(100%)|nrm - npm 镜像源管理。|
|numfmt|en-US
zh-CN(7.69%)|Convert numbers from/to human-readable strings.
Completion was written based on uutils/coreutils.|
|nvm|en-US
zh-CN(100%)|nvm - node 版本管理器。|
|od|en-US
zh-CN(4.65%)|Dump files in octal and other formats.
Completion was written based on uutils/coreutils.|
|oh-my-posh|en-US
zh-CN(7.41%)|oh-my-posh 是一款跨平台工具,用于渲染你的终端提示符。|
|paste|en-US
zh-CN(28.57%)|Write lines consisting of the sequentially corresponding lines from each ‘FILE’, separated by ‘TAB’s, to standard output.
Completion was written based on uutils/coreutils.|
|pdm|en-US
zh-CN(0.31%)|A modern Python package and dependency manager supporting the latest PEP standards.|
|pip|en-US
zh-CN(99.42%)|pip - Python 包管理器。|
|pnpm|en-US
zh-CN(100%)|pnpm - 软件包管理器。|
|powershell|en-US
zh-CN(100%)|Windows PowerShell 命令行 CLI. (powershell.exe)|
|psc|en-US
zh-CN(97.63%)|PSCompletions 模块的补全提示
它只能更新,不能移除
如果移除它,将会自动重新添加|
|pwsh|en-US
zh-CN(100%)|PowerShell 命令行 CLI。(pwsh.exe)|
|python|en-US
zh-CN(100%)|python - 命令行。|
|scoop|en-US
zh-CN(100%)|Scoop - 软件管理|
|scoop-install|en-US
zh-CN(100%)|一个 PowerShell 脚本,它允许你添加 Scoop 配置,在 Scoop 安装应用时使用替换后的 url 而不是原始的 url。|
|scoop-update|en-US
zh-CN(100%)|一个 PowerShell 脚本,它允许你添加 Scoop 配置,在 Scoop 更新应用时使用替换后的 url 而不是原始的 url。|
|sfsu|en-US
zh-CN(6.67%)|Scoop utilities that can replace the slowest parts of Scoop, and run anywhere from 30-100 times faster.|
|uv|en-US
zh-CN(10%)|一个极其快速的 Python 包和项目管理器,用 Rust 编写。|
|volta|en-US
zh-CN(100%)|volta - 无障碍 JavaScript 工具管理器。|
|winget|en-US
zh-CN(100%)|WinGet - Windows 程序包管理器。|
|wsh|en-US
zh-CN(3.45%)|wsh is a small utility that lets you do cool things with Wave Terminal, right from the command line.|
|wsl|en-US
zh-CN(100%)|WSL - 适用于 Linux 的 Windows 子系统。|
|wt|en-US
zh-CN(100%)|Windows Terminal 命令行终端。
你可以使用此命令启动一个终端。|
|yarn|en-US
zh-CN(100%)|yarn - 软件包管理器。|
|…|… |…|