Yet Another Developer
Devlogify

Devlogify

Customise Your Terminal Like You Deserve

Your Current Terminal may look bit boring! Spice Up Your Terminal Now With These Customisation.

Yet Another Developer's photo
Yet Another Developer
·May 12, 2022·

5 min read

Table of contents

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

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:

# 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!"

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

where zsh

You May Find Multiple paths like /usr/bin/zsh and /bin/zsh, you can use anyone them. Then run

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. 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

After Download, Open Your Files and Double Click to Install them. Then Change Your Terminal Font. (Instructions)

Change Your Theme

Now You need to copy the Powerlevel10k guthub repo first. Run

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.

ZSH_THEME="powerlevel10k/powerlevel10k"

Changing the ZSH Theme

Now Save the file and Run

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

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

(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 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 Choose versbose by pressing 1. It will write settings automatically.

Rewrite Prompt.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.

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

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

nr() {
        npm run $1;
}

Now I Can use nr dev instead. You Can Learn More about these here.

You Can Use these as you want.

ZSH Autosuggestion

You can Install Many Plugins for ZSH. Here is the List of pre-installed plugins. git plugin is preconfigured as you can see here

Git Plugin.png But Now I am going to install the autosuggestion plugin. Install it through git by running

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

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. 👋

 
Share this