Set Up and Beautify ZSH in Manjaro Linux

Become a Command-Line Power User

Rumaisa Niazi
4 min readJul 9, 2021
Photo by Florian Olivo on Unsplash

Zsh is a powerful, customizable Unix shell. It is a command-line interpreter that incorporates rich features of other Linux shells and offers features like loadable modules, tab completion, regex integration, and much more.

Any user relatively new to Linux must have used Bash, the Bourne-Again Shell. It’s a shell with progressive features as it ships as a default shell for Unix/Linux systems. However, an experienced user will look for many ways to improvise shell interaction. Hence, users migrate from bash to Z.

Zsh is also supported by a community-driven open-source framework, oh-my-zsh. It enables zsh configuration with tons of plugins, themes, and other features to beautify the terminal.

In this guide, we will install zsh, set it as a default shell and beautify our terminal with the oh-my-zsh framework. Let’s get started!

Install ZSH

Update the Manjaro repository and install zsh as follows:

#sudo pacman -Syu && sudo pacman -S zsh

Install Oh-My-Zsh

Make sure you have curl or wget to commands in the terminal. To install either of these utilities with git and carry out the oh-my-zsh installation as follows:

for wget:

#sudo pacman -S curl wget git#sh -c “$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)”

for curl:

#sudo pacman -S curl git#sh -c “$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

We will now git clone the two most fundamental oh-my-zsh plugins. The zsh-syntax-highlighting plugin enables command highlighting and helps catch syntax errors.

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

Where the zsh-autosuggestions plugin offers command completion based on commands history.

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

Configure ~/.zshrc

Choose a theme of your choice from oh-my-zsh themes and enable the selected theme by setting its name to ZSH_THEME in the ~/.zshrc file.

ZSH_THEME=”theme_name”

Add the downloaded plugins:

plugins=(gitzsh-autosuggestionszsh-syntax-highlighting)

Now source the file to make changes into effect.

#source ~/.zshrc

It’s important to note that oh-my-zsh installation creates a backup of the current .zshrc file and creates a new .zshrc file for configuration. Hence, whenever we remove oh-my-zsh files, the backup file is reverted.

Make ZSH the Default Terminal

Use echo $SHELL to find the existing default terminal. Now run the following command to migrate to zsh:

#chsh -s $(which zsh)

The command may output some error and does not make zsh as the default shell. It might be possible that the shell is already changed.

Use cat /etc/passwd | grep “manjaro/username” to find the default shell, it returns:

manjaro:x:1000:1001:manjaro:/home/manjaro:/usr/bin/zsh

However, echo $SHELL command outputs /bin/bash.

Before executing any other commands, the quickest trick here is to reboot the machine, as it resolves the problem.

Enable user/hostname at The ZSH Terminal

From the screenshots above, we can notice that zsh hides the username and hostname of the machine. It requires us to modify the theme settings.

Head to the .oh-my-zsh/themes directory in the home folder and open the agnoster-theme file with your favorite editor.

#cd ~/.oh-my-zsh/themes && sudo vim theme_name.zsh-theme

Now replace the PROMPT=’$(git_custom_status)%{$fg[cyan]%}[%~% ]%{$reset_color%}%B$%b ‘ with the following PROMPT value.

PROMPT=’%(!.%{%F{yellow}%}.)$USER @ %{$fg[white]%}%M %{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}’PROMPT=’%(!.%{%F{yellow}%}.)$USER @ %{$fg[white]%}%M %{$fg_bold[red]%}➜ %{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}’

Save and exit the file.

[~]$ source ~/.zshrc

Thank you for coming this far.

The guide covers zsh and oh-my-zsh installation and configuration. We also learn about oh-my-zsh themes and plugins with tips and tricks for setting zsh as the default terminal and enabling username and hostname.

--

--