Mastering your Zsh configuration with Antigen and Oh-My-Zsh
About 2 min reading time
Zsh (default on macOS) and Oh My Zsh are among the tools I set up first on every machine. Yesterday I took a look at Antigen, a plugin manager for Zsh, and I was impressed with how well it simplified my previous configuration.
So far, I have always installed Oh My Zsh manually. To do this, you run the following command, and you are actually ready to go:
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
Installing Plugins manually
Well I still have a few plugins that I would like to use. For example I use zsh-autosuggestions and the installation is relatively straightforward:
- clone the repository into
$ZSH_CUSTOM/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
- Add the plugin to the list of plugins for Oh My Zsh to load (inside
~/.zshrc
):
plugins=(
# other plugins...
zsh-autosuggestions
)
- start a new terminal session
This is not particularly difficult at all, and I have worked successfully with this procedure for many years. However, the whole approach has a few disadvantages:
- the installation is always manual work
- the whole setup is complicated to port (I don't like to back up my
.oh-my-zsh
folder somewhere)
Yesterday I came across Antigen, a plugin manager for Zsh that makes working with plugins easier.
Setting up Zsh and "Oh my Zsh" with Antigen
I can save the Oh my Zsh installation and also everything else for now (I only need Zsh). You can install antigen by hand (curl -L git.io/antigen > antigen.zsh
) or you can use homebrew like me (brew install antigen
).
After that, you can work directly in .zshrc
:
# antigen path when using Homebrew:
source $(brew --prefix)/share/antigen/antigen.zsh
# if you installed antigen using curl:
# source /path-to-antigen/antigen.zsh
# Load the oh-my-zsh's library.
antigen use oh-my-zsh
# load plugins
antigen bundle git
antigen bundle node
antigen bundle npm
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zdharma-continuum/fast-syntax-highlighting
antigen bundle djui/alias-tips
# Load the theme.
# my personal theme
antigen theme dzenzes/danielzenzes.zsh-theme --branch=main
# something more popular:
# antigen theme robbyrussell
# Tell Antigen that you're done
antigen apply
# more configuration
It's important to add the antigen apply
at the end. For most plugins, you can find instructions on how to install them with antigen in their GitHub repository.
Themes
It took me a bit longer to install my theme: So far I used a customized copy of Stefan Judis' theme (Blogpost). I copied the theme manually into my .oh-my-zsh
folder. 🙈
As part of my switch to Antigen, I uploaded the theme to a repository and can now install it by referencing the repository in my configuration. The whole thing only works for me if I explicitly include the branch.
All in all, I am very happy with the setup right now. The only manual step at the moment is to run antigen update
in the terminal occasionally to keep the plugins up to date (which should be possible to automate).
How do you use Zsh and what plugins can you recommend? Feel free to sent me a message on Mastodon