Customized zsh terminal with Starship prompt and neofetch output

Customizing zsh terminals with oh-my-zsh and Starship.rs

A tutorial on how I personally configure my Linux terminals to look prettier and function better.


As a web developer and Linux user, I spend a lot of time in a terminal. Whether it be in a WSL2 Ubuntu terminal on Windows or a Kitty terminal on Arch Linux, the default styling for the terminals need a lot of work.

Here is how I customize my terminals!

Zed shell (zsh) and oh-my-zsh setup

Usually, Linux terminals use the default bash shell.

If you are using the bash shell, I highly recommend switching to zsh. This will allow us to use oh-my-zsh, which has many useful plugins, such as:

  • Auto-suggestions: shows a gray suggestion after typing a command like cd or vim:
zsh autosuggestions showing a gray command suggestion after typing
zsh autosuggestions showing a gray command suggestion after typing
  • Completions: gives a list of context-aware commands. For example, if we are typing git stash and then hit Tab:

    zsh completions menu for git stash options after pressing Tab
    zsh completions menu for git stash options after pressing Tab

    We get a comprehensive list of all the options available to use!

  • Syntax highlighting: tells you if a command is going to run or not before you use it:

    ✅ Will run:

    zsh syntax highlighting showing a valid command in green
    zsh syntax highlighting showing a valid command in green

    ❌ Won't run:

    zsh syntax highlighting showing an invalid command in red
    zsh syntax highlighting showing an invalid command in red

You can check what shell you are running by running this command in your terminal:

echo $0

If it says bash, then you need to install zsh! Since 99% of people use Ubuntu, here are the steps for switch to the Zed shell with Ubuntu.

Switching to zsh

  1. Install the base shell:
sudo apt update
sudo apt install zsh
  1. Verify it was installed:
zsh --version
  1. Change shells with chsh:
chsh -s $(which zsh)
  1. Restart your terminal and open a new window.

    It will ask you to configure .zshrc, just press q to close out of it. oh-my-zsh will create this file.

    Terminal prompt asking to configure a new .zshrc file
    Terminal prompt asking to configure a new .zshrc file

Installing oh-my-zsh + plugins

Now to truly unlock the power of zsh, we will install oh-my-zsh and add some sensible plugins.

  1. Install oh-my-zsh:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

You should notice the terminal got a little fancy after doing that!

Terminal after installing oh-my-zsh with updated prompt styling
Terminal after installing oh-my-zsh with updated prompt styling
  1. Install some plugins!

zsh-autosuggestions:

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

zsh-syntax-highlighting:

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

zsh-completions:

git clone https://github.com/zsh-users/zsh-completions ${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions

To get zsh-completions to work, you will have to add this line before export ZSH="$HOME/.oh-my-zsh" in your .zshrc file:

fpath+=${ZSH_CUSTOM:-${ZSH:-~/.oh-my-zsh}/custom}/plugins/zsh-completions/src

Should look like this:

.zshrc snippet adding zsh-completions to fpath
.zshrc snippet adding zsh-completions to fpath
  1. Now all we have to do is enable the plugins!
    In .zshrc, at the bottom of the file you will see a plugins=(git). Replace that with this:
plugins=(git zsh-autosuggestions zsh-completions zsh-syntax-highlighting) 

Save the file.

You will have to delete the old completions cache, you will have to delete that so oh-my-zsh doesn't get confused. We also have to apply the .zshrc changes. Here's how to do it in one command:

rm -f ~/.zcompdump; compinit; source ~/.zshrc

You should now notice the plugins working!

Styling with Starship.rs

Starship.rs is how we are going to style our terminal.
Starship technically works on any terminal, even Powershell (🤮powerSMELL am I right??). But for this tutorial, we are going to be installing it on WSL2 Ubuntu.

Enabling a Nerd Font in your terminal

  1. First, download a Nerd Font of your choosing from the Nerd Font website. Personally, I use the CaskaydiaCove Nerd Font. Make sure to install the font on your computer after downloading, I usually download the Regular and Regular Mono variants and that's pretty much it.
  2. Enable the font in your terminal. This is easy in WSL2 Ubuntu:
    1. Hit the downwards chevron next to the new tab button, and click Settings.

      Windows Terminal settings menu opened from the tab chevron
      Windows Terminal settings menu opened from the tab chevron
    2. Then go to: Ubuntu > Appearance

      Windows Terminal Ubuntu Appearance settings panel
      Windows Terminal Ubuntu Appearance settings panel
    3. Set the font to your Nerd Font, then hit Save.

      Windows Terminal font picker set to CaskaydiaCove Nerd Font
      Windows Terminal font picker set to CaskaydiaCove Nerd Font

Installing Starship.rs

  1. Run this command:
