Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork46
⚡️ Znap! Fast, easy-to-use tools for Zsh dotfiles & plugins, plus git repos
License
marlonrichert/zsh-snap
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Znap is a fast, light-weight set of tools to ease the use of Zsh plugins &Git repos and reduce your shell's startup time.
Enjoy using this software?Become a sponsor!
Tested with:
- Zsh 5.8.1
- Git 2.39.1
Put this in your.zshrc file (replacing~/Repos with wherever you want tokeep your Zsh plugins and/or Git repos):
# Download Znap, if it's not there yet.[[-r~/Repos/znap/znap.zsh ]]|| git clone --depth 1 -- \ https://github.com/marlonrichert/zsh-snap.git~/Repos/znapsource~/Repos/znap/znap.zsh# Start Znap
Then restart your shell.
To uninstall, simply remove the above from your.zshrc file and remove Znap's repo.
Znap will automatically manage the repos found in its parent directory. To change the directory it should manage, addthe following to your.zshrc file:
zstyle':znap:*' repos-dir<path>
To update Znap and all of your plugins/repos simultaneously, run
% znap pull
Note, that if you told Znap not to manage its parent directory (see the previous section), then it will not updateitself with this. You will have to manuallycd to its directory and rungit pull.
If there are repos that you do not want to be included byznap pull, add the following to your.zshrc file:
zstyle':znap:pull:*' exclude<repo> ...
To runznap pull on specific repos only, including ones you have set to be excluded, pass them as an arguments:
% znap pull<repo> ...
Znap gives you handy shortcuts to your repos in the form ofnameddirectories.
You can use these both on the command line:
%cd~[zsh-snap]# `cd` to a repo% ls~[asdf/asdf]/completions# `ls` to a subdir in a repo% rm -rf~[zsh-users/zsh]# Remove a repo completely.% print~[zsh-snap]# Print the absolute path of a repo.
And in your dotfiles:
znap clone tuist/xcbeautify zsh-users/zsh-completions# Make sure we have the repos we need. path=(~[tuist/xcbeautify]/tools$path )# Add commands.fpath=(~[zsh-users/zsh-completions]/src$fpath )# Add completions.
Additionally, Znap gives you a shortcut for moving to the root directory of the current repo:
%cd~[zsh-autocomplete]/Functions/Util%cd~[]# Moves you all the way up to ~[zsh-autocomplete].
Using Znap to optimize your Zsh config can be as simple as this:
[[-r~/Repos/znap/znap.zsh ]]|| git clone --depth 1 -- https://github.com/marlonrichert/zsh-snap.git~/Repos/znapsource~/Repos/znap/znap.zsh# `znap prompt` makes your prompt visible in just 15-40ms!znap prompt sindresorhus/pure# `znap source` starts plugins.znapsource marlonrichert/zsh-autocomplete# `znap eval` makes evaluating generated command output up to 10 times faster.znapeval iterm2'curl -fsSL https://iterm2.com/shell_integration/zsh'# `znap function` lets you lazy-load features you don't always need.znapfunction_pyenv pyenv"znap eval pyenv 'pyenv init - --no-rehash'"compctl -K _pyenv pyenv
For more examples of what Znap can do for your dotfiles, please seethe included.zshrcfile.
Additionaly, Znap makes it so that you actually need to haveless in your.zshrc file, byautomating several tasks for you.
Useznap eval ... <command> to cache the output of<command>, compile it, and thensource it (instead ofeval it):
znapeval<name>'<command>'
This can be up 10 times faster than a regulareval "$( <command> )" statement! If you pass a repo as the firstargument, then Znap willeval the command output inside the given repo and will invalidate the cache whenever the repois update. Otherwise, the cache will be invalidated whenever<command> changes. Caches are stored in${XDG_CACHE_HOME:-$HOME/.cache}/zsh-snap/eval.
Note that the above example does not include any call tocomplist,compinit, orbashcompinit inthe.zshrc file. That is because Znap will run these for you as needed.
Znap also regenerates yourcomp dumpfile automatically whenever you update arepo, install a repo, or change your.zshrc file.
If necessary, you can let Znap pass arguments tocompinit as follows:
zstyle'*:compinit' arguments -D -i -u -C -wZnap compiles your scripts and functions in the background. This way, your shell will start up evenfaster next time!
Should you not want this feature, you can disable it with
zstyle':znap:*' auto-compile noIn any case, you can compile sources manually at any time withznap compile [ <dir> | <file> ] ....
Znap also makes life on the command line easier. For a full list of available commands, run
% znap
For more help on a particular command, run
% znaphelp<command>
Exhaustive tab completion is available, too. For examples of the most important command-line features, see below.
Note:
- The examples below you should run on the command line, not add to your
.zshrcfile!%represents the prompt. You shouldn't type that part. 🙂
To check the Git status of all repos managed by Znap, run
% znap status
If there are repos that you do not want to be included byznap status, add the following to your.zshrc file:
zstyle':znap:status:*' exclude<repo> ...
To runznap status on specific repos only, including ones you have set to be excluded, pass them as an arguments:
% znap status<repo> ...
Some commands generate output that should be loaded as a function. You can install these generated functions withznap fpath <function> '<command>'. For example:
% znap fpath _kubectl'kubectl completion zsh'% znap fpath _rustup'rustup completions zsh'% znap fpath _cargo'rustup completions zsh cargo'
This will save them to${XDG_DATA_HOME:-$HOME/.local/share}/zsh/site-functions.
© 2020-2021Marlon Richert
This project is licensed under the MIT License. See theLICENSE file for details.
About
⚡️ Znap! Fast, easy-to-use tools for Zsh dotfiles & plugins, plus git repos
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Contributors14
Uh oh!
There was an error while loading.Please reload this page.