Purpose
Sometimes, classic bash stops being sufficient for every developer and I mean not it's utility but details that it can show to us.
For this purpose, comes Oh-My-Posh, which as author states is:
Oh My Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable.
Preparation
First things first, in order to install it. We can install it manually, or with homebrew
which every developer that works on Linux, should have.
Homebrew
We install it with this tiny snippet:
sudo apt-get install build-essential procps curl file git
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then we pass it to our .profile
:
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/ubuntu/.profile
Or:
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
Then we need to restart our shell:
exec "$SHELL"
And update our new brew
:
brew update
And that's it, now we can use e.g.:
brew install minikube
But that is not a purpose of this topic.
Oh-My-Posh
Manual installation looks like this:
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
With brew:
brew install jandedobbeleer/oh-my-posh/oh-my-posh
brew update && brew upgrade oh-my-posh
We are going to need special font for it:
cd ~
mkdir .fonts
unzip ~/Downloads/Meslo.zip -d ~/.fonts/Meslo
fc-cache -fv
Then we download official theme pack from author:
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
Then we go to this website and look for theme and add it to ~/.profile
:
echo 'eval "$(oh-my-posh init bash --config ~/.poshthemes/theme_name.omp.json)"' >> ~/.profile
exec SHELL
Installing on Windows
For Windows users installation looks like this:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force;
Install-Module oh-my-posh -Scope CurrentUser
Add-Content $PROFILE "`nSet-PoshPrompt -Theme tonybaloney"
Than in order to set theme use snippet below:
Add-Content $PROFILE "`nSet-PoshPrompt -Theme YOURTHEME"
Note that you will need any font from here: link.
Top comments (2)
Hi!
Thanks for the tutorial.
Is that applicable on windows?
Hi!
Yes of course, you can install it for 'Powershell' & 'Terminal' :)
Link:
ohmyposh.dev/docs/installation/win...