DEV Community

Mr F.
Mr F.

Posted on • Edited on

Awesome Terminal upgrades - Part Three: Manage ZSH plugins using Zplugin

Recently, I wrote an article about customising your shell using ZSH.

However, as one person pointed out in the comments, the startup time and performance was excrucuatingly slow.

So I set about making sure I chose a better ZSH manager this time around.

According to this comparison of ZSH frameworks and plugin managers, if you're using any plugins and doing any sort of development, Zplugin is the only option to consider, especially if you use tools like thefuck for example.

It turns out, Zplugin is hands down the fastest most performant ZSH plugin manager, beating Oh-My-ZSH, Antigen, Zplug, Prezto and so on.

zplugin startup times

Zplugin launches in < 1 second (~50ms) as opposed to > 8 seconds which I was experiencing whilst using zplug!

Install Homebrew

The missing package manager for macOS (or Linux)

We will be using Homebrew to manage everything for us, if you don't have it installed, go ahead and do it now!

echo “[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion” >> ~/.bash_profile
Enter fullscreen mode Exit fullscreen mode

Install Zplugin

brew install zplugin
Enter fullscreen mode Exit fullscreen mode

Zplugin will dump some lines of code into your .zshrc file:

source "$HOME/.zplugin/bin/zplugin.zsh"
autoload -Uz _zplugin
(( ${+_comps} )) && _comps[zplugin]=_zplugin
Enter fullscreen mode Exit fullscreen mode

Install some plugins to get up and running

Once the above output is added to you .zshrc, we can leverage Oh-My-ZSH's plugins and add some functionality and shortcuts. We'll add Git and SSH to keep it shoer, we'll add some auto suggestion and completion features as well.

We reference OMZ plugins with zplugin snippet OMZ:: followed by the path to the zsh command eg ssh-agent/ssh-agent.plugin.zsh to make zplugin snippet OMZ::ssh-agent/ssh-agent.plugin.zsh.

Here is a more fleshed out example:

zplugin ice blockf
zplugin light zsh-users/zsh-completions

zplugin ice as"program" pick"$ZPFX/bin/git-*" make"PREFIX=$ZPFX"

zplugin ice wait lucid atload'_zsh_autosuggest_start'
zplugin light zsh-users/zsh-autosuggestions

zplugin snippet OMZ::plugins/git/git.plugin.zsh
zplugin snippet OMZ::plugins/ssh-agent/ssh-agent.plugin.zsh
Enter fullscreen mode Exit fullscreen mode

After you've done this you will want to source your .zshrc file again:

source ~/.zshrc
Enter fullscreen mode Exit fullscreen mode

And voila! You're all done, ready and up and running!

Here is what my own .zshrc file looks like:

Top comments (0)