Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zdharma-continuum/zinit-annex-rust
Unmaintained mirror of zinit-zsh/z-a-rust
https://github.com/zdharma-continuum/zinit-annex-rust
zinit zinit-annex zsh
Last synced: about 1 month ago
JSON representation
Unmaintained mirror of zinit-zsh/z-a-rust
- Host: GitHub
- URL: https://github.com/zdharma-continuum/zinit-annex-rust
- Owner: zdharma-continuum
- License: mit
- Created: 2021-11-01T08:39:44.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-16T05:39:31.000Z (over 1 year ago)
- Last Synced: 2024-04-16T16:22:06.708Z (8 months ago)
- Topics: zinit, zinit-annex, zsh
- Language: Shell
- Homepage:
- Size: 188 KB
- Stars: 2
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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):```zsh
#!/usr/bin/env zshfunction 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.
![example zinit-annex-rust use](https://raw.githubusercontent.com/zdharma-continuum/zinit-annex-rust/master/images/z-a-rust.png)
- [Installation](#installation)
- [Usage](#usage)
- [Options](#options)
- [Examples](#examples)
- [Install rust, the `lsd` crate, and a `lsd` shim exposing the binary](#install-rust-the-lsd-crate-and-a-lsd-shim-exposing-the-binary)
- [Install rust, the `exa` crate, and a `ls` shim exposing the `exa` binary](#install-rust-the-exa-crate-and-a-ls-shim-exposing-the-exa-binary)
- [Install rust and then the `exa` and `lsd` crates](#install-rust-and-then-the-exa-and-lsd-crates)
- [Installs rust and then the `exa' and `lsd' crates and exposes their binaries by altering $PATH](#installs-rust-and-then-the-exa-and-lsd-crates-and-exposes-their-binaries-by-altering-path)
- [Installs rust and then the `exa` crate and creates its shim with standard error redirected to /dev/null](#installs-rust-and-then-the-exa-crate-and-creates-its-shim-with-standard-error-redirected-to-devnull)
- [Install Rust and make it available globally in the system](#install-rust-and-make-it-available-globally-in-the-system)
- [Use Bin-Gem-Node annex to install the cargo completion provided with rustup](#use-bin-gem-node-annex-to-install-the-cargo-completion-provided-with-rustup)Load like a regular plugin, i.e.,:
```zsh
zi light zdharma-continuum/zinit-annex-rust
```This 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.### Install rust, the `lsd` crate, and a `lsd` shim exposing the binary
```zsh
zinit ice rustup cargo'!lsd'
zinit load zdharma-continuum/null
```### Install rust, the `exa` crate, and a `ls` shim exposing the `exa` binary
```zsh
zi ice rustup cargo'!exa -> ls'
zi load zdharma-continuum/null
```### Install rust and then the `exa` and `lsd` crates
```zsh
zinit ice rustup cargo'exa;lsd'
zinit load zdharma-continuum/null
```### Installs rust and then the `exa' and `lsd' crates and exposes their binaries by altering $PATH
```zsh
zinit ice rustup cargo'exa;lsd' as"command" pick"bin/(exa|lsd)"
zinit load zdharma-continuum/null
```### Installs rust and then the `exa` crate and creates its shim with standard error redirected to /dev/null
```zsh
zinit ice rustup cargo'!E:exa'
zinit load zdharma-continuum/null
```### Install Rust and make it available globally in the system
```zsh
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 zdharma-continuum/null
```### Use Bin-Gem-Node annex to install the cargo completion provided with rustup
```zsh
zi 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/null
```When 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```zsh
zi for \
wait='[[ -v CARGO_HOME && -v RUSTUP_HOME ]]' \
id-as'rust-exa' \
cargo'!exa' \
zdharma-continuum/null
```