gpt4 book ai didi

powershell - 如何使 PowerShell 选项卡补全像 Bash 一样工作

转载 作者:行者123 更新时间:2023-12-03 05:09:38 24 4
gpt4 key购买 nike

假设我的当前目录中有以下文件:

buildBar.bat
buildFoo.bat
buildHouse.bat

然后我在命令提示符处键入以下内容:./bu,然后键入 TAB

  • 在 Bash 中,它扩展为 ./build

  • 在 PowerShell 中,它会扩展为 ./buildBar.bat——列表中的第一项。

  • 在 Cmd 中,行为与 PowerShell 相同。

我更喜欢 Bash 行为 - 有没有办法让 PowerShell 表现得像 Bash?

最佳答案

新版本的 PowerShell 包括 PSReadline,可用于执行以下操作:

Set-PSReadlineKeyHandler -Key Tab -Function Complete

或者,让它更像 bash,您可以使用箭头键来导航可用选项:

Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete

要使其永久化,请将此命令放入由 $PROFILE 定义的 powershell 配置文件中(对于 Windows PowerShell,通常为 %UserProfile%\Documents\WindowsPowerShell\profile.ps1 5.x 和 %UserProfile%\Documents\PowerShell\profile.ps1(适用于 PowerShell 6+)。

关于powershell - 如何使 PowerShell 选项卡补全像 Bash 一样工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8264655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com