How to Customize Ubuntu Terminal
S.M. Khalid Mahmud
Posted on October 13, 2023
Table of Content
Install ZSH
At first, you need to install the Z shell. So, go to the Ubuntu terminal and run the below command:
sudo apt install zsh
After that is done, need to change the default shell. By default, it remains bash. If you want to check it, then run the below command:
echo $0
Now run the below command to change the shell:
chsh
Then it will ask to set the login shell. So, type:
/bin/zsh
And press Enter.
Now restart the terminal, and you'll be greeted by ZSH config. In that case, select option 2 (press 2 on your keyboard) for the default settings.
Congratulations! You now have set ZSH as your default shell. Now you can go ahead with your terminal customization and install Oh My Posh.
Install Oh My Posh
First, you need to install Oh My Posh and UnZip so you can unzip the files in a second.
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
sudo apt install unzip
Next up, you need to download the themes.
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
Install Nerd Font
You need to use Nerd Font to display all the nice custom icons. You can download them directly from here. Just save them on your computer, unzip and install them.
Then, you need to set this font from terminal settings.
Activate Oh My Posh
Now you need to add some code to your zshrc file; which theme you want to use in Oh My Posh will indicate. That's a necessary step for terminal customization.
Open your zshrc file by running the below command:
nano ~/.zshrc
And add the following two lines at the bottom of it.
# Oh My Posh Theme Config
eval "$(oh-my-posh --init --shell zsh --config '~/.poshthemes/atomic.omp.json')"
Now press Ctrl + O and then Enter to save your file, and to close the file, press Ctrl + X.
Finally, you need to activate the theme by running the below command:
source ~/.zshrc
Change the Theme
Now, if you want to change your current theme, then just open your zshrc file by running the below command:
nano ~/.zshrc
And scroll down to where you added your # Oh My Posh Theme Config and replace the old theme name with the new theme name.
# Oh My Posh Theme Config
eval "$(oh-my-posh --init --shell zsh --config '~/.poshthemes/night-owl.omp.json')"
Now press Ctrl + O and then Enter to save your file, and to close the file, press Ctrl + X.
Finally, you need to activate the new theme by running the below command:
source ~/.zshrc
Posted on October 13, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.