A Zsh-Zinit annex that installs rust and cargo packages locally inside the plugin or snippet directories. The crate can
then have a so called shim created (name borrowed from rbenv) – a script that's located in the standard $PATH
entry "$ZPFX/bin" of following contents (example):
#!/usr/bin/env zsh
function lsd {
local bindir="/root/.zinit/plugins/zdharma-continuum---null/bin"
local -x PATH="/root/.zinit/plugins/zdharma-continuum---null"/bin:"$PATH" # -x means export
local -x RUSTUP_HOME="/root/.zinit/plugins/zdharma-continuum---null"/rustup CARGO_HOME="/root/.zinit/plugins/zdharma-continuum---null"
"$bindir"/"lsd" "$@"
}
lsd "$@"As it can be seen shim ultimately provides the binary to the command line.
- Installation
- Usage
- Examples
- Install rust, the
lsdcrate, and alsdshim exposing the binary - Install rust, the
exacrate, and alsshim exposing theexabinary - Install rust and then the
exaandlsdcrates - Installs rust and then the
exa' andlsd' crates and exposes their binaries by altering $PATH - Installs rust and then the
exacrate and creates its shim with standard error redirected to /dev/null - Install Rust and make it available globally in the system
- Use Bin-Gem-Node annex to install the cargo completion provided with rustup
- Install rust, the
Load like a regular plugin, i.e.,:
zi light zdharma-continuum/zinit-annex-rustThis installs the annex and makes the rustup and cargo'' ices available.
The Zinit annex provides two new ices: rustup and cargo''. The first one installs rust inside the plugin's folder
using the official rustup installer. The second one has the following syntax:
cargo"[name-of-the-binary-or-path <-] [[!][c|N|E|O]:]{crate-name} [-> {shim-script-name}]'
| Flag | description |
|---|---|
N |
redirect both standard output and error to /dev/null |
E |
redirect standard error to /dev/null |
O |
redirect standard output to /dev/null |
c |
change the current directory to the plugin's or snippet's directory before executing the command |
As the examples showed, the name of the binary to run and the shim name are by default equal to the name of the crate.
Specifying {binary-name} <- … and/or … -> {shim-name} allows to override them.
zinit ice rustup cargo'!lsd'
zinit load zdharma-continuum/nullzi ice rustup cargo'!exa -> ls'
zi load zdharma-continuum/nullzinit ice rustup cargo'exa;lsd'
zinit load zdharma-continuum/nullzinit ice rustup cargo'exa;lsd' as"command" pick"bin/(exa|lsd)"
zinit load zdharma-continuum/nullInstalls rust and then the exa crate and creates its shim with standard error redirected to /dev/null
zinit ice rustup cargo'!E:exa'
zinit load zdharma-continuum/nullzi ice \
id-as"rust" \
wait"0" \
lucid \
rustup \
as"command" \
pick"bin/rustc" \
atload='export CARGO_HOME=$PWD RUSTUP_HOME=$PWD/rustup'
zi load zdharma-continuum/nullzi for \
atload='
[[ ! -f ${ZINIT[COMPLETIONS_DIR]}/_cargo ]] && zi creinstall rust
export CARGO_HOME=\$PWD RUSTUP_HOME=$PWD/rustup' \
as=null \
id-as=rust \
lucid \
rustup \
sbin="bin/*" \
wait=1 \
zdharma-continuum/nullWhen using a global installation of rust in turbo mode, cargos need to omit the rustup ice, and wait on $CARGO_HOME
and $RUSTUP_HOME environment variables to be available
zi for \
wait='[[ -v CARGO_HOME && -v RUSTUP_HOME ]]' \
id-as'rust-exa' \
cargo'!exa' \
zdharma-continuum/null