Improve command line UX on Windows
Tags: windows, windowsterminal, commandline, productivity
Published: 2021-08-10 19:56:17

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xj7rabm1kl4g3hjzxdqo.png)

## 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0w44591hrlgln8rp7wpz.png)
 
## 3. Update PowerShell
Run PowerwShell and type `$PSVersionTable.PSVersion` Probably version 5 is installed on your machine. 
```powershell
Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  1023
```

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uuit4wtj46fs2w9rycce.png)
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hxh1a73z9wgrfc0xdmtg.png)
 
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zejeyjmye2oozaq7fjec.png)
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p4ea140lr8k4mkib9e0o.png)
 
Restart Windows Terminal to verify the step.

## 5. Install a proper font
1. I recommend Caskaydia Cove from from [Nerd Fonts](https://github.com/ryanoasis/nerd-fonts) repository. This font is based on well-known [Cascadia Code](https://github.com/microsoft/cascadia-code). Nerd Fonts mod adds extra glyphs to the original font.
2. Download the patched version of the font [from here](https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/CascadiaCode/Regular/CaskaydiaCoveNerdFontMono-Regular.ttf) (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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9zc6peh2c61nx3m21bi.png)


 
## 6. Install required PowerShell modules
Now the fun part begins. We will install more themes and tweaks to the Terminal. Run these commands
```powershell
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
```

## 7. Pick a theme
Run `Get-PoshThemes` and locate one you like the most.

## 8. Set theme
```powershell
Set-PoshPrompt -Theme themename
```
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.
```powershell
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme themename
```

## 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](
https://www.hanselman.com/blog/how-to-make-a-pretty-prompt-in-windows-terminal-with-powerline-nerd-fonts-cascadia-code-wsl-and-ohmyposh)