Wednesday, November 04, 2020

Setting up your Windows Terminal (powerline)

As more and more developers adopt the terminal, it becomes important to bit improvise the experience. 

Scott Hansleman don't need introduction to many programmers. Recently I came across his blog post on beautifying the Windows Terminal. 

 Here I am posting the steps for quick reference. Install Windows Terminal and Git for windows.

For Windows Terminal

 1. Download Cascadia Code font from https://github.com/microsoft/cascadia-code/releases

2. Using Windows Powershell Install Posh and Oh my posh.

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
 

3. Install PSReadline

 Install-Module -Name PSReadLine -Scope CurrentUser -Force -SkipPublisherCheck

4.  Open your PowerShell profile

$ notepad $PROFILE

5.  Add the following lines to your Powershell profile at the end of the file

Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox

6. Set Cascadia Code PL as PowerLine font, by editing Windows Terminal Settings and add 'fontFace' and it looks like this

{
    // Make changes here to the powershell.exe profile.
    "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "name": "Windows PowerShell",
    "commandline": "powershell.exe",
    "fontFace": "Cascadia Code PL",
    "hidden": false
},

7. For Visual Studio Code terminal, Go to File > Preferences > Settings and search for 'Terminal integrated Font Family' and set it to 'Cascadia Code PL'.

For Ubuntu on WSL2

1. Open Ubuntu in Windows Terminal WSL

2. Run the following commands

sudo apt install golang-go
go get -u github.com/justjanne/powerline-go

3.  Open ~/.bashrc using nano and then add this to end of the file and save it.

GOPATH=$HOME/go
function _update_ps1() {
    PS1="$($GOPATH/bin/powerline-go -colorize-hostname -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

 Remember not to add white space around "PS1=". 


For more detailed explanations you can read his blog here : https://www.hanselman.com/blog/how-to-make-a-pretty-prompt-in-windows-terminal-with-powerline-nerd-fonts-cascadia-code-wsl-and-ohmyposh . You can also follow this tutorial from microsoft website from here: https://docs.microsoft.com/en-us/windows/terminal/tutorials/powerline-setup

 He also has a nice youtube video explaining how to set it up. 

 

Also use this link to read about setting up Ubuntu prompt : https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html

This will definitely improve experience  working with the Terminal in windows. Other thing to note is that Oh my Posh V3 beta is here https://github.com/JanDeDobbeleer/oh-my-posh?WT.mc_id=-blog-scottha#themes , keep an eye on the developments of this and adopt the V3 when it is releases.


No comments: