As someone who is absolutely obsessed with automation, I am always looking for little hacks or tweaks to make myself more efficient. Since I spend a lot of time in the PowerShell console, I thought I would share my favorite PSReadline setting and one that I HIGHLY recommend to anyone who wants to save themselves hours if not days of their life trying to remember exactly what command they used last week to do task X. With that said, I am not crazy about throwing in a lot of stuff into my profile, but for me this is a must have.

In my PowerShell profile I have two lines that modify my console experience:

So what do these two little beauties do exactly? They create and destroy worlds. Just kidding. They do save human lives though. Just kidding again. OK, enough with the suspense…

Basically, they allow the user to cycle back and forth through command history using the up and down arrow keys but with an added twist. In addition to cycling through your command history, it will autocomplete the rest of a command you start typing. So in this example I have typed Get-Process. When I hit the up arrow after Get-Process, the console will autocomplete with the last command I used in my history that started with Get-Process. At this point I can hit the up and down arrow which allows me to cycle through previous instances.

Update: I previously stated I hit tab to autocomplete the rest of the command in Get-Process. I meant I hit up arrow not tab.

Awesome right? Keep in mind the command history is not dependent on the current session so it includes other previous sessions as well. Enjoy!

Categories: Technical

Leave a Reply

Your email address will not be published. Required fields are marked *