Behind the PowerShell Pipeline logo

Behind the PowerShell Pipeline

Subscribe
Archives
May 9, 2024

More PSReadLine Power

Last time, I showed you how to customize PSReadLine in your module by taking advantage of examples in the sample PSReadLine profile script. But since this module has so many options, I thought I'd come back to it one more time and share some other tips and tricks. Let's start with looking at key bindings again. The PSReadline module is an integral part of PowerShell. It gets loaded automatically when you start PowerShell and pre-defines many keyboard shortcuts. Which is great, because the more you can keep your hands on the keyboard, the more efficient you can be. One keyboard shortcut which I wasn't taking advantage of until Sean Wheeler, the lead docs writer for PowerShell, opened my eyes is `Ctrl+a`. Suppose you have a command like this entered at your prompt:

Get-Process p* | sort WS -Descending | Select -first 10
Or this is a previous command you've brought back to your prompt using the up arrow key. Pressing `Ctrl+a` will cycle through each parameter value and select it. This makes it very easy to change a parameter value. I love this, because often I want to re-run a command with a different parameter value. Using this keyboard shortcut is the fastest way for me to update the command. I know that last time I shared some custom key handlers you could add, but I have a few more that you might find helpful.
Get a premium subscription for full article and archive access

Last time, I showed you how to customize PSReadLine in your module by taking advantage of examples in the sample PSReadLine profile script. But since this module has so many options, I thought I'd come back to it one more time and share some other tips and tricks. Let's start with looking at key bindings again.

The PSReadline module is an integral part of PowerShell. It gets loaded automatically when you start PowerShell and pre-defines many keyboard shortcuts. Which is great, because the more you can keep your hands on the keyboard, the more efficient you can be. One keyboard shortcut which I wasn't taking advantage of until Sean Wheeler, the lead docs writer for PowerShell, opened my eyes is Alt+a.

Suppose you have a command like this entered at your prompt:

Want to read the full issue?
GitHub Bluesky LinkedIn About Jeff
Powered by Buttondown, the easiest way to start and grow your newsletter.