Getting Started With ZSHa read
The following is a small story of my switch to zsh, followed up by my dotfiles management. I decided I needed to upgrade my terminal experience and make it consistent between my main machine and any other machine I regularly use such as the servers at University. To start, I decided to take the full plunge and give my terminal a makeover starting with ripping out bash and replacing it altogether.
What is ZSH?
zsh is a shell similar to
bash with many powerful plugins and features. Getting started is easy. It it available on
homebrew, or through most package managers. Now, to use it as your default shell either:
This option directly changes the shell your user loads into.
echo $(which zsh) >> /etc/shells
chsh -s $(which zsh)
b) add zsh to your
This snippet checks for the existence of zsh and runs it meaning it can be synced across machines and run when zsh is available. Useful for situations where you don’t have priveleges.
echo "[ -x "$(command -v zsh)" ] && exec zsh -l" >> .bash_profile
zsh enabled, you can now start to get acquainted. One of the great things of zsh are the many package managers
available for it, some examples of which being
antigen. My personal favorite is antigen,
because of how easy it is to define packages, and how unobtrusive it is. To get started with antigen you simply have to
download the script and source it from your newly created
curl -L git.io/antigen > antigen.zsh
echo "source PATH_TO_ANTIGEN/antigen.zsh" >> ~/.zshrc
With antigen added to your zshrc, you can start using antigen packages. Antigen lets you download packages straight from
github, simply by running the command
antigen bundle USER/REPO. Additionally, antigen can use all the packages from
oh-my-zsh as well such as git, heroku or pip. For example, to load a github bundle try running the following code:
antigen bundle MichaelAquilina/zsh-you-should-use
or, to use an oh-my-zsh package:
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# Bundles from the default repo (robbyrussell's oh-my-zsh).
antigen bundle git
antigen bundle heroku
antigen bundle pip
The package will download (unless already cached) and will be applied immediately. To automate this when we start the
terminal, it makes sense to add these declarations to the
.zshrc file as well. Here are some useful zsh packages that
antigen can install for you:
This plugin is fairly straight-forward. It simply reminds you when there is an already existing alias for the command you are typing.
This plugin adds nifty autosuggestion to your prompt, which suggests a completion for the current command based on your
history. Pressing the left arrow will then fill the command for you, saving time for repeated commands (such as in my
The last plugin on in the list brings syntax highlighting to the terminal which (amongst other things) lets you visually see if a command exists before even running it. Very useful.
A final feature antigen boasts is the ability to apply themes, through the
antigen theme command. The theme I use is
spaceship which is a fairly robust 2-line command line with
a whole load of features. Its quite straight forward, and needs a bit of tweaking and testing to see what you like. When
you have chosen your configuration of choice, the last command to run is
Here is my complete configuration:
To start heading down the rabbit hole, have a look at awesome-zsh-plugins which includes an exhaustive list of plugins for zsh, and lastly, happy zsh-ing.