如何使 PowerShell 选项卡完成像 Bash 一样工作 [英] How to make PowerShell tab completion work like Bash

查看:27
本文介绍了如何使 PowerShell 选项卡完成像 Bash 一样工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Let's say I have the following files in my current directory:

buildBar.bat
buildFoo.bat
buildHouse.bat

然后我在命令提示符下输入以下内容,./bu,然后是 TAB.

And I type the following at my command prompt, ./bu and then TAB.

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

在 PowerShell 中,它被扩展为 ./buildBar.bat -- 列表中的第一项.

In PowerShell, it gets expanded to ./buildBar.bat -- the first item in the list.

在 Cmd 中,行为与 PowerShell 相同.

In Cmd, the behavior is the same as PowerShell.

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

I prefer the Bash behaviour - is there a way to make PowerShell behave like Bash?

推荐答案

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

New versions of PowerShell include PSReadline, which can be used to do this:

Set-PSReadlineKeyHandler -Key Tab -Function Complete

要使其永久化,请将此命令放入 C:Users[User]DocumentsWindowsPowerShellprofile.ps1.

To make it permanent, put this command into C:Users[User]DocumentsWindowsPowerShellprofile.ps1.

这篇关于如何使 PowerShell 选项卡完成像 Bash 一样工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