使用 PowerShell 完成类似 Bash 的非旋转文件名选项卡

Bru*_*uno 8 windows powershell command-line tab-completion

在 Windows 下,使用 PowerShell,是否可以使文件名建议(使用Tab密钥)像 Linux 下的 bash 一样工作?

假设一个目录包含 3 个目录:example1,exampleexamination.

在 Windows 上(默认情况下),如果您键入cd exTab,它将自动建议cd .\examination。的后续使用Tab将在example1example和之间轮换建议examination

使用 bash(通常在 Linux 下),如果您键入cd exTab,它将自动完成,直到文件名开始不同的字符:cd exam. Tabthen 的另一种用法表明哪些目录可用:

$ cd exam
examination/ example1/    example2/
Run Code Online (Sandbox Code Playgroud)

然后,如果您键入pand Tab,它将自动完成为example,依此类推(此处提供example1和之间的选择example2)。

有没有办法让文件名建议在像这样的树状搜索中工作,而不是在名称中旋转?

(我主要对文件名感兴趣。Bash 还可以根据文件类型细化这个选择,例如只有目录 for cd,这会很好,但是选择文件名本身就足够了。)

Jay*_*uzi 5

默认完成行为是使用处理键盘输入的命令窗口的结果。

从 PowerShell v3 开始,ISE 值得考虑作为全时 shell,并且具有现代完成行为(和着色!)。

如果您真的想在 PowerShell 命令窗口中使用 BASH 样式的完成,请获取PSReadline

https://github.com/lzybkr/PSReadLine

有一个旧的,功能齐全,并没有维护项目也被称为PSReadline这里: http://nivot.org/nivot2/post/2012/09/12/Emulating-Bash-GNU-Readline-with-PowerShell-30.aspx HTTP ://nivot.org/blog/post/2012/09/12/Emulating-Bash-GNU-Readline-with-PowerShell-30