François-Xavier Cat

PowerShell Tip - PSReadLine shortcuts

2015/01/06 |
1 minute read
|

If you are using PowerShell everyday like me, you probably started to populate you profile with some neat tools that make you like easier. In my case It’s loading some modules or add some functions such as Connect-Office365 or Clx.

PSReadLine is one of the module I’ve been using for a while now and I can’t work without it anymore!!!!

What is the PSReadLine module ?
This PowerShell module has been created by one of the PowerShell team members - Jason Shirk.
This module replaces the command line editing experience in PowerShell.exe.

It provides:

Syntax coloring

Simple syntax error notification

A good multi-line experience (both editing and history)

Customizable key bindings

Cmd and emacs modes (neither are fully implemented yet, but both are usable)

Many configuration options

Bash style completion (optional in Cmd mode, default in Emacs mode)

Bash/zsh style interactive history search (CTRL-R)

Emacs yank/kill ring

PowerShell token based “word” movement and kill

Undo/redo

Automatic saving of history, including sharing history across live sessions

CTRL+SPACE

Other than the Syntax coloring and the Error Notification, one of the coolest trick in this module is the Ctrl+Space which list the possible completions! This is just awesome!

Here are some examples:
Using Get-Help and Show-Command, you can see all the parameters available to you by pressing the ctrl+space after the dash “-“. You’ll then be able to select a parameter.

It is also work with Accelerators and Net Classes:

Also work if you are looking for a properties with Select-Object, Where-Object, Foreach-Object, Group-Object, … Obviously in this case it will only show Properties and not methods.

Methods will only show where it make sense, where you can actually use them, here for example GetType(), ToString()are available.
# Other Shortcuts
You can easily access the list of other shortcuts using Get-PSReadLineKeyHandler.