How to Customize Ubuntu Terminal

khalidccnu

S.M. Khalid Mahmud

Posted on October 13, 2023

How to Customize Ubuntu Terminal

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Now run the below command to change the shell:

chsh
Enter fullscreen mode Exit fullscreen mode

Then it will ask to set the login shell. So, type:

/bin/zsh
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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')"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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')"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
khalidccnu
S.M. Khalid Mahmud

Posted on October 13, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

What was your win this week?
weeklyretro What was your win this week?

November 29, 2024

Where GitOps Meets ClickOps
devops Where GitOps Meets ClickOps

November 29, 2024