How to set up Terminal Oh-my-Posh for a better user experience

Overview

Since the release of the new Terminal application in windows, I have been using more and more powershell, bash and cmd to perform some tasks. At some point, as a dev, I am often missing git informations. When watching conferences I have realized there was a tool that could help with that : Oh My Posh. So I have been using it for a while now, but I m always forgetting to configure some parts of it. Like setting the proper font in Visual Studio Code, etc… Here are my personal notes to not forget about those anymore when setting up new boxes.

Oh my Posh

Installation

For windows :

1
winget install JanDeDobbeleer.OhMyPosh -s winget

For Windows server :

1
Set-ExecutionPolicy Bypass -Scope Process -Force; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://ohmyposh.dev/install.ps1'))

For linux :

1
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d ~/bin

Themes

Official themes are available ‘ here ’. In Windows, edit $PROFILE

1
oh-my-posh init pwsh --config ~/AppData/Local/Programs/oh-my-posh/themes/blue-owl.omp.json | Invoke-Expression

The file saved is located here : C:\Users\{CurrentUser}\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1. To change the location use : Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" -Name "Personal" -Value "MyLocation" Navigating to a git repo folder and executing ‘Get-PoshThemes’ in the Terminal windows will show a preview of all the installed theme for the current folder. Themes are located here : C:\Users\{CurrentUser}\AppData\Local\Programs\oh-my-posh\themes\.

In Linux, edit ~/.bashrc considering all my themes are located in folder ~/.poshthemes.

1
eval "$(oh-my-posh init bash --config ~/.poshthemes/blue-owl.omp.json)"

Fonts

Easy installation from Powershell with elevated rights :

1
oh-my-posh font install commitMono

Visual Studio Code

In Linux or Wondows, open Visual Studio Code. Go to File, Preferences, Settings. Search for ’terminal font family’ and set the value with the Nerd font installed.

Alternatively, edit the ‘settings.json’ file and add :

1
2
    "terminal.integrated.gpuAcceleration": "auto",
    "terminal.integrated.fontFamily": "'CommitMono Nerd Font Mono'",

Visual Studio

The commitMono will not be recognized by Visual Studio. Use Meslo, Meslo or Cousine instead. Other fonts can work, but we need TTF fonts instead of OTF for them to appear in Visual Studio. Easy Font installation from Powershell with elevated rights :

1
oh-my-posh font install Cousine

Then In Visual Studio, go in Tools, Options, Fonts and Colors then select Terminal and set the font to the Nerd font installed.

Terminal & WSL bashes

For each instances where we want to install the Oh-My-Posh, go in Settings, then select the Terminal (like Powershell, or Ubuntu). Scroll down to Appearance and Set the Font-Face to your favourite Nerd Font.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
set $TERM=xterm-256color

sudo apt install unzip

sudo wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh

mkdir ~/.poshthemes
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/themes.zip -O ~/.poshthemes/themes.zip
unzip ~/.poshthemes/themes.zip -d ~/.poshthemes
chmod u+rw ~/.poshthemes/*.json
rm ~/.poshthemes/themes.zip

Once Oh-My-Posh is installed, edit ~/.bashrc considering all my themes are located in folder ~/.poshthemes.

1
eval "$(oh-my-posh init bash --config ~/.poshthemes/blue-owl.omp.json)"

References