Nextpertise a journal of interesting technical ideas . . .

Oh My Posh

by Brent Stewart on Tuesday, Jan 25, 2022

I really like the powerline-style prompts that jazz up the command line and I’d like to be able to carry that experience through from Linux to Windows. It seems like everytime I install a new systema and think about this, I find another slightly different way to do something similar. Recently I found Oh My Posh, which is designed to support Windows, Linux, and MacOS. The attraction here is that this gives me the prompt style I like from a consolidated source and with a defined way to set it up.

Here’s an example of OMP installed in Linux running inside Tilix. You can see that it’s providing me collapsed directory information, git info, and the time of the last command. OMP can be customized and the details of that are described extensively in the online docs. Oh My Posh in Tilix on Linux This has some marginal productivity - the Agnoster theme condenses directory structure in a very visible way and helps me understand the state of Git. Regardless, it looks cool and a little terminal rice establishes some credibility. If it looks cool to you too, I’ve put together some notes on how it’s done. Follow along!


Installation on Linux involves grabbing the file from Github and making it executable.

sudo wget -O /usr/local/bin/oh-my-posh
sudo chmod +x /usr/local/bin/oh-my-posh

Next, grab the themes JSON collection, uncompress them, and set the permissions appropriately. With the themes locally stored, you can easily switch as the mode strikes. Agnoster fits my needs, so that’s what is used in the examples, but you can substitute anywhere you see it mentioned.

mkdir ~/.poshthemes
wget -O ~/.poshthemes/
unzip ~/.poshthemes/ -d ~/.poshthemes
chmod u+rw ~/.poshthemes/*.json
rm ~/.poshthemes/

Finally, edit ~/.bashrc to run Oh My Posh as part of the shell. Notice in the code below that I’ve specified the “agnosterplus” layout. Substitute whichever theme you are interested in there.

eval "$(oh-my-posh --init --shell bash --config ~/.poshthemes/agnosterplus.omp.json)"

You’ll need to specify the terminal font in your terminal application. A lot of the styling is done through extra ligatures included in nerd fonts - font files that are re-compiled to include additional symbols. Grab a font you like (I’m using Meslo in this example, but I’m also partial to JetBrains NF) and set it as the default in the terminal profile.

This setup is used by bash, regardless of the terminal application. I have Tabby, Tilix, and the included Terminal from Pop! and all three “just work”. As mentioned, the only cavaet is getting a good font setup in the terminal profile.

Windows PowerShell

As mentioned, Oh My Posh works swimmingly with PowerShell on Windows. I have it working in the Powershell terminal and in the Windows Terminal (but recommend the later).

Om My Posh in Windows Terminal

OMP can be installed on Windows using PowerShell, Chocolatey, Winget, or scoop. I prefer Choco, so that’s what is used in the examples below.

choco install oh-my-posh

Then edit the profile. You may get an error because there’s not an existing profile. If so, just create one. Type $profile in PowerShell to see what the filename and location should be.

notepad $profile

add the following into the profile:

Import-Module oh-my-posh
oh-my-posh --init --shell pwsh --config ~/agnosterplus.omp.json | Invoke-Expression

Again, you’ll need to use the nerd font of your choice. Set this up in the PowerShell Terminal or Microsoft Terminal. Both apps use the same $profile, so you just need to change the font in the terminal.

Windows CMD

OMP is even available for the traditional command line. For cmd, install clink. Clink adds some of the editing features of Bash to the traditional CMD. Download clink and run the installer. You can verify the installer by running clink info.

clink info
version  :
session  : 8504
binaries : C:\Program Files (x86)\clink\
state    : C:\Users\Brent\AppData\Local\clink
    < output trimmed>

Next create a file called oh-my-posh.lua in your clink directory. Note that this directory is given from clink info. The load string below starts OMP - note the theme is specified as well. This section of text can be replaced if you disagree with me on the theme to be used.

notepad AppData\Local\clink\oh-my-posh.lua
    <add this text>
load(io.popen('oh-my-posh --config="C:/Users/Brent/.oh-my-posh/themes/agnosterplus.omp.json" --init --shell cmd'):read("*a"))()


Recent articles related to these tags: Shell Windows Linux
Share this article:    Tweet