I love my prompt! #
I have worked in IT for over 20 years now, and a not insignificant amount of that time is spent at the terminal, whether that’s Windows or Linux, and when you spend that much time at the terminal, it has to look sexy!
Below I am going to show you how I set up my prompt, how I set up my fonts, glyphs, colours and much more besides. So let’s get this show on the road.
Get PowerShell #
The baked-in version of PowerShell that comes with Windows is old-hat now. What we need to do is get the latest .NET Core cross-platform version installed and set-up so it keeps itself up to date.
There’s two ways you can get this
- Windows Store
- Command line install
winget install Microsoft.PowerShell
Get Windows Terminal and set a default Shell #
Now that PowerShell is installed, let’s grab the new Terminal app
- Windows Store - Recommended to keep the app up-to-date
- GitHub Release Page
Once installed, open Terminal and make head into the settings, we need to ensure PowerShell is set as the default
- Click the drop-down arrow, select settings
- Set the default to PowerShell, not Windows PowerShell, then click Save
Let’s upgrade the font! #
There are many fonts out there you can choose from, and I use different fonts for different applications, but when it comes to the Terminal I like to use a font packed with glyphs to add that extra sexiness. You can check out the Nerd Fonts collection over on Github.
For my Terminal I am very partial to Caskaydia Code Nerd Font, but take a look at what’s available and choose the one that suits you best.
Once your chosen font is installed, let’s get it set up in the Terminal
- Head back to the Terminal settings, select PowerShell in the left-hand menu and then click on Appearance
- In the Font face section, make sure to select the correct font with the “NF” marker. Then click save.
Now it’s time to really spice things up with Oh My Posh #
Oh My Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable.
I absolutely love Oh My Posh, and have actively been using it for all my Terminal setups for many years. I will do a Linux version of this article at some point.
There’s a few ways to install Oh My Posh
- Windows Store
- Command line with Winget
winget install JanDeDobbeleer.OhMyPosh -s winget
- Command line manual install
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))
Whichever install method you use, make sure to restart the Terminal to update the PATH
Set up Oh My Posh in your PowerShell $PROFILE #
Now that Oh My Posh is in the PATH, it’s time to get it added to the $PROFILE so that it runs when PowerShell does.
Open up the Terminal and type (You’ll need VSCode installed for this command to run. Substitute Code with Notepad if you don’t have VSCode)
Code $profile
Now add this line to the top of your profile
oh-my-posh --init --shell pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression
This will set-up Oh My Posh with the default configuration file. I have my own config file that I store in OneDrive so that it syncs across all my Windows machines (Except my work devices, that’s a different story due to policy control/security et al). I highly recommend you read the docs and build your own config. There’s also plenty of custom themes to choose from.
After you have modified the .json file, don’t forget to either restart your Terminal, or reload your profile
. $PROFILE
And there you have it. Oh My Posh is installed and set up. Tinker away to get that perfect prompt just for you.
POSH-GIT #
Let’s also install posh-git
posh-git is a PowerShell module that integrates Git and PowerShell by providing Git status summary information that can be displayed in the PowerShell prompt. posh-git also provides tab completion support for common git commands, branch names, paths and more.
PowerShellGet\Install-Module posh-git -Scope CurrentUser -Force
NOTE: If you’re asked to trust packages from the PowerShell Gallery, answer yes to continue installation of posh-git
Edit your PowerShell $PROFILE and add the following line to import posh-git when you run PowerShell
Import-Module posh-git
Terminal Icons #
Want to spice up your directory lists with sweet icons, let’s do it!
Install-Module -Name Terminal-Icons -Repository PSGallery
Now add this line to your $PROFILE like you did above
Import-Module -Name Terminal-Icons
There’s a lot of things you can do to pimp your prompt, this is just a start. Enjoy!