Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make powershell tab complete show me all options, rather than picking a specific one?

In Powershell, if I type:

install-<tab>

Powershell tab completion will complete with a single command that starts with install-

Install-Package

And I can hit Tab again to see different completions.

Is it possible to have Powershell show all options that start with what I typed, like Linux or Unix shell? Eg, if I type:

install-<tab>

I get:

Install-Package
Install-PackageProvider
Install-Script
like image 456
mikemaccana Avatar asked Aug 30 '16 08:08

mikemaccana


People also ask

Does PowerShell have Tab completion?

PowerShell provides completions on input to provide hints, enable discovery, and speed up input entry. Command names, parameter names, argument values and file paths can all be completed by pressing the Tab key. The Tab key is the default key binding on Windows.

What is Tab completion in PowerShell?

File and cmdlet name completionTo fill in a filename or path from the available choices automatically, type part of the name and press the Tab key. PowerShell will automatically expand the name to the first match that it finds. Pressing the Tab key repeatedly will cycle through all of the available choices.

Why is the Tab key useful in PowerShell?

The TAB key has a specific meaning in PowerShell. It's for command completion. So if you enter "getch" and then type a TAB , it changes what you typed into "GetChildItem" (it corrects the case, even though that's unnecessary).


1 Answers

PSReadLine has a feature like this called MenuComplete. Instead of Tab, press Ctrl+space:

EmacsModeTabCompletionWithPSReadLine

You can bind the MenuComplete function to tab with Set-PSReadLineKeyHandler:

Set-PSReadlineKeyHandler -Chord Tab -Function MenuComplete
like image 52
Mathias R. Jessen Avatar answered Oct 20 '22 12:10

Mathias R. Jessen