How to Customize Ubuntu Terminal
Published: 2023-10-13 09:18:47

### Table of Content

- [Install ZSH](#izsh)
- [Install Oh My Posh](#iomp)
- [Install Nerd Font](#inf)
- [Activate Oh My Posh](#aomp)
- [Change the Theme](#ct)

<a name="izsh"></a>

> #### 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 <kbd>Enter</kbd>.

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.

<a name="iomp"></a>

> #### 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
```

<a name="inf"></a>

> #### Install Nerd Font

You need to use Nerd Font to **display** all the nice custom icons. You can download them directly from [here](https://www.nerdfonts.com/font-downloads). Just save them on your computer, unzip and install them.

Then, you need to set this font from terminal settings.

<a name="aomp"></a>

> #### 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 <kbd>Ctrl</kbd> + <kbd>O</kbd> and then <kbd>Enter</kbd> to save your file, and to close the file, press <kbd>Ctrl</kbd> + <kbd>X</kbd>.

Finally, you need to activate the theme by running the below command:
```
source ~/.zshrc
```

<a name="ct"></a>

> #### 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 <kbd>Ctrl</kbd> + <kbd>O</kbd> and then <kbd>Enter</kbd> to save your file, and to close the file, press <kbd>Ctrl</kbd> + <kbd>X</kbd>.

Finally, you need to activate the new theme by running the below command:
```
source ~/.zshrc
```