Supercharge zsh with Zap

Zap is a very lightweight (172 kb) plugin manager for Zsh. If you’re looking to improve your terminal usage but don’t know where to start, or if you have a zsh config but it’s a bloated unorganized mess (hey that’s me). Zap is a great choice to hit the ground running or clean things up.

Relevant Links

Install

As a prerequisite, you need zsh. It’s also ideal to have Nerd Fonts.

To install, run the following command in your terminal. This archives any existing .zshrc & creates a new one using zap

zsh <(curl -s https://raw.githubusercontent.com/zap-zsh/zap/master/install.zsh) --branch release-v1
Terminal Output
Moved .zshrc to .zshrc_2023-08-23_1692809128
 Zapped
Find more plugins at https://zapzsh.com
 Zap installed zsh-autosuggestions
 Zap installed supercharge
 Zap installed zap-prompt
 Zap installed zsh-syntax-highlighting

After installing (you may need to restart your terminal). By default, the zap-prompt and a few other features like syntax highlighting and autocompletion are already configured.

Zap Terminal

Navigate to your .zshrc file. If you’re already a zsh user, you may recognize some of these plugins. Zap makes it easy to install common plugins in the zsh ecosystem

  • zsh-autosuggestions - suggest completions
  • supercharge - cool conveniences like auto cd
  • zap-prompt - ⚡| CWD | VC Info
  • zsh-syntax-highlighting - color valid / invalid commands

Any additional config you want to add will also go here in your .zshrc

.zshrc
# Created by Zap installer
[ -f "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh" ] && source "${XDG_DATA_HOME:-$HOME/.local/share}/zap/zap.zsh"
plug "zsh-users/zsh-autosuggestions"
plug "zap-zsh/supercharge"
plug "zap-zsh/zap-prompt"
plug "zsh-users/zsh-syntax-highlighting"

# Load and initialise completion system
autoload -Uz compinit
compinit

Configuring

Zap Outlet lists a ton of compatible plugins.

To add a plugin, simply add plug "user/repository" to your .zshrc.

Personally, I love plug "MAHcodes/distro-prompt". This allows me to assert my dominance in the tech bro hierarchy by showing that I use Arch literally every time I open my terminal.

Big Arch User Energy

You can also use zap to load your own custom plugins or .zsh files. In my case, migrating to zap took less than a minute because I moved all of my aliases and exports over like this

.zshrc
# Community plugin
plug "MAHcodes/distro-prompt"

# Example of a local plugin
plug "$HOME/plugins/my-custom-prompt"

# My existing .zsh files
plug "$HOME/.config/zsh/zsh-aliases"
plug "$HOME/.config/zsh/zsh-exports"

Useful commands

zap list + zap clean can be used to see what plugins you’re using and remove any that are unused. For example, after switching from zap-prompt to distro-prompt

Terminal Output
$ zap list
 Zap - List
   1  🔌 zsh-autosuggestions
   2  🔌 supercharge
   3  🔌 zsh-syntax-highlighting
   4  🔌 distro-prompt
$ zap clean
 Zap - Clean

 Removed zap-prompt

Updating

Terminal Output
zap update self # Update the Zap installation
zap update plugins # Update all your plugins but not Zap
zap update all # Update both the Zap installation and its plugins

Conclusion

I really like and highly recommend Zap. I always worry about bringing in new dependencies or removing old ones because these things can tend to spiral. What should take minutes, may even take hours. That’s not the case with Zap. It was incredibly easy to setup (literally less than 5 minutes to have my whole setup working) and it’s cool to know it has virtually no overhead or bloat.

Wed Aug 23 2023