1
0
Fork 0
mirror of https://github.com/zdharma-continuum/zinit-annex-binary-symlink.git synced 2025-01-29 00:48:19 +01:00
A Zinit annex (i.e. an extension), which provides a non $PATH modifying solution for installing binaries and scripts
Find a file
Vladislav Doster c6385fc130 fix: consistent log prefix
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
2023-12-23 21:13:21 -06:00
.github/workflows feat: add lint gh action workflow 2023-04-14 17:15:17 -05:00
.gitignore .gitignore 2020-02-18 02:47:57 +01:00
:za-lb-atclone-handler fix: consistent log prefix 2023-12-23 21:13:21 -06:00
:za-lb-atdelete-handler fix: consistent log prefix 2023-12-23 21:13:21 -06:00
LICENSE LICENSE, .gitignore 2019-09-15 03:26:32 +02:00
README.md feat: add lint gh action workflow 2023-04-14 17:15:17 -05:00
z-a-binary-symlink.plugin.zsh fix: atclone handler log msgs conditionals 2023-01-08 03:18:10 -06:00

zinit-annex-binary-symlink

A Zsh-Zinit annex (i.e. an extension) that provides functionality, which allows to:

  1. Run programs and scripts without adding anything to $PATH via the automatic creation of links in $ZPFX/bin

Installation

Simply load like a regular plugin, i.e.:

zinit light zdharma-continuum/zinit-annex-binary-symlink

After executing this command you can then use the new ice-mods provided by the annex.

How it works

Exposing a binary program without modifying $PATHzinit-annex-binary-symlink will automatically create a hard or soft link to the binary in $ZPFX/bin exposing the program to the command line as if it were being placed in $PATH.

The command can then be accessed normally – not only in the live Zsh session, but also from any Zsh script.

The Ice Modifiers Provided By The Annex

There is 1 ice-modifier provided and handled by this annex. They are:

  1. lbin'' – creates links for binaries and scripts.

The ice-modifier in detail:

lbin'[!]{path-to-binary}[ -> {name-of-the-script}]'

It creates the link that calls the actual binary. The link is created always under the same, standard and single $PATH entry: $ZPFX/bin (which is ~/.zinit/polaris/bin by default).

The optional preceding ! flag means create a soft link instead of a hard link.

Example:

% zinit ice from"gh-r" lbin"!fzf"
% zinit load junegunn/fzf-bin
…installation messages…
% ls -l $ZPFX/bin/ | awk '{print $(NF-2),$(NF-1),$NF}'
fzf -> /home/sg/.zinit/plugins/junegunn---fzf-bin/fzf
% fzf --version
0.23.1 (fc7630a)

The ice can contain globs. It will expand these when searching for the binary.

Example:

% zinit ice from"gh-r" lbin"**fzf -> myfzf"
% zinit load junegunn/fzf-bin
…installation messages…
% ls $ZPFX/bin/
myfzf
% myfzf --version
0.23.1 (fc7630a)

The ice can be empty. It will then try to create the link for:

  • trailing component of the id_as ice, e.g.: id_as'exts/git-my' → it'll check if a file git-my exists and if yes, create the link git-my,
  • the plugin name, e.g.: for paulirish/git-open it'll check if a file git-open exists and if yes, create the link git-open,
  • trailing component of the snippet URL,
  • for any alphabetically first executable file.

Note

: The above also applies if only ! is passed.