The Ops Community ⚙️

Emre for Z-Shell

Posted on • Originally published at on

✨〰️ ZI 〰️✨ Gems & Node Modules With ZI

ZI Swiss army knife

❮ ZI ❯ 🧙‍‍♀️ A Swiss Army Knife for Zsh.

Designed to glue everything together. 🔗 | GitHub | Discussions | Localize

With use of the bin-gem-node annex you can install Ruby Gems and Node modules in an interesting way:

✴️ they'll be installed in the plugin's or snippet's directory,
✴️ an automatic function will be provided to run the binary that's provided by the package.

This has several benefits. For example, no $PATH alteration is required in the .zprofile file. Also, the package will be automatically updated on zi update. Plus, the installation will be isolated from other packages – multiple packages not be put in a single place.

An example ZI invocation that installs the remark tool that can be used to convert Markdown documents into man pages:

zi ice wait'2' lucid id-as'remark' node'remark <- !remark-cli; remark-man'
zi snippet /dev/null

Enter fullscreen mode Exit fullscreen mode

It is snippet-based. An example plugin-based invocation:

zi ice wait'2' lucid id-as'remark' node'remark <- !remark-cli; remark-man'
zi load z-shell/null

Enter fullscreen mode Exit fullscreen mode

It has an advantage – it will delete the remark function when unloading the plugin.

The exclamation-mark before !remark-cli is important – it causes the automatic function invoking the binary to be created.

More information can be found on the bin-gem-node annex page.

The command installs 2 node modules – remark-cli and remark-man (the backend for the remark converter – remark can convert also to other formats).

By using the exclamation-mark and the <- pointer it also requests the function that will run the remark binary to be created. The function has the following body:

remark () {
    local bindir="/root/.zi/plugins/remark/node_modules/.bin"
        local -x NODE_PATH="/root/.zi/plugins/remark2"/node_modules
        "$bindir"/"remark" "$@"

Enter fullscreen mode Exit fullscreen mode

As it can be seen it ultimately provides the remark tool to the command line.

Top comments (0)