Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
597 views
in Technique[技术] by (71.8m points)

cmd - How to make PowerShell tab completion work like Bash

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

buildBar.bat
buildFoo.bat
buildHouse.bat

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

  • In Bash, it gets expanded to ./build

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

  • In Cmd, the behavior is the same as PowerShell.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Set-PSReadlineKeyHandler -Key Tab -Function Complete

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...