Customise Your Terminal Like You Deserve
Tags: linux, beginners, tutorial, productivity
Published: 2022-05-12 10:51:12

If You Use Terminal for any reason then you might find find it boring and awful. In Ubuntu the default shell is `bash` which is **OK** to do your every work but you can be much **productive** with the help of a good customised terminal. Follow along this blog and your terminal will be like This.

![My Terminal Looks](https://cdn.hashnode.com/res/hashnode/image/upload/v1652261496483/2yehOM1a9.png)

If You Look At the Image, this **Terminal** is like the one you ***always*** wanted. This is not just only **visually appealing** but can boost your **productivity** much more.

It has many features, some of them are listed here

- Colourful Prompt with Icons
- Many Themes to choose from
- Customiseable shorthand commands
- Autosuggestion through your command history
- Selectable prompt for everything
- And Much More!

With This you will also learn some **quick terminal tricks!**

So Lets get started.

# The Shell
We are going to use the `zsh` shell with **"Oh My ZSH!"** Configuration. It is available for WSL (Windows Subsystem for Linux) and Linux. It is the default shell for Mac OS. You Can also install it on default windows but that is little bit tricky so I will not cover it here. (May be I will do in Future)

## Installation on Ubuntu
**(Same command on any other non-ubuntu distro, except the package manager)**

To Install `zsh` run, Open Up your terminal and type these commands: 

```bash
# First Install/update some required packages
sudo apt update  # for ubuntu based distos only
sudo apt install curl git # needed for installation
sudo apt install zsh  # install the actual shell
``` 
Now you need to run the installation script for **"Oh My ZSH!"**
```bash
# run this in your linux distro/ MacOS
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```
It will setup the shell for you. It will ask if you want to change the default terminal. Just Enter your password and continue.

## If you couldn't change shell
If for some reason you can't change your shell, follow these steps:
```bash
where zsh
```
You May Find Multiple paths like `/usr/bin/zsh` and `/bin/zsh`, you can use anyone them. Then run
```bash
chsh
```
Enter your password, then enter the path you got previously.

Now once your zsh is setup, Reboot your PC so that the shell can change in next boot up.

# Installing A Theme
150 themes come preinstalled with `zsh`. You can check them [here](https://github.com/ohmyzsh/ohmyzsh/wiki/Themes). You May Find Your Theme there but I will show you one of the best theme.

## Installing Powerlevel10k theme
### Installing Required Font
You Need to install some font to make the icons work. So download and install these
- [MesloLGS NF Regular.ttf](https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf)
- [MesloLGS NF Bold.ttf](https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf)
- [MesloLGS NF Italic.ttf](https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf)
- [MesloLGS NF Bold Italic.ttf](https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf)

After Download, Open Your Files and Double Click to Install them. Then Change Your Terminal Font. ([Instructions](https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k))
### Change Your Theme
Now You need to copy the **Powerlevel10k** guthub repo first. Run
```bash
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
```
After that Open your home folder and open `.zshrc` file in an text editor. In that file you would see and entry called `ZSH_THEME`, add an `#` at beginning of that line and paste this line below that.
```bash
ZSH_THEME="powerlevel10k/powerlevel10k"
```

![Changing the ZSH Theme](https://cdn.hashnode.com/res/hashnode/image/upload/v1652329735519/HK5Nvr0X8.png)

Now Save the file and Run
```bash
exec zsh
```
Now it will open a menu asking some questions.

## Customising Your Terminal
You will get the p10k prompt after changing your theme. If you want change your settings later then you would need to run
```bash
p10k configure
```
(**If it says `p10k not found` then change your theme and try again**)

You Firstly It will ask you some questions to assure your font is correct.

![Asking Font Questions](https://cdn.hashnode.com/res/hashnode/image/upload/v1652329876899/YDypR4_6v.png)


(If you can't see the correct icons try checking your terminal font settings.)

If you can see the correct icons then press `y` for 3-4 questions .

Now it will ask about the style choice of your terminal. **Choose Whatever you like**.
![Asking for Prompt Style](https://cdn.hashnode.com/res/hashnode/image/upload/v1652329948677/_8c8fODzdn.png)
I Like the Classic so i will press `2`

Choose Everything According to your need.

Finally It will ask you  about Instant Prompt.

![Instant Prompt.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1652330365450/8OXmVb9C6.png)
 Choose `versbose` by pressing 1. It will write settings automatically. 

![Rewrite Prompt.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1652330500602/BYSy3q9Hu.png)
*Also say yes in rewrite prompt if you are re-configuring.*

**Now You Have a beautiful terminal like mine.**

# Quick Terminal Shorthand Commands
You May want to have shorthand commands for some really long commands. You can make your custom commands too.
## Using Alias Commands
If You Have a command which doesn't require arguments in between then you may use alias. 

Open Your `.zshrc` file in text editor. Then Add This Line at last and save.
```bash
alias cls="clear"
```
I am used to `cls` command in windows so I use it in linux too.

Now restart your terminal or type `exec zsh`, then type `cls` and your terminal will be cleared! You can add as many alias as you want. Like add
```bash
alias la="ls -A"
```
Now using `la` you can list your hidden files too.

## Using Commands with arguments
When I use nodejs, I feel that `npm run dev` is a very long command. So What I Can do is added this to my `.zshrc`
```bash
nr() {
        npm run $1;
}
```
Now I Can use `nr dev` instead. You Can Learn More about these [here](https://opensource.com/article/20/6/bash-functions).

You Can Use these as you want.

# ZSH Autosuggestion
You can Install Many Plugins for ZSH. [Here](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins) is the List of pre-installed plugins.
git plugin is preconfigured as you can see here

![Git Plugin.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1652332226866/9aCrNI_GU.png)
But Now I am going to install the autosuggestion plugin. Install it through git by running
```bash
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
```

Then find the line `plugins=(git)` and change that line like this
```bash
plugins=(
         git
         zsh-autosuggestions
)
```
Now restart (`exec zsh`) and you will have auto suggestions.

---

Hope You Liked My Post, If you did then please comment your feedback.

Till then Bye. 👋