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 comm
It is now possible to get PowerShell to do Bash-style completion, using PSReadline.
Check out blog post Bash-like tab completion in PowerShell.
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]\Documents\WindowsPowerShell\profile.ps1.
# keep or reset to powershell default
Set-PSReadlineKeyHandler -Key Shift+Tab -Function TabCompletePrevious
# define Ctrl+Tab like default Tab behavior
Set-PSReadlineKeyHandler -Key Ctrl+Tab -Function TabCompleteNext
# define Tab like bash
Set-PSReadlineKeyHandler -Key Tab -Function Complete
With Powershell Core we can set the PredictionSource property for PSReadLine as History to get auto suggestion. Refer to the YouTube video for more details https://youtu.be/I0iIZe0dUNw
tab
only completes the command name not its previous arguments/parameters.
to also autocomplete the complete command with arguments from history set the below keybinding.
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
Now, type few characters of command name and use up/down arrow to autocomplete this command (with arguments) from history.
real time saver.
Modify the TabExpansion function to achieve what you want. Remember that perhaps it completes till the end if you press tab again the new suggestion modify from where you originally press the key. I strongly prefer the actual behaviour, I want the line writted as fast as possible. Finally don't forget the wildcard expansion, for example: bu*h[Tab] automatically completes to buildHouse.bat