curl -sS https://starship.rs/install.sh | sh
  1. SInce we have zsh, we will add this line to the end of our .zshrc file:
eval "$(starship init zsh)"

Should look something like this:

.zshrc with starship init zsh eval line at the end
.zshrc with starship init zsh eval line at the end

Now open up a new terminal, and you should see Starship's default styling applied!

Terminal showing Starship default prompt styling
Terminal showing Starship default prompt styling

Configuring Starship.rs

  1. If you are starting out fresh, you probably don't have a .config directory. You will have to make it:
mkdir -p ~/.config
  1. Now make a starship.toml file inside the .config directory:
touch ~/.config/starship.toml
  1. This is where we will put our config! You can find many starting configs online, or you can start with using mine. Once you starship.toml configured, save the file, you should see the styling immediately!
Terminal with a customized Starship prompt
Terminal with a customized Starship prompt

(Optional) Making Vim better with Neovim & NvChad

If you used Vim for any amount of time, you probably came to this conclusion:

It sucks.

And honestly, even Vim users wouldn't blame you.

But what if I told you we could make Vim look like this? 👇

Neovim with NvChad theme and dashboard UI
Neovim with NvChad theme and dashboard UI

What makes it look pretty is a Neovim config called NvChad. Since Neovim is a prerequisite for NvChad, lets install that first!

Installing and using Neovim

  1. The first step to using Neovim is to install it. Who knew?? Use your package manager to install it, here are the commands for Ubuntu:
sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt update
sudo apt install neovim
  1. Usually, I alias vim to run nvim. This way, when you type something like: vim .zshrc, it will open it in Neovim. This is completely optional. But, if you want to do it, add this line to the end of your .zshrc file:
alias vim='nvim'
  1. It's also helpful to change the EDITOR and VISUAL environment variables so if programs open up a text editor by themselves, it will open up Neovim instead of Vim. To do that, also add these lines to your .zshrc file:
export EDITOR='nvim'
export VISUAL='nvim'
  1. Now open up a new terminal instance and type vim. You should see Neovim pop-up instead!

Making things fun with NvChad

  1. Run this command:
git clone https://github.com/NvChad/starter ~/.config/nvim && nvim

This will open up nvim, it should look like this when done:

Neovim after cloning the NvChad starter config
Neovim after cloning the NvChad starter config
  1. Don't close out just yet! Type :MasonInstallAll and then :TSInstallAll
  2. Then you are pretty much done! Here are a few NvChad keybinds:
  • Spacebar - Opens up the hint window
  • Spacebar + e - Opens up the nvimtree window. You can close it with Spacebar + x
  • Spacebar + t + h - Opens up the theme picker. You can see all the themes NvChad has by default here.
  • Spacebar + c + h - Opens up a Neovim keybind cheatsheet.
  • Spacebar + r + n - Toggles relative line numbers.

NvChad has a ton more features, check them all out here.

(Optional) Adding startup programs to your terminal

Many people add programs like neofetch and pokemon-colorscripts to their terminals, so every time they open a new terminal, the program runs!

Example of neofetch running on startup:

Terminal startup showing neofetch system info output
Terminal startup showing neofetch system info output

All you have to do is download the program you want to run and display, and add it to the end of your .zshrc file. Here's the full process for both!

💡 PRO LINUX POWER USER TIP: You can use this line to instantly append lines to the end of your .zshrc file without having to open it in a text editor:

echo "{your command here}" >> ~/.zshrc

neofetch

  1. Install neofetch with your package manager. For Ubuntu, the command would be:
sudo apt install neofetch
  1. Open up .zshrc, and write neofetch at the end of the file:
.zshrc with neofetch added at the end of the file
.zshrc with neofetch added at the end of the file
  1. Open up a new terminal. Bam!

pokemon-colorscripts

  1. Install pokemon-colorscripts by first cloning the repo...
git clone https://gitlab.com/phoneybadger/pokemon-colorscripts.git
  1. ...going into the directory...
cd pokemon-colorscripts
  1. ...and running the install script.
sudo ./install.sh
  1. Now you can use the pokemon-colorscripts program. Go here to see how to use it to display any set of Pokemon you'd like, or ask an LLM to generate the line for you if you are lazy. In my example, I will be displaying a shiny Reuniclus (my favorite Pokemon) with no title. The exact command for that is:
pokemon-colorscripts -n reuniclus -s --no-title

Adding that line to the end of my .zshrc file:

.zshrc with pokemon-colorscripts command for shiny Reuniclus
.zshrc with pokemon-colorscripts command for shiny Reuniclus

Now opening a new terminal, we see him!

Terminal startup showing a shiny Reuniclus pokemon colorscript
Terminal startup showing a shiny Reuniclus pokemon colorscript
  • Tutorial