Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

⚡️ Znap! Fast, easy-to-use tools for Zsh dotfiles & plugins, plus git repos

License

NotificationsYou must be signed in to change notification settings

marlonrichert/zsh-snap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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!

Requirements

Tested with:

  • Zsh 5.8.1
  • Git 2.39.1

Installation

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>

Updating

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> ...

Named dirs

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].

.zshrc optimization

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.

Fastereval

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.

Automaticcompinit andbashcompinit

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 -w

Asynchronous compilation

Znap 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 no

In any case, you can compile sources manually at any time withznap compile [ <dir> | <file> ] ....

Command-Line Usage

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.zshrc file!
  • % represents the prompt. You shouldn't type that part. 🙂

Check Git status of all repos

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> ...

Install generated functions

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.

Author

© 2020-2021Marlon Richert

License

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

Stars

Watchers

Forks

Sponsor this project

 

Contributors14

Languages


[8]ページ先頭

©2009-2025 Movatter.jp