🌀 Rust
An annex installs rust and cargo packages locally inside the plugin or snippet directories.
- Player
- Shortcuts
Key | Description |
---|---|
f | Toggle fullscreen mode |
space | Play / Pause |
← → | Rewind by 5sec. / Fast-forward by 5sec. |
Shift + ← / Shift + → | Rewind by 10% / fast-forward by 10% |
0, 1, 2, 3, 4, 5, 6, 7, 8, 9 | Jump to 0%, 10%, 20%, 30%, 40%, 50%, 60%, 70%, 80%, 90% |
Usage of the annex
The Zi annex provides ice-modifiers rustup
and cargo'…'
.
The first one installs rust inside the plugin's folder using the official rustup
installer and 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.
The crate can create so-called shims – scripts that are exposed to the standard $PATH
. The shim script is a wrapper around the binary that is installed by the crate. The shim script is created in the plugin's or snippet's directory and is named after the crate. The shim script is a shell script that sets up the environment variables and then runs the binary.
Example of the shim script:
#!/usr/bin/env zsh
function lsd {
local bindir="/root/.zi/plugins/z-shell---null/bin"
local -x PATH="/root/.zi/plugins/z-shell---null"/bin:"$PATH" # -x means export
local -x RUSTUP_HOME="/root/.zi/plugins/z-shell---null"/rustup CARGO_HOME="/root/.zi/plugins/z-shell---null"
"$bindir"/"lsd" "$@"
}
lsd "$@"
As it can be seen shim ultimately provides the binary to the command line.
Use case examples
Set up rust and the lsd
crate with a shim lsd
exposing the binary:
zi ice rustup cargo'!lsd'
zi load z-shell/0
Set up rust and the exa
crate with a shim ls
exposing the exa
binary:
zi ice rustup cargo'!exa -> ls'
zi load z-shell/0
Set up rust and the exa
and lsd
crates:
zi ice rustup cargo'exa;lsd'
zi load z-shell/0
Set up rust, then the exa
and lsd
crates, with their binaries exposed by altering $PATH
:
zi ice rustup cargo'exa;lsd' as"command" pick"bin/(exa|lsd)"
zi load z-shell/0
Set up rust and then the exa
crate with shim standard error redirected to /dev/null
:
zi ice rustup cargo'!E:exa'
zi load z-shell/0
Just install rust and make it available globally in the system:
zi ice id-as"rust" wait"0" lucid rustup as"command" pick"bin/rustc" atload="export \
CARGO_HOME=\$PWD RUSTUP_HOME=\$PWD/rustup"
zi load z-shell/0
A little more complex rustup configuration that uses bin-gem-node annex and installs the cargo completion provided with rustup, using the for syntax:
zi id-as=rust wait=1 as=null sbin="bin/*" lucid rustup \
atload="[[ ! -f ${ZI[COMPLETIONS_DIR]}/_cargo ]] && zi creinstall rust; \
export CARGO_HOME=\$PWD RUSTUP_HOME=\$PWD/rustup" for \
z-shell/0
Install rust
- Default
Add the following snippet in the .zshrc
file:
zi light z-shell/z-a-rust
This will register the rustup
and cargo'…'
ice-modifiers.