Znap!
Zsh-Snap –or Znap for short– is the light-weight plugin manager for Zsh that's easy to grok.
Consisting of only ~4 kilobytes of source code, Znap does everything you need from a plugin manager, but without any bloat.
Znap is in fact so simple, that if you ever have a question about it, the fastest way to get an answer is probably to read the code. Because good software shouldn't be hard to understand.
Oh, and of course, Znap needs exactly zero configuration. Just git clone
the repo into the right place, source
the plugin file, and you're good to go.
Installation
cd
into the dir where you already keep your plugins or where you want to keep your plugins. If you don't have such a dir yet, you'll have to first make one. I personally use the following:mkdir ~/.zsh-plugins cd ~/.zsh-plugins
git clone
this repo. You'll end up with dir calledzsh-snap
inside your plugins dir. This example useshttps
because you don't need a GitHub account for it, but if you do have one, you can usessh
instead:git clone https://github.com/marlonrichert/zsh-snap.git
- (optional) If you want to install Znap elsewhere, you'll need to tell it where to find your plugins dir (which you can also change on the fly):
zstyle ':znap:*' plugins-dir ~/.zsh-plugins
- (optional) If you want to install Znap elsewhere, you'll need to tell it where to find your plugins dir (which you can also change on the fly):
- Add this line near the top of your
~/.zshrc
file —or at least early enough that Znap issource
d before any plugins that you want to manage:source ~/.zsh-plugins/zsh-snap/znap.zsh
- Restart your shell.
Getting Started
git clone
multiple repos simultaneously, including submodules, straight into your plugins dir:
znap clone [email protected]:marlonrichert/zsh-hist.git https://github.com/sorin-ionescu/prezto.git
Instantly re-clone
all repos you've znap clone
d before, again in parallel:
znap clone
Run git pull
simultaneously in all your repos, including submodules, or just in specific ones:
znap pull
znap pull zsh-autocomplete zsh-hist
source
a plugin, or a combination of submodules and/or specific files inside a repo:
znap source zsh-hist
znap source ohmyzsh lib/key-bindings.zsh plugins/history-substring-search
znap source prezto modules/history modules/directory
Add a repo to your $path
or $fpath
:
typeset -gU PATH path=(
$(znap path github-markdown-toc)
$path
)
fpath+=( $(znap path pure) )
Run a command inside a repo, then cache its output and eval
it with automatic cache invalidation:
znap eval LS_COLORS 'gdircolors -b LS_COLORS'
zstyle ":completion:*" list-colors "${(s.:.)LS_COLORS}"
…or run, cache and eval
without a repo (in which case you'll have to manually znap rm
the cache file when necessary):
znap eval brew-shellenv 'brew shellenv'
znap eval pyenv-init 'pyenv init -'
znap eval pipenv-completion 'pipenv --completion'
rm
repos and cache files:
znap rm LS_COLORS prezto brew-shellenv
cd
to your plugins dir, or straight into a repo:
znap cd
znap cd zsh-hist
ls
your plugins dir, or a repo:
znap ls
znap ls zsh-hist
Author
© 2020 Marlon Richert
License
This project is licensed under the MIT License. See the LICENSE file for details.