📅 2011-Aug-05 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ powershell, powertab ⬩ 📚 Archive
The Windows command prompt (cmd.exe
) has simple command history. You can press the Up/Down arrow keys to cycle through the previous commands. If you want a visual display of previous commands, you can press F7 and use the Up/Down keys to navigate the list and Enter to execute a command.
PowerShell has powerful command history features. To see the list of all available commands from history:
PS> Get-History
To cycle through previous commands from history, press #
followed by Tab
key presses. Each press of the Tab key, displays one older command from the history stack.
PS> #[Tab]
To switch to a specific command from the stack displayed by Get-History
, press #, the number of that command in the stack and Tab. For example, to get the command numbered 9 in the Get-History
stack:
PS> #9[Tab]
PowerShell can also find a previous command if you can provide the starting few letters. For example, this will bring up all the commands where I invoked vim
:
PS> #vim[Tab]
PowerShell can also understand the *
wildcard. For example, this will bring up all the commands where I edited a log file using vim
:
PS> #vim log*.txt[Tab]
PS> #vim log*[Tab]
The module that will hook you to command history is PowerTab. Install it (for instructions see here) and press # and Tab to get a visual list of all commands in the history stack! 😊 Note that PowerTab does not provide a few of the above features like the wildcards for example.
Tried with: PowerShell 2 and PowerTab 0.99.6