This tutorial will guide you through steps to Install Zsh on Linux and Configure it to suite your needs.
Definition of shell from Wikipedia:
A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems. Users direct the operation of the computer by entering commands as text for a command line interpreter to execute or by creating text scripts of one or more such commands.
Most fresh installation of Linux comes pre-loaded with Bash shell. Personally i like zsh, and it’s my favorite shell that i use all the time.
Zsh does a bunch of other useful things that bash alone won’t accomplish.
Apart from being a powerful scripting language, Zsh is a shell designed for interactive use.It incorporates into it many useful features of Bash, ksh, and tcsh.Othe additional features provided by zsh are:
- Auto Completions are case insensitive much faster than bash.
- All sorts of bells and whistles made possible by community driven framework like oh-my-zsh.
- Support multi-line editing
- Recursive file globbing
- Highly compatible with ksh.
- Zsh has huge collection of better themes.
- Simple configuration style
- Output redirection to multiple destinations
And many more, do some googling to learn more. Here you’ll Install Zsh on Linux.
Install Zsh on Linux
sudo pacman -S zsh
emerge --ask zsh
sudo apt-get install zsh
sudo dnf install zsh
yum install zsh
yum install zsh
Check and Change shell to Zsh
Confirm it’s installed and see list of installed shells. After you successfully Install Zsh on Linux, you should see version displayed.
zsh --version chsh -l
After you’ve installed it, we need to make it our default shell and customize it to get extra eye-candy.We’ll change shell for both root and standard user account.
Install Oh My Zsh
Easiest way to customize zsh is to install Oh My Zsh to set zsh theme. Oh My Zsh is an open source, community-driven framework for managing your zsh configuration.It comes with load of plugins and themes to take advantage of. Install it as below.
Make sure you have all above prerequisites installed on your system.
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Once installed, you’ll get a bundle of themes that comes with it, located at ~/.oh-my-zsh/themes/
You can also take a look in the plugins directory to see all plugins available.
ls -lh ~/.oh-my-zsh/plugins
Install Oh My Zsh themes for Zsh
We’ll install my favorite theme to ~/.oh-my-zsh/themes/ and configure .zshrc to use it.
cd ~/.oh-my-zsh/themes/ git clone https://github.com/oskarkrawczyk/honukai-iterm-zsh.git cp honukai-iterm-zsh/honukai.zsh-theme ~/.oh-my-zsh/themes/
Modify theme variable name to ZSH_THEME=”honukai” in ~/.zshrc
See screenshot below,
Save changes and exit. Type CTRL+X, Then Y.
Source ~/.zshrc file
Configure Help command.
Add the following lines to the end.
autoload -U run-help autoload run-help-git autoload run-help-svn autoload run-help-svk alias help=run-help
Source it and you’re good to go.
Fish-like syntax highlighting (Optional)
cd ~/.oh-my-zsh/plugins git clone https://github.com/zsh-users/zsh-syntax-highlighting.git nano ~/.zshrc
Add below line at the end,
Then source zshrc file
Persistent rehash: This allow compinit to automatically find new executables in the $PATH.
zstyle ':completion:*' rehash true
Save and exit, the source it.
Configure additional zsh-completions, applicable to all Linux systems.
I will assume you already installed oh-my-zsh, if not refer to it above.
git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions
Then enable it in your .zshrc
plugins+=(zsh-completions) autoload -U compinit && compinit
zsh tab-completion system
To enable the famous zsh tab-completion system, you need to add above commands ( autoload -U compinit && compinit).
If you are running Arch Linux, you can install it using Pacman package manager. This has an advantage of getting updates for it automatically.
pacman -S zsh-completions
Installing zsh-completions on Gentoo
emerge --ask zsh-completions
When you use pacman and emerge, it will enable it automatically on zshrc file.
To unistall oh-my-zsh type
rm -rf ~/.oh-my-zsh
We’ve covered how to Install Zsh on Linux and configuring Zsh environment on your system. Zsh is the most customizable shell i have ever used. It’s easy to install and customize with more than 100 themes. There are plenty of plugins to extend its functionality with frameworks like oh-my-zsh. Zsh is worth your time and i think you should give it a try.