Make your terminal smarter with PowerShell and Set-Location
| CommentsOn this lazy Sunday morning I was catching up among the feeds and saw Scott Hanselman’s post about customizing Windows Terminal a bit more. I had already done this a while back and got my terminal all fancy looking with those cool Powerline fonts and such.
It’s a simple thing, but actually does make my experience a bit nicer to work in the terminal environment. I’m not really a CLI kind of person – it’s growing on me though – so these customizations help make it more pleasing to me. I use PowerShell (PowerShell Core to be specific) as my default shell. I use it because I like the ability of some of the modules from time to time that enable me to do some quick things working with Azure. Scott’s post had a step to customize basically your startup script for PowerShell. You can get to this from your shell by typing:
notepad $PROFILE
from a PowerShell prompt.
NOTE: PowerShell and PowerShell Core do NOT share the same profile script, so if you want similar customizations for both, you need to edit both profiles. The $PROFILE trick above will take you to the right startup profile script for each shell.
As I inspected mine, I was reminded of my favorite command: Set-Location. It’s simple but it will let you basically create aliases to quickly move to directories. Take a look in action for me. While I do have a startup directory configured for Windows Terminal, it’s nice to quickly navigate around.
So for me I’ve got a few quick shortcuts to get to some most-used directories while working in Terminal. Here’s mine that I have:
# Helper function to change directory to my development workspace function source { Set-Location c:\\users\\timheuer\\documents\\github } function ghroot { Set-Location c:\\users\\timheuer\\documents\\github } function sroot { Set-Location c:\\users\timheuer\\source\\repos } function dl { Set-Location c:\\users\\timheuer\\downloads } function desk { Set-Location c:\\users\\timheuer\\desktop } function od { Set-Location c:\\users\\timheuer\\OneDrive }
It’s dumb simple, but it saves me keystrokes when I’m working in Terminal and moving back and forth. What’s your favorite tips to use in Terminal?
Please enjoy some of these other recent posts...
Comments