DEV Community

Krzysztof Kopieczek
Krzysztof Kopieczek

Posted on • Updated on

Improve command line UX on Windows

As a .NET developer who remembers coding in .NET Framework 2.0, I'm not used to use command line at daily basis, but recently my workflow includes Bash/PowerShell/Azure CLI more and more every day. Over time, I improved my setup and here is a configuration which I may recommend.

This is how it will look at the end:
image

1. Get windows terminal

https://aka.ms/terminal

2. Pin Windows Terminal to taskbar

This will allow to quickly run Terminal with a shortcut Win+number (e.g. Win+5 as shown below)
image

3. Update PowerShell

Run PowerwShell and type $PSVersionTable.PSVersion Probably version 5 is installed on your machine.

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1023
Enter fullscreen mode Exit fullscreen mode

Go to https://github.com/PowerShell/PowerShell, download and run the installer. This will install v7 side-by-side with v5, but it will be tackled in the next steps.

4. Set PowerShell 7 as default

Windows Terminal opens PowerShell 5 by default, but it's configurable. Go to Settings > Startup and select the second "PowerShell" item in the "Default profile".
image
image

Or "Open JSON file" and locate the defaultProfile property. Replace its value with the guid of Windows.Terminal.PowershellCore from the bottom of the json.
image
image

Restart Windows Terminal to verify the step.

5. Install a proper font

  1. I recommend Caskaydia Cove from from Nerd Fonts repository. This font is based on well-known Cascadia Code. Nerd Fonts mod adds extra glyphs to the original font.
  2. Download the patched version of the font from here (use "Download" button)
  3. Go to downloads folder on your machine, locate downloaded *.ttf file, press right mouse button and select "Install".
  4. Change the font in Windows Terminal settings for the PowerShell" profile or in json. change font in settings

6. Install required PowerShell modules

Now the fun part begins. We will install more themes and tweaks to the Terminal. Run these commands

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
Enter fullscreen mode Exit fullscreen mode

7. Pick a theme

Run Get-PoshThemes and locate one you like the most.

8. Set theme

Set-PoshPrompt -Theme themename
Enter fullscreen mode Exit fullscreen mode

I chosen powerlevel10k_classic.

9. Save settings in your profile

Run notepad $PROFILE in base folder (create file if don't exist) and paste the following. Replace themename with your theme name.

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme themename
Enter fullscreen mode Exit fullscreen mode

10. Enjoy more productive terminal environment ๐Ÿ™‚

And feel free to post the font you have selected.

PS

Kudos to Scott Hanselman - I saw the pretty command line at his blog for the first time. Here is the original post

Top comments (0)