Skip to content
/ zr Public

zsh plugin manager written in rust

License

Notifications You must be signed in to change notification settings

jedahan/zr

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Repository files navigation

z 🐀

zrat

License: MPL 2.0 Build Status

Quick, simple zsh plugin manager

zr 0.9.0
by Jonathan Dahan <hi@jonathan.is>

zr help     show help
zr list     list cached plugins
zr update   update plugin repositories
zr load     generate file to source from  [http://example.com/]plugin/name[.git/path/to/file.zsh]

install

You can use crates.io and cargo to just cargo install zr

usage

Add this to your ~/.zshrc:

# Generate new ~/.zr/init.zsh if it does not exist or ~/.zshrc is newer
if [[ ! -f ~/.config/zr.zsh ]] || [[ ~/.zshrc -nt ~/.config/zr.zsh ]]; then
  zr load \
    frmendes/geometry \
    jedahan/geometry-hydrate \
    junegunn/fzf/shell/key-bindings.zsh \
    > ~/.config/zr.zsh
fi

source ~/.config/zr.zsh

identifiers

zr supports four identifier formats, note that the last format requires .git as a delimeter.

format resolves to
author/name *.zsh from https://github.com/author/name
author/name/file.zsh file.zsh from https://github.com/author/name
https://gitlab.com/a/plugin *.zsh from https://gitlab.com/a/plugin
https://gitlab.com/a/plugin.git/file.zsh file.zsh from https://gitlab.com/a/plugin.git. The .git is used as a delimeter, and is required.

speed

The following benchmark.zsh takes 171ms total, with 26ms spent in zr load for my 2012 13" retina macbook pro.

# install hyperfine for benchmarking
cargo install hyperfine

# benchmark zr init time
hyperfine --warmup 3 'zsh -d -f -l -c "source benchmark.zsh && zrinit && exit"' | grep Time
Time (mean ± σ):      26.0 ms ±   1.6 ms

# benchmark total zsh load time
hyperfine --warmup 3 'zsh -d -f -l -c "source benchmark.zsh && zrinit && source ~/.zr/init.zsh && exit"' | grep Time
Time (mean ± σ):     171.6 ms ±  4.4 ms
# benchmark.zsh
function zrinit {
  zr load sorin-ionescu/prezto/modules/git/alias.zsh \
    sorin-ionescu/prezto/modules/history/init.zsh \
    junegunn/fzf/shell/key-bindings.zsh \
    zsh-users/zsh-autosuggestions \
    zdharma/fast-syntax-highlighting \
    molovo/tipz \
    geometry-zsh/geometry \
    jedahan/geometry-hydrate \
    jedahan/geometry-todo \
    geometry-zsh/geometry \
    ael-code/zsh-colored-man-pages \
    momo-lab/zsh-abbrev-alias \
    jedahan/alacritty-completions \
    zpm-zsh/ssh
}

thanks

  • SX91 for linux fixes
  • alanpearce for bug reports and nix package
  • nshtg for bug reports and windows fix
  • foray1010 for improving install instructions
  • everyone on #rust-beginners