I’ve been getting more and more back to the command line, doing more with PowerShell and even Bash scripting on Docker and WSL (Windows Subsystem for Linux). There are a few of the tricks I have learned recently that help me every day.

F8 searches history!

That’s right! When you type into the command line (this work in cmd and PowerShell) and then press F8, it will do a back-in-time search for a historical command that begins with what you typed. This is a nice way to auto-complete an entire command with complex arguments quickly and easily.

F8 cmd history demo

Windows Explorer “Open Shell Here”

This works for WSL, PowerShell, and cmd. From any folder in Windows Explorer, you can type into the address bar either wsl, powershell or cmd and it will launch the respective shell opened at the same directory.

Open Shell Here Demo

$PROFILE

Powershell has a configuration file that you can add startup scripts to. This file exists at a path specified by the variable $PROFILE. You can quickly get to it from PowerShell using notepad++ $PROFILE (or use whatever text editor appeals).

You can add all sorts in here, from defining functions to be available, setting environment variables and more. Some ideas I’ve used it for before are:

WSL

Windows Subsystem for Linux (wsl) is an interesting new development. With this, I can install Ubuntu and have a bash shell I can run Linux commands in. This is what Cygwin always wanted to grow up to be.

The neat thing is you can pass commands back and forward from Powershell and wsl.

In powershell, you can type a command such as:

wsl find . -name *.csproj | % { cat $_ | wsl grep Framework }

This command will execute the command wsl find . -name *.csproj from the current directory in Linux, pass list of file paths generated back to Powershell, then for each path, execute a grep search on Linux again. We could now take the collection of results and pipe them once more through PowerShell, or another Linux command for further processing. Clever.

If you are already a Linux Shell Pro, you will probably find this ability a true PowerUser feature for you.

Wrap up

These are just a few of the Shell features I have been loving to use lately. There are so many more cool tips and tricks out there. What are your favourites?