diff --git a/.za-bgn-bin-or-src-function-body b/.za-bgn-bin-or-src-function-body
index 66c3e39..42e2b57 100644
--- a/.za-bgn-bin-or-src-function-body
+++ b/.za-bgn-bin-or-src-function-body
@@ -1,32 +1,33 @@
-# Copyright (c) 2019 Sebastian Gniazdowski
-# License MIT
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
+
# FUNCTION: .za-bgn-bin-or-src-function-body
# Returns the body of the function wrapping a binary
local name="$2" bin="$3" dir="${4#%}"
-integer run_type="$1" set_gem_home="$5" \
- set_node_path="$6" set_virtualenv="$7" set_cwd="$8" \
- use_all_null="$9" use_err_null="$10" use_out_null="$11"
+integer run_type="$1" set_gem_home="$5" set_node_path="$6" set_virtualenv="$7" set_cwd="$8" use_all_null="$9" use_err_null="$10" use_out_null="$11"
local nl=$'\n' tab=$' '
REPLY="function ${(q)name} {
- local bindir=${(qqq)bin:h}
- ${${(M)set_gem_home:#1}:+local -x GEM_HOME=${(qqq)dir}}
- ${${(M)set_node_path:#1}:+local -x NODE_PATH=${(qqq)dir}/node_modules}
- ${${(M)set_virtualenv:#1}:+local -x VIRTUALENV=${(qqq)dir}/venv}
- local -xU PATH=${${(M)set_virtualenv:#1}:+${(qqq)dir}/venv/bin:}${${(M)set_node_path:#1}:+${(qqq)dir}/node_modules/.bin:}${${(M)set_gem_home:#1}:+${(qqq)dir}/bin:}\"\$bindir\":\"\$PATH\"
- ${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
- () { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"}
-"
+ local bindir=${(qqq)bin:h}
+ ${${(M)set_gem_home:#1}:+local -x GEM_HOME=${(qqq)dir}}
+ ${${(M)set_node_path:#1}:+local -x NODE_PATH=${(qqq)dir}/node_modules}
+ ${${(M)set_virtualenv:#1}:+local -x VIRTUALENV=${(qqq)dir}/venv}
+ local -xU PATH=${${(M)set_virtualenv:#1}:+${(qqq)dir}/venv/bin:}${${(M)set_node_path:#1}:+${(qqq)dir}/node_modules/.bin:}${${(M)set_gem_home:#1}:+${(qqq)dir}/bin:}\"\$bindir\":\"\$PATH\"
+ ${${(M)set_cwd:#1}:+"local oldpwd=${(qqq)PWD}
+ () { setopt localoptions noautopushd; builtin cd -q ${(qqq)dir}; }"
+}"
if (( run_type == 0 )); then
- REPLY+="$tab\"\$bindir\"/${(qqq)bin:t} \"\$@\""
+ REPLY+="$tab\"\$bindir\"/${(qqq)bin:t} \"\$@\""
elif (( run_type == 1 )); then
- REPLY+="$tab() { source \"\$bindir\"/${(qqq)bin:t}; } \"\$@\""
+ REPLY+="$tab() { source \"\$bindir\"/${(qqq)bin:t}; } \"\$@\""
elif (( run_type == 2 )); then
- REPLY+="$tab() { eval \"\$(<\"\$bindir\"/${(qqq)bin:t})\"; } \"\$@\""
+ REPLY+="$tab() { eval \"\$(<\"\$bindir\"/${(qqq)bin:t})\"; } \"\$@\""
fi
(( use_all_null )) && REPLY+=" &>/dev/null"
@@ -34,7 +35,4 @@ fi
(( use_out_null )) && REPLY+=" >/dev/null"
REPLY+="$nl"
-REPLY+="${${(M)set_cwd:#1}:+"$nl$tab() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
-}"
-
-# vim:ft=zsh:sw=4:sts=4:et
+REPLY+="${${(M)set_cwd:#1}:+"$nl$tab() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}}"
diff --git a/.za-bgn-bin-or-src-function-body-cygwin b/.za-bgn-bin-or-src-function-body-cygwin
index 09b39be..52a756c 100644
--- a/.za-bgn-bin-or-src-function-body-cygwin
+++ b/.za-bgn-bin-or-src-function-body-cygwin
@@ -1,18 +1,18 @@
-# Copyright (c) 2019 Sebastian Gniazdowski
-# License MIT
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
+
# FUNCTION: .za-bgn-bin-or-src-function-body
# Returns the body of the function wrapping a binary
-
local name="$2" bin="$3" dir="${4#%}"
-integer run_type="$1" set_gem_home="$5" \
- set_node_path="$6" set_virtualenv="$7" set_cwd="$8" \
- use_all_null="$9" use_err_null="$10" use_out_null="$11"
+integer run_type="$1" set_gem_home="$5" set_node_path="$6" set_virtualenv="$7" set_cwd="$8" use_all_null="$9" use_err_null="$10" use_out_null="$11"
local nl=$'\n' tab=$' '
-dir=`cygpath -w "$dir"`
-local binh=`command cygpath -w "${bin:h}"` bint=`command cygpath -w "${bin:t}"`
+dir=$(cygpath -w "$dir")
+local binh=$(command cygpath -w "${bin:h}"` bint=`command cygpath -w "${bin:t}")
REPLY="
@echo off
@@ -38,7 +38,4 @@ fi
(( use_out_null )) && REPLY+=" >NUL"
REPLY+="$nl"
-REPLY+="${${(M)set_cwd:#1}:+"${nl}cd %oldpwd%"
-}"
-
-# vim:ft=zsh:sw=4:sts=4:et
+REPLY+="${${(M)set_cwd:#1}:+"${nl}cd %oldpwd%"}"
diff --git a/.za-bgn-mod-function-body b/.za-bgn-mod-function-body
index 27d6093..880d5bc 100644
--- a/.za-bgn-mod-function-body
+++ b/.za-bgn-mod-function-body
@@ -1,6 +1,9 @@
-# Copyright (c) 2019 Sebastian Gniazdowski
-# License MIT
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
+
# Returns the body of the function wrapping a function
local name="$1" target_func="$2" dir="${3#%}"
@@ -27,5 +30,3 @@ ${(qqq)target_func} \"\$@\""
REPLY+="$nl"
REPLY+="${${(M)set_cwd:#1}:+"() { setopt localoptions noautopushd; builtin cd -q \"\$oldpwd\"; }"}
}"
-
-# vim:ft=zsh:sw=4:sts=4:et
diff --git a/LICENSE b/LICENSE
index 396d783..ded2928 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,7 @@
-This software is licensed under MIT.
-
MIT License
------------
+
+Copyright (c) 2019-2021 Sebastian Gniazdowski and contributors
+Copyright (c) 2021-2022 zdharma-continuum
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -10,13 +10,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index bb507be..8355014 100644
--- a/README.md
+++ b/README.md
@@ -1,62 +1,42 @@
-# zinit-annex-bin-gem-node
-
-
-
-**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
-
-- [zinit-annex-bin-gem-node](#z-a-bin-gem-node)
- - [Introduction](#introduction)
- - [Installation](#installation)
- - [How it works – bird's-eye view](#how-it-works--birds-eye-view)
- - [How it works, in detail](#how-it-works-in-detail)
- - [The Ice Modifiers Provided By The Annex](#the-ice-modifiers-provided-by-the-annex)
- - [1. **`fbin'[{g|n|c|N|E|O}:]{path-to-binary}[ -> {name-of-the-function}]; …'`**](#1-fbingncneopath-to-binary---name-of-the-function-)
- - [2. **`gem'{gem-name}; …'`**](#2-gemgem-name-)
- - [ **`gem'[{path-to-binary} <-] !{gem-name} [-> {name-of-the-function}]; …'`**](#nbspnbspnbsp-gempath-to-binary---gem-name---name-of-the-function-)
- - [3. **`node'{node-module}; …'`**](#3-nodenode-module-)
- - [ **`node'[{path-to-binary} <-] !{node-module} [-> {name-of-the-function}]; …'`**](#nbspnbspnbsp-nodepath-to-binary---node-module---name-of-the-function-)
- - [4. **`pip'{pip-package}; …'`**](#3-pippip-package-)
- - [ **`pip'[{path-to-binary} <-] !{pip-package} [-> {name-of-the-function}]; …'`**](#nbspnbspnbsp-pippath-to-binary---pip-package---name-of-the-function-)
- - [5. **`fmod'[{g|n|c|N|E|O}:]{function-name}; …'`**](#4-fmodgncneofunction-name-)
- - [ **`fmod'[{g|n|c|N|E|O}:]{function-name} -> {wrapping-function-name}; …'`**](#nbspnbspnbsp-fmodgncneofunction-name---wrapping-function-name-)
- - [6. **`sbin'[{g|n|c|N|E|O}:]{path-to-binary}[ -> {name-of-the-script}]; …'`**](#5-sbingncneopath-to-binary---name-of-the-script-)
- - [7. **`fsrc'[{g|n|c|N|E|O}:]{path-to-script}[ -> {name-of-the-function}]; …'`**](#6-fsrcgncneopath-to-script---name-of-the-function-)
- - [8. **`ferc'[{g|n|c|N|E|O}:]{path-to-script}[ -> {name-of-the-function}]; …'`**](#7-fercgncneopath-to-script---name-of-the-function-)
+# zinit-annex-bin-gem-node
+
+
+
+- [Installation](#installation)
+- [Technical details](#technical-details)
+- [Ice Modifiers](#ice-modifiers)
+ - [sbin''](#sbin)
+ - [fbin''](#fbin)
+ - [gem''](#gem)
+ - [node''](#node)
+ - [pip''](#pip)
+ - [fmod''](#fmod)
+ - [fsrc''](#fsrc)
- [Additional Zinit commands](#additional-zinit-commands)
-- [Cygwin support](#cygwin-support)
-
-
-
-## Introduction
-
-A Zsh-Zinit annex (i.e. an extension) that provides functionality, which
-allows to:
-
- 1. Run programs and scripts without adding anything to `$PATH`,
- 2. Install and run Ruby [gems](https://github.com/rubygems/rubygems),
- [Node](https://github.com/npm/cli) and [Python](https://python.org)
- modules from within a local directory with
- [$GEM_HOME](https://guides.rubygems.org/command-reference/#gem-environment)
- ,
- [$NODE_PATH](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders)
- and
- [$VIRTUALENV](https://docs.python.org/3/tutorial/venv.html)
- automatically set,
- 3. Run programs, scripts and functions with automatic `cd` into the plugin
- or snippet directory, plus also with automatic standard output
- & standard error redirecting.
- 4. Source scripts through an automatically created function with the above
- `$GEM_HOME`, `$NODE_PATH`, `$VIRTUALENV` and `cd` features available,
- 5. Create the so called `shims` known from
- [rbenv](https://github.com/rbenv/rbenv) – the same feature as the first
- item of this enumaration – of running a program without adding anything
- to `$PATH` with all of the above features, however through an automatic
- **script** created in `$ZPFX/bin`, not a **function** (the first item
- uses a function-based mechanism),
- 6. Automatic updates of Ruby gems and Node modules during regular plugin and
- snippet updates with `zinit update …`.
-
-## Installation
+- [Cygwin Support](#cygwin-support)
+
+
+
+A Zsh-Zinit annex (i.e. an extension) that provides functionality, which allows to:
+
+1. Run programs and scripts without adding anything to `$PATH`,
+2. Install and run Ruby [gems](https://github.com/rubygems/rubygems),
+ [Node](https://github.com/npm/cli) and [Python](https://python.org) modules from within a local
+ directory with [$GEM_HOME](https://guides.rubygems.org/command-reference/#gem-environment) ,
+ [$NODE_PATH](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders) and
+ [$VIRTUALENV](https://docs.python.org/3/tutorial/venv.html) automatically set,
+3. Run programs, scripts and functions with automatic `cd` into the plugin or snippet directory,
+ plus also with automatic standard output & standard error redirecting.
+4. Source scripts through an automatically created function with the above `$GEM_HOME`,
+ `$NODE_PATH`, `$VIRTUALENV` and `cd` features available,
+5. Create the so called `shims` known from [rbenv](https://github.com/rbenv/rbenv) – the same
+ feature as the first item of this enumaration – of running a program without adding anything to
+ `$PATH` with all of the above features, however through an automatic **script** created in
+ `$ZPFX/bin`, not a **function** (the first item uses a function-based mechanism),
+6. Automatic updates of Ruby gems and Node modules during regular plugin and snippet updates with
+ `zinit update …`.
+
+## Installation
Simply load like a regular plugin, i.e.:
@@ -64,45 +44,39 @@ Simply load like a regular plugin, i.e.:
zinit light zdharma-continuum/zinit-annex-bin-gem-node
```
-After executing this command you can then use the new ice-mods provided by
-the annex.
+After executing this command you can then use the new ice-mods provided by the annex.
-## How it works – bird's-eye view
+## Technical details
-**Note:** the README is somewhat outdated – the `sbin''` ice that creates
-forwarder-scripts instead of forwarder-functions (created by the `fbin''` ice
-and elaborated in this `How it works …` section) turned out to be the proper,
-best method for exposing binary programs and scripts. You can jump to the
-`sbin''` ice [section](#5-sbingncneopath-to-binary---name-of-the-script-) if
-you want or read on, as the forwarder-scripts are pretty similar to the
-forwarder-functions elaborated on in the following text:
+**Note:** the README is somewhat outdated – the `sbin''` ice that creates forwarder-scripts instead
+of forwarder-functions (created by the `fbin''` ice and elaborated in this `How it works …` section)
+turned out to be the proper, best method for exposing binary programs and scripts. You can jump to
+the `sbin''` ice [section](#5-sbingncneopath-to-binary---name-of-the-script-) if you want or read
+on, as the forwarder-scripts are pretty similar to the forwarder-functions elaborated on in the
+following text:
-Below is a diagram explaining the major feature – exposing a binary program
-or script through a Zsh function of the same name:
+Below is a diagram explaining the major feature – exposing a binary program or script through a Zsh
+function of the same name:

-This way there is no need to add anything to `$PATH` – `zinit-annex-bin-gem-node`
-will automatically create a function that will wrap the binary and provide it
-on the command line like if it was being placed in the `$PATH`.
+This way there is no need to add anything to `$PATH` – `zinit-annex-bin-gem-node` will automatically
+create a function that will wrap the binary and provide it on the command line like if it was being
+placed in the `$PATH`.
-Also, like mentioned in the enumeration, the function can automatically
-export `$GEM_HOME`, `$NODE_PATH`, `$VIRTUALENV` shell variables and also automatically cd
-into the plugin or snippet directory right before executing the binary and
-then cd back to the original directory after the execution is finished.
+Also, like mentioned in the enumeration, the function can automatically export `$GEM_HOME`,
+`$NODE_PATH`, `$VIRTUALENV` shell variables and also automatically cd into the plugin or snippet
+directory right before executing the binary and then cd back to the original directory after the
+execution is finished.
-Also, like already mentioned, instead of the function an automatically
-created script – so called `shim` – can be used for the same purpose and with
-the same functionality, so that the command is being accessible practically
-fully normally – not only in the live Zsh session (only within which the
-functions created by `fbin''` exist), but also from any Zsh script.
+Also, like already mentioned, instead of the function an automatically created script – so called
+`shim` – can be used for the same purpose and with the same functionality, so that the command is
+being accessible practically fully normally – not only in the live Zsh session (only within which
+the functions created by `fbin''` exist), but also from any Zsh script.
-## How it works, in detail
-
-Suppose that you would want to install `junegunn/fzf-bin` plugin from GitHub
-Releases, which contains only single file – the `fzf` binary for the selected
-architecture. It is possible to do it in the standard way – by adding the
-plugin's directory to the `$PATH`:
+Suppose that you would want to install `junegunn/fzf-bin` plugin from GitHub Releases, which
+contains only single file – the `fzf` binary for the selected architecture. It is possible to do it
+in the standard way – by adding the plugin's directory to the `$PATH`:
```zsh
zinit ice as"command" from"github-rel"
@@ -113,75 +87,64 @@ After this command, the `$PATH` variable will contain e.g.:
```zsh
% print $PATH
-/home/sg/.zinit/plugins/junegunn---fzf-bin:/bin:/usr/bin:/usr/sbin:/sbin
+/home/zi/.zinit/plugins/junegunn---fzf-bin:/bin:/usr/bin:/usr/sbin:/sbin
```
-For many such programs loaded as plugins the PATH can become quite cluttered.
-I've had 26 entries before switching to `zinit-annex-bin-gem-node`. To solve this,
-load with use of `sbin''` ice provided and handled by `zinit-annex-bin-gem-node`:
+For many such programs loaded as plugins the PATH can become quite cluttered. I've had 26 entries
+before switching to `zinit-annex-bin-gem-node`. To solve this, load with use of `sbin''` ice
+provided and handled by `zinit-annex-bin-gem-node`:
```zsh
zinit ice from"gh-r" sbin"fzf"
zinit load junegunn/fzf-bin
```
-The `$PATH` will remain unchanged and a `fzf` forwarder-script, so called
-*shim* will be created in `$ZPFX/bin` (`~/.zinit/polaris/bin` by default),
-which is being already added to the `$PATH` by Zinit when it is being
-sourced:
+The `$PATH` will remain unchanged and a `fzf` forwarder-script, so called *shim* will be created in
+`$ZPFX/bin` (`~/.zinit/polaris/bin` by default), which is being already added to the `$PATH` by
+Zinit when it is being sourced:
```zsh
% cat $ZPFX/bin/fzf
#!/usr/bin/env zsh
function fzf {
- local bindir="/home/sg/.zinit/plugins/junegunn---fzf-bin"
- "$bindir"/"fzf" "$@"
+ local bindir="/home/zi/.zinit/plugins/junegunn---fzf-bin"
+ "$bindir"/"fzf" "$@"
}
fzf "$@"
```
-Running the script will forward the call to the program accessed through
-an embedded path to it. Thus, no `$PATH` changes are needed!
+Running the script will forward the call to the program accessed through an embedded path to it.
+Thus, no `$PATH` changes are needed!
-## The Ice Modifiers Provided By The Annex
+## Ice Modifiers
There are 7 ice-modifiers provided and handled by the annex. They are:
- 1. `sbin''` – creates `shims` for binaries and scripts.
- 2. `fbin''` – creates functions for binaries and scripts.
- 3. `gem''` – installs and updates gems + creates functions for gems'
- binaries.
- 4. `node''` – installs and updates node_modules + creates functions for
- binaries of the modules.
- 5. `pip''` – installs and updates python packages into a virtualenv + creates
- functions for binaries of the packages.
- 6. `fmod''` – creates wrapping functions for other functions.
- 7. `fsrc''` – creates functions that source given scripts.
- 8. `ferc''` – the same as `fsrc''`, but using an alternate script-loading
- method.
-
-**The ice-modifiers in detail:**
-
----
-
-## 1. **`sbin'[{g|n|c|N|E|O}:]{path-to-binary}[ -> {name-of-the-script}]; …'`**
-
-It creates the so called `shim` known from `rbenv` – a wrapper script that
-forwards the call to the actual binary. The script is created always under
-the same, standard and single `$PATH` entry: `$ZPFX/bin` (which is
-`~/.zinit/polaris/bin` by default).
+
+| ice | description |
+| -------- | -------------------------------------------------------------------------------------------------- |
+| `fbin''` | creates functions for binaries and scripts. |
+| `ferc''` | the same as `fsrc''`, but using an alternate script-loading method. |
+| `fmod''` | creates wrapping functions for other functions. |
+| `fsrc''` | creates functions that source given scripts. |
+| `gem''` | installs and updates gems + creates functions for gems' binaries. |
+| `node''` | installs and updates node_modules + creates functions for binaries of the modules. |
+| `pip''` | installs and updates python packages into a virtualenv + creates functions for the package binary. |
+| `sbin''` | creates `shims` for binaries and scripts. |
+
+### sbin''
+
+It creates the so called `shim` known from `rbenv` – a wrapper script that forwards the call to the
+actual binary. The script is created always under the same, standard and single `$PATH` entry:
+`$ZPFX/bin` (which is `~/.zinit/polaris/bin` by default).
The flags have the same meaning as with `fbin''` ice.
Example:
```zsh
-% zinit delete junegunn/fzf-bin
-Delete /home/sg/.zinit/plugins/junegunn---fzf-bin?
-[yY/n…]
-y
-Done (action executed, exit code: 0)
+% zinit delete junegunn/fzf-bin --yes
% zinit ice from"gh-r" sbin"fzf"
% zinit load junegunn/fzf-bin
…installation messages…
@@ -189,8 +152,8 @@ Done (action executed, exit code: 0)
#!/usr/bin/env zsh
function fzf {
- local bindir="/home/sg/.zinit/plugins/junegunn---fzf-bin"
- "$bindir"/"fzf" "$@"
+ local bindir="/home/zi/.zinit/plugins/junegunn---fzf-bin"
+ "$bindir"/"fzf" "$@"
}
fzf "$@"
@@ -198,31 +161,27 @@ fzf "$@"
**The ice can be empty**. It will then try to create the shim 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 shim `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 shim `git-open`,
+- 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 shim `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 shim `git-open`,
- trailing component of the snippet URL,
- for any alphabetically first executable file.
----
-
-## 2. **`fbin'[{g|n|c|N|E|O}:]{path-to-binary}[ -> {name-of-the-function}]; …'`**
-
-Creates a wrapper function of the name the same as the last segment of the
-path or as `{name-of-the-function}`. The optional preceding flags mean:
-
- - `g` – set `$GEM_HOME` variable to `{plugin-dir}`,
- - `n` – set `$NODE_PATH` variable to `{plugin-dir}/node_modules`,
- - `p` – set `$VIRTUALENV` variable to `{plugin-dir}/venv`,
- - `c` – cd to the plugin's directory before running the program and then cd
- back after it has been run,
- - `N` – append `&>/dev/null` to the call of the binary, i.e. redirect both
- standard output and standard error to `/dev/null`,
- - `E` – append `2>/dev/null` to the call of the binary, i.e. redirect
- standard error to `/dev/null`,
- - `O` – append `>/dev/null` to the call of the binary, i.e. redirect
- standard output to `/dev/null`.
+### fbin''
+
+Creates a wrapper function of the name the same as the last segment of the path or as
+`{name-of-the-function}`. The optional preceding flags mean:
+
+- `g` – set `$GEM_HOME` variable to `{plugin-dir}`,
+- `n` – set `$NODE_PATH` variable to `{plugin-dir}/node_modules`,
+- `p` – set `$VIRTUALENV` variable to `{plugin-dir}/venv`,
+- `c` – cd to the plugin's directory before running the program and then cd back after it has been
+ run,
+- `N` – append `&>/dev/null` to the call of the binary, i.e. redirect both standard output and
+ standard error to `/dev/null`,
+- `E` – append `2>/dev/null` to the call of the binary, i.e. redirect standard error to `/dev/null`,
+- `O` – append `>/dev/null` to the call of the binary, i.e. redirect standard output to `/dev/null`.
Example:
@@ -231,230 +190,188 @@ Example:
% zinit load junegunn/fzf-bin
% which myfzf
myfzf () {
- local bindir="/home/sg/.zinit/plugins/junegunn---fzf-bin"
- local -x GEM_HOME="/home/sg/.zinit/plugins/junegunn---fzf-bin"
- "$bindir"/"fzf" "$@"
+ local bindir="/home/zi/.zinit/plugins/junegunn---fzf-bin"
+ local -x GEM_HOME="/home/zi/.zinit/plugins/junegunn---fzf-bin"
+ "$bindir"/"fzf" "$@"
}
```
**The ice can be empty**. It will then try to create the function 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 function `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 function `git-open`,
+- 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 function `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 function `git-open`,
- trailing component of the snippet URL,
- for any alphabetically first executable file.
----
-
-## 2. **`gem'{gem-name}; …'`**
-## **`gem'[{path-to-binary} <-] !{gem-name} [-> {name-of-the-function}]; …'`**
+### gem''
-Installs the gem of name `{gem-name}` with `$GEM_HOME` set to the plugin's or
-snippet's directory. In other words, the gem and its dependencies will be
-installed locally in that directory.
+Installs the gem of name `{gem-name}` with `$GEM_HOME` set to the plugin's or snippet's directory.
+In other words, the gem and its dependencies will be installed locally in that directory.
-In the second form it also creates a wrapper function identical to the one
-created with `fbin''` ice.
+In the second form it also creates a wrapper function identical to the one created with `fbin''`
+ice.
Example:
```zsh
% zinit ice gem'!asciidoctor'
-% zinit load zdharma/null
+% zinit load zdharma-continuum/null
% which asciidoctor
asciidoctor () {
- local bindir="/home/sg/.zinit/plugins/zdharma---null/bin"
- local -x GEM_HOME="/home/sg/.zinit/plugins/zdharma---null"
- "$bindir"/"asciidoctor" "$@"
+ local bindir="/home/zi/.zinit/plugins/zdharma-continuum---null/bin"
+ local -x GEM_HOME="/home/zi/.zinit/plugins/zdharma-continuum---null"
+ "$bindir"/"asciidoctor" "$@"
}
```
----
-
-## 3. **`node'{node-module}; …'`**
-## **`node'[{path-to-binary} <-] !{node-module} [-> {name-of-the-function}]; …'`**
+### node''
-Installs the node module of name `{node-module}` inside the plugin's or
-snippet's directory.
+Installs the node module of name `{node-module}` inside the plugin's or snippet's directory.
-In the second form it also creates a wrapper function identical to the one
-created with `fbin''` ice.
+In the second form it also creates a wrapper function identical to the one created with `fbin''`
+ice.
Example:
```zsh
-% zinit delete zdharma/null
-Delete /home/sg/.zinit/plugins/zdharma---null?
-[yY/n…]
-y
-Done (action executed, exit code: 0)
+% zinit delete zdharma-continuum --yes
% zinit ice node'remark <- !remark-cli -> remark; remark-man'
-% zinit load zdharma/null
+% zinit load zdharma-continuum/null
…installation messages…
% which remark
remark () {
- local bindir="/home/sg/.zinit/plugins/zdharma---null/node_modules/.bin"
- local -x NODE_PATH="/home/sg/.zinit/plugins/zdharma---null"/node_modules
- "$bindir"/"remark" "$@"
+ local bindir="/home/zi/.zinit/plugins/zdharma-continuum---null/node_modules/.bin"
+ local -x NODE_PATH="/home/zi/.zinit/plugins/zdharma-continuum---null"/node_modules
+ "$bindir"/"remark" "$@"
}
```
-In this case the name of the binary program provided by the node module is
-different from its name, hence the second form with the `b <- a -> c` syntax
-has been used.
+In this case the name of the binary program provided by the node module is different from its name,
+hence the second form with the `b <- a -> c` syntax has been used.
----
+### pip''
-## 4. **`pip'{pip-package}; …'`**
-## **`node'[{path-to-binary} <-] !{pip-package} [-> {name-of-the-function}]; …'`**
+Installs the node module of name `{pip-package}` inside the plugin's or snippet's directory.
-Installs the node module of name `{pip-package}` inside the plugin's or
-snippet's directory.
-
-In the second form it also creates a wrapper function identical to the one
-created with `fbin''` ice.
+In the second form it also creates a wrapper function identical to the one created with `fbin''`
+ice.
Example:
```zsh
-% zinit delete zdharma/null
-Delete /home/sg/.zinit/plugins/zdharma---null?
-[yY/n…]
-y
-Done (action executed, exit code: 0)
+% zinit delete zdharma-continuum/null --yes
% zinit ice node'ansible <- !ansible -> ansible; ansible-lint'
-% zinit load zdharma/null
+% zinit load zdharma-continuum/null
…installation messages…
% which remark
ansible () {
- local bindir="/home/sg/.zinit/plugins/zdharma---null/venv/bin"
- local -x VIRTUALENV="/home/sg/.zinit/plugins/zdharma---null"/venv
- "$bindir"/"ansible" "$@"
+ local bindir="/home/zi/.zinit/plugins/zdharma-continuum---null/venv/bin"
+ local -x VIRTUALENV="/home/zi/.zinit/plugins/zdharma-continuum---null"/venv
+ "$bindir"/"ansible" "$@"
}
```
-In this case the name of the binary program provided by the node module is
-different from its name, hence the second form with the `b <- a -> c` syntax
-has been used.
-
----
+In this case the name of the binary program provided by the node module is different from its name,
+hence the second form with the `b <- a -> c` syntax has been used.
-## 5. **`fmod'[{g|n|c|N|E|O}:]{function-name}; …'`**
-## **`fmod'[{g|n|c|N|E|O}:]{function-name} -> {wrapping-function-name}; …'`**
+### fmod''
-It wraps given function with the ability to set `$GEM_HOME`, etc. – the
-meaning of the `g`,`n` and `c` flags is the same as in the `fbin''` ice.
+It wraps given function with the ability to set `$GEM_HOME`, etc. – the meaning of the `g`,`n` and
+`c` flags is the same as in the `fbin''` ice.
Example:
```zsh
-% myfun() { pwd; ls -1 }
-% zinit ice fmod'cgn:myfun'
-% zinit load zdharma/null
-% which myfun
+$ myfun() { pwd; ls -1; }
+$ zinit ice fmod'cgn:myfun'
+$ zinit load zdharma-continuum/null
+```
+
+```zsh
+$ which myfun
myfun () {
- local -x GEM_HOME="/home/sg/.zinit/plugins/zdharma---null"
- local -x NODE_PATH="/home/sg/.zinit/plugins/zdharma---null"/node_modules
- local oldpwd="/home/sg/.zinit/plugins/zinit---zinit-annex-bin-gem-node"
- () {
- setopt localoptions noautopushd
- builtin cd -q "/home/sg/.zinit/plugins/zdharma---null"
- }
- "myfun--za-bgn-orig" "$@"
- () {
- setopt localoptions noautopushd
- builtin cd -q "$oldpwd"
- }
+ local -x GEM_HOME="/home/zi/.zinit/plugins/zdharma-continuum---null"
+ local -x NODE_PATH="/home/zi/.zinit/plugins/zdharma-continuum---null"/node_modules
+ local oldpwd="/home/zi/.zinit/plugins/zinit---zinit-annex-bin-gem-node"
+ () {
+ setopt localoptions noautopushd
+ builtin cd -q "/home/zi/.zinit/plugins/zdharma-continuum---null"
+ }
+ "myfun--za-bgn-orig" "$@"
+ () {
+ setopt localoptions noautopushd
+ builtin cd -q "$oldpwd"
+ }
}
-% myfun
-/home/sg/.zinit/plugins/zdharma---null
+$ myfun
+/home/zi/.zinit/plugins/zdharma-continuum---null
LICENSE
README.md
```
----
+### fsrc''
-## 7. **`fsrc'[{g|n|c|N|E|O}:]{path-to-script}[ -> {name-of-the-function}]; …'`**
-## 8. **`ferc'[{g|n|c|N|E|O}:]{path-to-script}[ -> {name-of-the-function}]; …'`**
-
-Creates a wrapper function that at each invocation sources the given file.
-The second ice, `ferc''` works the same with the single difference that it
-uses `eval "$(<{path-to-script})"` instead of `source "{path-to-script}"` to
-load the script.
+Creates a wrapper function that at each invocation sources the given file. The second ice, `ferc''`
+works the same with the single difference that it uses `eval "$(<{path-to-script})"` instead of
+`source ` to load the script.
Example:
```zsh
-% zinit ice fsrc"myscript -> myfunc" ferc"myscript"
-% zinit load zdharma/null
-% which myfunc
+$ zinit ice fsrc"myscript -> myfunc" ferc"myscript"
+$ zinit load zdharma-continuum/null
+
+$ which myfunc
myfunc () {
- local bindir="/home/sg/.zinit/plugins/zdharma---null"
- () {
- source "$bindir"/"myscript"
- } "$@"
+ local bindir="/home/zi/.zinit/plugins/zdharma-continuum---null"
+ () { source "$bindir"/"myscript"; } "$@"
}
-% which myscript
+
+$ which myscript
myscript () {
- local bindir="/home/sg/.zinit/snippets/OMZ::plugins--git/git.plugin.zsh"
- () {
- eval "$(<"$bindir"/"myscript")"
- } "$@"
+ local bindir="/home/zi/.zinit/snippets/OMZ::plugins--git/git.plugin.zsh"
+ () { eval "$(<"$bindir"/"myscript")"; } "$@"
}
```
-**The ices can be empty**. They will then try to create the function for
-trailing component of the `id-as` ice and the other cases, in the same way as
-with the `fbin` ice.
+**The ices can be empty**. They will then try to create the function for trailing component of the
+`id-as` ice and the other cases, in the same way as with the `fbin` ice.
-# Additional Zinit commands
+## Additional Zinit commands
-There's an additional Zinit command that's provided by this annex
-–`shim-list`. It searches for and displays any shims that are being
-currently stored under `$ZPFX/bin`. Example invocation:
+There's an additional Zinit command that's provided by this annex –`shim-list`. It searches for and
+displays any shims that are being currently stored under `$ZPFX/bin`. Example invocation:
-
+
Available options are:
```zsh
-zinit shim-list [-h/--help] [-t|--this-dir] [-i|--from-ices] \
- [-o|--one-line] [-s|--short] [-c|--cat]
+zinit shim-list [-h/--help] [-t|--this-dir] [-i|--from-ices] [-o|--one-line] [-s|--short] [-c|--cat]
```
The options' meanings:
-- `-h/--help` – shows a usage information,
-- `-t/--this-dir` – instructs Zinit to look for shims in the current
- directory instead of `$ZPFX/bin`,
-- `-i/--from-ices` – normally the code looks for the shim files by examining
- their contents (shims created by BGN annex have a fixed structure); this
- option instructs Zinit to show the list of shims that results from the
- `sbin''` ice of the loaded plugins; i.e.: if a plugin has `sbin'git-open'`,
- for example, then this means that there has to be such shim already
- created,
-- `-o/--one-line` – display the list of shim files without line breaks, in
- single line, after spaces,
-- `-s/--short` – don't show the plugin/snippet that the shim belongs to,
-- `-c/--cat` – displays contents of each of the found shim
- (unimplemented yet).
-
-# Cygwin Support
-
-The `sbin''` ice has an explicit Cygwin support – it creates additional,
-**extra shim files** – Windows batch scripts that allow to run the shielded
-applications from e.g.: Windows run dialog – if the `~/.zinit/polaris/bin`
-directory is being added to the Windows `PATH` environment variable, for
-example (it is a good idea to do so, IMHO). The Windows shims have the same
-name as the standard ones (which are also being created, normally) plus the
-`.cmd` extension. You can test the feature by e.g.: installing Firefox from
-the Zinit package via:
-
-```zsh
-zinit pack=bgn for firefox
-```
-
-
+| option | description |
+| ---------------- | ---------------------------------------------------------------------------- |
+| `-c/--cat` | Displays contents of each of the found shim (unimplemented yet) |
+| `-h/--help` | Shows a usage information |
+| `-i/--from-ices` | Display a list of shims using the `sbin''` ice of the loaded plugins |
+| `-o/--one-line` | Display list of shim files without line breaks, in single line, after spaces |
+| `-s/--short` | Omit the plugin/snippet for a shim |
+| `-t/--this-dir` | Display shims in the current directory instead of `$ZPFX/bin` |
+
+## Cygwin Support
+
+The `sbin''` ice has an explicit Cygwin support – it creates additional, **extra shim files** –
+Windows batch scripts that allow to run the shielded applications from e.g.: Windows run dialog – if
+the `~/.zinit/polaris/bin` directory is being added to the Windows `PATH` environment variable, for
+example (it is a good idea to do so, IMHO). The Windows shims have the same name as the standard
+ones (which are also being created, normally) plus the `.cmd` extension. You can test the feature by
+e.g.: installing Firefox from the Zinit package via:
+
+````zsh
+zinit pack'bgn' for firefox ```
+````
diff --git a/z-a-bin-gem-node.plugin.zsh b/z-a-bin-gem-node.plugin.zsh
index db8909c..e17eccc 100644
--- a/z-a-bin-gem-node.plugin.zsh
+++ b/z-a-bin-gem-node.plugin.zsh
@@ -1,5 +1,8 @@
-# Copyright (c) 2019-2020 Sebastian Gniazdowski
-# License MIT
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
+#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
# According to the Zsh Plugin Standard:
# https://zdharma-continuum.github.io/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
@@ -8,39 +11,38 @@
0="${${(M)0:#/*}:-$PWD/$0}"
autoload .za-bgn-bin-or-src-function-body \
- .za-bgn-bin-or-src-function-body-cygwin \
- .za-bgn-mod-function-body \
- za-bgn-atload-handler za-bgn-atclone-handler \
- za-bgn-atpull-handler za-bgn-help-handler \
- za-bgn-atdelete-handler \
- za-bgn-shim-list
+ .za-bgn-bin-or-src-function-body-cygwin \
+ .za-bgn-mod-function-body \
+ za-bgn-atload-handler za-bgn-atclone-handler \
+ za-bgn-atpull-handler za-bgn-help-handler \
+ za-bgn-atdelete-handler \
+ za-bgn-shim-list
# An empty stub to fill the help handler fields
za-bgn-null-handler() { :; }
@zinit-register-annex "zinit-annex-bin-gem-node" \
- subcommand:shim-list \
- za-bgn-shim-list \
- za-bgn-null-handler
+ subcommand:shim-list \
+ za-bgn-shim-list \
+ za-bgn-null-handler
@zinit-register-annex "zinit-annex-bin-gem-node" \
- hook:\!atload-50 \
- za-bgn-atload-handler \
- za-bgn-help-handler \
- "fbin''|sbin|sbin''|gem''|node''|pip''|fmod''|fsrc''|ferc''" # also register new ices
+ hook:\!atload-50 \
+ za-bgn-atload-handler \
+ za-bgn-help-handler \
+ "fbin''|sbin|sbin''|gem''|node''|pip''|fmod''|fsrc''|ferc''" # also register new ices
@zinit-register-annex "zinit-annex-bin-gem-node" \
- hook:atclone-50 \
- za-bgn-atclone-handler \
- za-bgn-null-handler
+ hook:atclone-50 \
+ za-bgn-atclone-handler \
+ za-bgn-null-handler
@zinit-register-annex "zinit-annex-bin-gem-node" \
- hook:\%atpull-50 \
- za-bgn-atclone-handler \
- za-bgn-null-handler
+ hook:\%atpull-50 \
+ za-bgn-atclone-handler \
+ za-bgn-null-handler
@zinit-register-annex "zinit-annex-bin-gem-node" \
- hook:atdelete-50 \
- za-bgn-atdelete-handler \
- za-bgn-null-handler
-
+ hook:atdelete-50 \
+ za-bgn-atdelete-handler \
+ za-bgn-null-handler
diff --git a/za-bgn-atclone-handler b/za-bgn-atclone-handler
index 70bb20c..b42b9bc 100644
--- a/za-bgn-atclone-handler
+++ b/za-bgn-atclone-handler
@@ -1,57 +1,60 @@
-# Copyright (c) 2019-2020 Sebastian Gniazdowski
-# License MIT
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
+#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
za-bgn-atclone-handler() {
-emulate -RL zsh
-setopt extendedglob warncreateglobal typesetsilent noshortloops
+ emulate -RL zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops
-if [[ "$1" = plugin ]] {
+ if [[ "$1" = plugin ]] {
local type="$1" user="$2" plugin="$3" id_as="$4" dir="${5#%}" hook="$6"
-} else {
+ } else {
local type="$1" url="$2" id_as="$3" dir="${4#%}" hook="$5"
-}
+ }
-local nl=$'\n'
+ local nl=$'\n'
-if [[ -n "${ICE[gem]}" ]] {
+ if [[ -n "${ICE[gem]}" ]] {
local -a gem_defs srcdst tmpsdst gems
gem_defs=( "${(s.;.)ICE[gem]}" )
local gem
for gem ( $gem_defs ) {
- srcdst=( ${(@s.->.)gem} )
- tmpsdst=( ${(@s.<-.)srcdst[1]} )
- if (( ${#tmpsdst} > 1 )); then
- srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
- else
- srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
- fi
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- srcdst[2]=${srcdst[2]#\!}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
-
- gems+=( ${srcdst[2]} )
+ srcdst=( ${(@s.->.)gem} )
+ tmpsdst=( ${(@s.<-.)srcdst[1]} )
+ if (( ${#tmpsdst} > 1 )); then
+ srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
+ else
+ srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
+ fi
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ srcdst[2]=${srcdst[2]#\!}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
+
+ gems+=( ${srcdst[2]} )
}
(( ${#gems} )) && {
- if [[ $hook = *atclone-<-> ]]; then
- command gem install -q --no-user-install -i "$dir" "${gems[@]}"
- elif [[ $hook = *atpull-<-> ]]; then
- if (( !OPTS[opt_-q,--quiet] )) {
- print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the gems...%f"
- command gem update -q --no-user-install -i "$dir" "${gems[@]}"
- } else {
- command gem update -q --no-user-install -i "$dir" "${gems[@]}" &> /dev/null
- }
- fi
+ if [[ $hook = *atclone-<-> ]]; then
+ command gem install -q --no-user-install -i "$dir" "${gems[@]}"
+ elif [[ $hook = *atpull-<-> ]]; then
+ if (( !OPTS[opt_-q,--quiet] )) {
+ print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the gems...%f"
+ command gem update -q --no-user-install -i "$dir" "${gems[@]}"
+ } else {
+ command gem update -q --no-user-install -i "$dir" "${gems[@]}" &> /dev/null
+ }
+ fi
}
-}
+ }
-if [[ -n "${ICE[pip]}" ]] {
+ if [[ -n "${ICE[pip]}" ]] {
local -a pip_defs srcdst tmpsdst imods umods
pip_defs=( "${(s.;.)ICE[pip]}" )
@@ -59,45 +62,44 @@ if [[ -n "${ICE[pip]}" ]] {
integer perform_update=0
for pip ( $pip_defs ) {
- srcdst=( ${(@s.->.)pip} )
- tmpsdst=( ${(@s.<-.)srcdst[1]} )
- if (( ${#tmpsdst} > 1 )); then
- srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
- else
- srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
- fi
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- srcdst[2]=${srcdst[2]#\!}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
-
- if [[ "$hook" = *atclone-<-> ]]; then
- imods+=( ${srcdst[2]} )
- elif [[ "$hook" = *atpull-<-> && -n ${srcdst[2]} ]]; then
- umods+=( ${srcdst[2]} )
- perform_update=1
- break
- fi
+ srcdst=( ${(@s.->.)pip} )
+ tmpsdst=( ${(@s.<-.)srcdst[1]} )
+ if (( ${#tmpsdst} > 1 )); then
+ srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
+ else
+ srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
+ fi
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ srcdst[2]=${srcdst[2]#\!}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
+
+ if [[ "$hook" = *atclone-<-> ]]; then
+ imods+=( ${srcdst[2]} )
+ elif [[ "$hook" = *atpull-<-> && -n ${srcdst[2]} ]]; then
+ umods+=( ${srcdst[2]} )
+ perform_update=1
+ break
+ fi
}
- (( ${#imods} )) && \
- ( builtin cd -q "$dir" && command python3 -m venv venv && VIRTUALENV=venv(:A) command venv/bin/pip install "${imods[@]}" )
+ (( ${#imods} )) && ( builtin cd -q "$dir" && command python3 -m venv venv && VIRTUALENV=venv(:A) command venv/bin/pip install "${imods[@]}" )
(( perform_update )) && (( ${#umods} )) && \
- (
- builtin cd -q "$dir" && {
- if (( !OPTS[opt_-q,--quiet] )) {
- print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the pip packages...%f"
- VIRTUALENV=venv(:A) command venv/bin/pip install --upgrade "${umods[@]}"
- } else {
- VIRTUALENV=venv(:A) command venv/bin/pip install -q --upgrade "${umods[@]}"
- }
- }
- )
-}
+ (
+ builtin cd -q "$dir" && {
+ if (( !OPTS[opt_-q,--quiet] )) {
+ print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the pip packages...%f"
+ VIRTUALENV=venv(:A) command venv/bin/pip install --upgrade "${umods[@]}"
+ } else {
+ VIRTUALENV=venv(:A) command venv/bin/pip install -q --upgrade "${umods[@]}"
+ }
+ }
+ )
+ }
-if [[ -n "${ICE[node]}" ]] {
+ if [[ -n "${ICE[node]}" ]] {
local -a node_defs srcdst tmpsdst mods
node_defs=( "${(s.;.)ICE[node]}" )
@@ -105,177 +107,164 @@ if [[ -n "${ICE[node]}" ]] {
integer perform_update=0
for node ( $node_defs ) {
- srcdst=( ${(@s.->.)node} )
- tmpsdst=( ${(@s.<-.)srcdst[1]} )
- if (( ${#tmpsdst} > 1 )); then
- srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
- else
- srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
- fi
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- srcdst[2]=${srcdst[2]#\!}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
-
- if [[ "$hook" = *atclone-<-> ]]; then
- mods+=( ${srcdst[2]} )
- elif [[ "$hook" = *atpull-<-> && -n ${srcdst[2]} ]]; then
- perform_update=1
- break
- fi
+ srcdst=( ${(@s.->.)node} )
+ tmpsdst=( ${(@s.<-.)srcdst[1]} )
+ if (( ${#tmpsdst} > 1 )); then
+ srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
+ else
+ srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
+ fi
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ srcdst[2]=${srcdst[2]#\!}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
+
+ if [[ "$hook" = *atclone-<-> ]]; then
+ mods+=( ${srcdst[2]} )
+ elif [[ "$hook" = *atpull-<-> && -n ${srcdst[2]} ]]; then
+ perform_update=1
+ break
+ fi
}
(( ${#mods} )) && \
- ( builtin cd -q "$dir" && command npm --silent install "${mods[@]}" )
+ ( builtin cd -q "$dir" && command npm --silent install "${mods[@]}" )
(( perform_update )) && \
- (
- builtin cd -q "$dir" && {
- if (( !OPTS[opt_-q,--quiet] )) {
- print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the node modules...%f"
- command npm --silent update
- } else {
- command npm --silent update &> /dev/null
- }
- }
- )
-}
+ (
+ builtin cd -q "$dir" && {
+ if (( !OPTS[opt_-q,--quiet] )) {
+ print -P -- "%F{38}bin-gem-node annex: %F{154}Updating the node modules...%f"
+ command npm --silent update
+ } else {
+ command npm --silent update &> /dev/null
+ }
+ }
+ )
+ }
-#
-# sbin'' ice – creation of shims (the name borrowed from rbenv)
-#
+ #
+ # sbin'' ice – creation of shims (the name borrowed from rbenv)
+ #
-if (( ${+ICE[sbin]} )) {
+ if (( ${+ICE[sbin]} )) {
local -a sbins srcdst
sbins=( ${(s.;.)ICE[sbin]} )
-
local sbin
-
(
- # CD for the globbing through eval
- builtin cd -q "$dir" || return
-
- for sbin ( $sbins "" ) {
- integer set_gem_home=0 set_node_path=0 set_virtualenv=0 set_cwd=0 \
- use_all_null=0 use_err_null=0 use_out_null=0
-
- if [[ -z $sbin && ${#sbins} -eq 0 ]] {
- if [[ -f $dir/${id_as:t} ]]; then
- sbin="$dir/${id_as:t}"
- elif [[ -n $plugin && -f $dir/$plugin ]]; then
- sbin="$dir/$plugin"
- elif [[ -n $url && -f $dir/${url:t} ]]; then
- sbin="$dir/${url:t}"
- else
- local -a files
- files=( $dir/*(*Nnon:t) )
- if (( ${#files} )); then
- sbin="${files[1]}"
- else
- print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
- break
- fi
- fi
- } elif [[ -z $sbin ]] {
- continue
- }
-
- srcdst=( ${(@s.->.)sbin} )
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1
- [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1
- [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1
- [[ ${srcdst[1]} = [gnpcNEO]#c[gnpcNEO]#:* ]] && set_cwd=1
- [[ ${srcdst[1]} = [gnpcNEO]#N[gnpcNEO]#:* ]] && use_all_null=1
- [[ ${srcdst[1]} = [gnpcNEO]#E[gnpcNEO]#:* ]] && use_err_null=1
- [[ ${srcdst[1]} = [gnpcNEO]#O[gnpcNEO]#:* ]] && use_out_null=1
- srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]'
-
- local -a fnames
- local fname
- eval "fnames=( ${srcdst[1]}(Nnon-.) )"
-
- if (( !${#fnames} )) {
- print -P -- "%F{38}bin-gem-node annex: %F{160}Warning: %F{154}The sbin'' ice (\`%F{219}$sbin%F{154}') didn't match any files%f"
- continue
- }
-
- for fname ( $fnames ) {
- srcdst[1]="$fname"
-
- local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}" \
- fnam="${srcdst[2]:-${srcdst[1]:t}}"
- local file="$ZPFX/bin/$fnam"
-
- if [[ $OSTYPE == cygwin ]]; then
- .za-bgn-bin-or-src-function-body-cygwin 0 \
- "$fnam" \
- "$target_binary" "$dir" "$set_gem_home" \
- "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
- "$use_err_null" "$use_out_null"
- builtin print -r -- "$REPLY" \
- >! "$file.cmd"
- command chmod +x "$file.cmd"
- fi
-
- .za-bgn-bin-or-src-function-body 0 \
- "$fnam" \
- "$target_binary" "$dir" "$set_gem_home" \
- "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
- "$use_err_null" "$use_out_null"
-
- builtin print -r -- "#!/usr/bin/env zsh$nl$nl$REPLY$nl$nl$fnam \"\$@\"" \
- >! "$file"
- command chmod +x "$file" "$target_binary"
-
- if [[ -x $file ]]; then
- (( !OPTS[opt_-q,--quiet] )) && \
- if [[ -x $target_binary ]]; then
- if [[ $hook == atclone-<-> || $ZINIT[annex-multi-flag:pull-active] -ge 2 ]] {
- print -P -- "%F{38}bin-gem-node annex: %F{154}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the %F{219}$fnam%F{154} shim and set +x on the %F{219}${target_binary:t}%F{154} binary%f"
- }
- else
- print -P -- "%F{38}bin-gem-node annex: %F{154}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the %F{219}$fnam%F{154} shim %F{160}however the %F{219}${target_binary:t}%F{160} binary does not exist or failed to set +x on it%f"
- fi
- else
- print -P -- "%F{38}bin-gem-node annex: %F{160}Something went wrong creating the %F{219}$fnam%F{160} shim%f"
- fi
- }
+ # CD for the globbing through eval
+ builtin cd -q "$dir" || return
+
+ for sbin ( $sbins "" ) {
+ integer set_cwd=0 set_gem_home=0 set_node_path=0 set_virtualenv=0 use_all_null=0 use_err_null=0 use_out_null=0
+ if [[ -z $sbin && ${#sbins} -eq 0 ]]; then
+ if [[ -f $dir/${id_as:t} ]]; then
+ sbin="$dir/${id_as:t}"
+ elif [[ -n $plugin && -f $dir/$plugin ]]; then
+ sbin="$dir/$plugin"
+ elif [[ -n $url && -f $dir/${url:t} ]]; then
+ sbin="$dir/${url:t}"
+ else
+ local -a files
+ files=( $dir/*(*Nnon:t) )
+ if (( ${#files} )); then
+ sbin="${files[1]}"
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
+ break
+ fi
+ fi
+ elif [[ -z $sbin ]]; then
+ continue
+ fi
+
+ srcdst=( ${(@s.->.)sbin} )
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1
+ [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1
+ [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1
+ [[ ${srcdst[1]} = [gnpcNEO]#c[gnpcNEO]#:* ]] && set_cwd=1
+ [[ ${srcdst[1]} = [gnpcNEO]#N[gnpcNEO]#:* ]] && use_all_null=1
+ [[ ${srcdst[1]} = [gnpcNEO]#E[gnpcNEO]#:* ]] && use_err_null=1
+ [[ ${srcdst[1]} = [gnpcNEO]#O[gnpcNEO]#:* ]] && use_out_null=1
+ srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]'
+
+ local -a fnames
+ local fname
+ eval "fnames=( ${srcdst[1]}(Nnon-.) )"
+
+ if (( !${#fnames} )) {
+ print -P -- "%F{38}bin-gem-node annex: %F{160}Warning: %F{154}The sbin'' ice (\`%F{219}$sbin%F{154}') didn't match any files%f"
+ continue
+ }
+
+ for fname ( $fnames ) {
+ srcdst[1]="$fname"
+
+ local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}" \
+ fnam="${srcdst[2]:-${srcdst[1]:t}}"
+ local file="$ZPFX/bin/$fnam"
+
+ if [[ $OSTYPE == cygwin ]]; then
+ .za-bgn-bin-or-src-function-body-cygwin 0 \
+ "$fnam" \
+ "$target_binary" "$dir" "$set_gem_home" \
+ "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
+ "$use_err_null" "$use_out_null"
+ builtin print -r -- "$REPLY" >! "$file.cmd"
+ command chmod +x "$file.cmd"
+ fi
+
+ .za-bgn-bin-or-src-function-body 0 \
+ "$fnam" \
+ "$target_binary" "$dir" "$set_gem_home" \
+ "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
+ "$use_err_null" "$use_out_null"
+
+ builtin print -r -- "#!/usr/bin/env zsh$nl$nl$REPLY$nl$nl$fnam \"\$@\"" >! "$file"
+ command chmod +x "$file" "$target_binary"
+
+ if [[ -x $file ]]; then
+ (( !OPTS[opt_-q,--quiet] )) && \
+ if [[ -x $target_binary ]]; then
+ if [[ $hook == atclone-<-> || $ZINIT[annex-multi-flag:pull-active] -ge 2 ]]; then
+ print -P -- "%F{38}bin-gem-node annex: %F{154}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the %F{219}$fnam%F{154} shim and set +x on the %F{219}${target_binary:t}%F{154} binary%f"
+ fi
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{154}${${${hook:#*atclone-<->}:+Re-c}:-C}reated the %F{219}$fnam%F{154} shim %F{160}however the %F{219}${target_binary:t}%F{160} binary does not exist or failed to set +x on it%f"
+ fi
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{160}Something went wrong creating the %F{219}$fnam%F{160} shim%f"
+ fi
}
+ }
)
-}
+ }
-if [[ -n "${ICE[fbin]}" ]] {
+ if [[ -n "${ICE[fbin]}" ]] {
local -a fbins srcdst
fbins=( "${(s.;.)ICE[fbin]}" )
-
local fbin
for fbin ( $fbins ) {
- srcdst=( ${(@s.->.)fbin} )
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- srcdst[1]=${srcdst[1]#[a-zA-Z]##:}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]'
-
- local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}" \
-
+ srcdst=( ${(@s.->.)fbin} )
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ srcdst[1]=${srcdst[1]#[a-zA-Z]##:}
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]'
+ local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}" \
command chmod +x "$target_binary"
- if [[ -x $target_binary ]]; then
- (( !OPTS[opt_-q,--quiet] )) && \
- print -P -- "%F{38}bin-gem-node annex: %F{154}Set +x on the %F{219}${target_binary:t}%F{154} binary%f"
- else
- print -P -- "%F{38}bin-gem-node annex: %F{160}Something went wrong setting +x on the %F{219}${target_binary:t}%F{160} binary%f"
- fi
+ if [[ -x $target_binary ]]; then
+ (( !OPTS[opt_-q,--quiet] )) && \
+ print -P -- "%F{38}bin-gem-node annex: %F{154}Set +x on the %F{219}${target_binary:t}%F{154} binary%f"
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{160}Something went wrong setting +x on the %F{219}${target_binary:t}%F{160} binary%f"
+ fi
}
+ }
}
-
-}
-
-# vim:ft=zsh:sw=4:sts=4:et
diff --git a/za-bgn-atdelete-handler b/za-bgn-atdelete-handler
index 87cd4a8..900a319 100644
--- a/za-bgn-atdelete-handler
+++ b/za-bgn-atdelete-handler
@@ -1,12 +1,15 @@
-# Copyright (c) 2019-2020 Sebastian Gniazdowski
-# License MIT
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
+#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
emulate -RL zsh
setopt extendedglob warncreateglobal typesetsilent noshortloops
[[ "$1" = plugin ]] && \
- local type="$1" user="$2" plugin="$3" id_as="$4" dir="$5" hook="$6" || \
- local type="$1" url="$2" id_as="$3" dir="$4" hook="$5"
+ local type="$1" user="$2" plugin="$3" id_as="$4" dir="$5" hook="$6" || \
+ local type="$1" url="$2" id_as="$3" dir="$4" hook="$5"
local nl=$'\n'
@@ -15,68 +18,66 @@ local nl=$'\n'
#
if (( ${+ICE[sbin]} )) {
- local -a sbins srcdst
- sbins=( ${(s.;.)ICE[sbin]} )
+ local -a sbins srcdst
+ sbins=( ${(s.;.)ICE[sbin]} )
- local sbin
- integer set_gem_home set_node_path set_virtualenv
+ local sbin
+ integer set_gem_home set_node_path set_virtualenv
- (
- builtin cd -q "$dir"
- for sbin ( $sbins "" ) {
- if [[ -z $sbin && ${#sbins} -eq 0 ]]; then
- if [[ -f $dir/${id_as:t} ]]; then
- sbin="$dir/${id_as:t}"
- elif [[ -n $plugin && -f $dir/$plugin ]]; then
- sbin="$dir/$plugin"
- elif [[ -n $url && -f $dir/${url:t} ]]; then
- sbin="$dir/${url:t}"
- else
- local -a files
- files=( $dir/*(*Nnon:t) )
- if (( ${#files} )); then
- sbin="${files[1]}"
- else
- print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
- break
- fi
- fi
- elif [[ -z $sbin ]]; then
- continue
- fi
+ (
+ builtin cd -q "$dir"
+ for sbin ( $sbins "" ) {
+ if [[ -z $sbin && ${#sbins} -eq 0 ]]; then
+ if [[ -f $dir/${id_as:t} ]]; then
+ sbin="$dir/${id_as:t}"
+ elif [[ -n $plugin && -f $dir/$plugin ]]; then
+ sbin="$dir/$plugin"
+ elif [[ -n $url && -f $dir/${url:t} ]]; then
+ sbin="$dir/${url:t}"
+ else
+ local -a files
+ files=( $dir/*(*Nnon:t) )
+ if (( ${#files} )); then
+ sbin="${files[1]}"
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty sbin ice didn't find any executable files%f"
+ break
+ fi
+ fi
+ elif [[ -z $sbin ]]; then
+ continue
+ fi
- srcdst=( ${(@s.->.)sbin} )
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1 || set_gem_home=0
- [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1 || set_node_path=0
- [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1 || set_virtualenv=0
- srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
+ srcdst=( ${(@s.->.)sbin} )
+ srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
+ [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1 || set_gem_home=0
+ [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1 || set_node_path=0
+ [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1 || set_virtualenv=0
+ srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]'
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]'
- local -a fnames
- local fname
- eval "fnames=( ${srcdst[1]}(Nnon-.) )"
- for fname ( $fnames ) {
- srcdst[1]="$fname"
- local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}" \
- fnam="${srcdst[2]:-${srcdst[1]:t}}"
- local file="$ZPFX/bin/$fnam"
+ local -a fnames
+ local fname
+ eval "fnames=( ${srcdst[1]}(Nnon-.) )"
+ for fname ( $fnames ) {
+ srcdst[1]="$fname"
+ local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}" \
+ fnam="${srcdst[2]:-${srcdst[1]:t}}"
+ local file="$ZPFX/bin/$fnam"
- if [[ -f $file ]]; then
- command rm -f "$file"
- if [[ -f $file ]]; then
- print -P -- "%F{38}bin-gem-node annex: %F{160}Couldn't remove the %F{220}$fnam%F{160} shim from \$ZPFX/bin (no write access to \$ZPFX/bin?)%f"
- else
- print -P -- "%F{38}bin-gem-node annex: %F{154}Correctly removed the %F{220}$fnam%F{154} shim from \$ZPFX/bin%f" || \
- fi
- else
- print -P -- "%F{38}bin-gem-node annex: %F{160}The %F{220}$fnam%F{160} shim didn't exist in \$ZPFX/bin (or isn't a regular file)%f"
- fi
- }
- }
- )
+ if [[ -f $file ]]; then
+ command rm -f "$file"
+ if [[ -f $file ]]; then
+ print -P -- "%F{38}bin-gem-node annex: %F{160}Couldn't remove the %F{220}$fnam%F{160} shim from \$ZPFX/bin (no write access to \$ZPFX/bin?)%f"
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{154}Correctly removed the %F{220}$fnam%F{154} shim from \$ZPFX/bin%f" || \
+ fi
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{160}The %F{220}$fnam%F{160} shim didn't exist in \$ZPFX/bin (or isn't a regular file)%f"
+ fi
+ }
+ }
+ )
}
-
-# vim:ft=zsh:sw=4:sts=4:et
diff --git a/za-bgn-atload-handler b/za-bgn-atload-handler
index 1eba5f8..4c2fa7b 100644
--- a/za-bgn-atload-handler
+++ b/za-bgn-atload-handler
@@ -1,24 +1,27 @@
-# Copyright (c) 2019-2020 Sebastian Gniazdowski
-# License MIT
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
+#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
za-bgn-atload-handler() {
-emulate -RL zsh
-setopt extendedglob warncreateglobal typesetsilent noshortloops
+ emulate -RL zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops
-if [[ "$1" = plugin ]] {
+ if [[ "$1" = plugin ]]; then
local type="$1" user="$2" plugin="$3" id_as="$4" dir="${5#%}" hook="$6"
-} else {
+ else
local type="$1" url="$2" id_as="$3" dir="${4#%}" hook="$5"
-}
+ fi
-local nl=$'\n'
+ local nl=$'\n'
-#
-# gem'' ice
-#
+ #
+ # gem'' ice
+ #
-if [[ -n "${ICE[gem]}" ]] {
+ if [[ -n "${ICE[gem]}" ]] {
local -a gems srcdst tmpsdst
gems=( "${(s.;.)ICE[gem]}" )
@@ -26,32 +29,32 @@ if [[ -n "${ICE[gem]}" ]] {
integer add_fbin
for gem ( $gems ) {
- srcdst=( ${(@s.->.)gem} )
- tmpsdst=( ${(@s.<-.)srcdst[1]} )
- if (( ${#tmpsdst} > 1 )); then
- srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
- else
- srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
- fi
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- [[ ${srcdst[2]} = \!* ]] && add_fbin=1 || add_fbin=0
- srcdst[2]=${srcdst[2]#\!}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
-
- if (( add_fbin )); then
- local target_binary="g:$dir/bin/${srcdst[1]}"
- ICE[fbin]+="${ICE[fbin]:+;}$target_binary -> ${srcdst[3]}"
- fi
+ srcdst=( ${(@s.->.)gem} )
+ tmpsdst=( ${(@s.<-.)srcdst[1]} )
+ if (( ${#tmpsdst} > 1 )); then
+ srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
+ else
+ srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
+ fi
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ [[ ${srcdst[2]} = \!* ]] && add_fbin=1 || add_fbin=0
+ srcdst[2]=${srcdst[2]#\!}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
+
+ if (( add_fbin )); then
+ local target_binary="g:$dir/bin/${srcdst[1]}"
+ ICE[fbin]+="${ICE[fbin]:+;}$target_binary -> ${srcdst[3]}"
+ fi
}
-}
+ }
-#
-# node'' ice
-#
+ #
+ # node'' ice
+ #
-if [[ -n "${ICE[node]}" ]] {
+ if [[ -n "${ICE[node]}" ]] {
local -a nodes srcdst tmpsdst
nodes=( "${(s.;.)ICE[node]}" )
@@ -59,32 +62,32 @@ if [[ -n "${ICE[node]}" ]] {
integer add_fbin
for node ( $nodes ) {
- srcdst=( ${(@s.->.)node} )
- tmpsdst=( ${(@s.<-.)srcdst[1]} )
- if (( ${#tmpsdst} > 1 )); then
- srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
- else
- srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
- fi
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- [[ ${srcdst[2]} = \!* ]] && add_fbin=1 || add_fbin=0
- srcdst[2]=${srcdst[2]#\!}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
-
- if (( add_fbin )); then
- local target_binary="n:$dir/node_modules/.bin/${srcdst[1]}"
- ICE[fbin]+="${ICE[fbin]:+;}$target_binary -> ${srcdst[3]}"
- fi
+ srcdst=( ${(@s.->.)node} )
+ tmpsdst=( ${(@s.<-.)srcdst[1]} )
+ if (( ${#tmpsdst} > 1 )); then
+ srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
+ else
+ srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
+ fi
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ [[ ${srcdst[2]} = \!* ]] && add_fbin=1 || add_fbin=0
+ srcdst[2]=${srcdst[2]#\!}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
+
+ if (( add_fbin )); then
+ local target_binary="n:$dir/node_modules/.bin/${srcdst[1]}"
+ ICE[fbin]+="${ICE[fbin]:+;}$target_binary -> ${srcdst[3]}"
+ fi
}
-}
+ }
-#
-# pip'' ice
-#
+ #
+ # pip'' ice
+ #
-if [[ -n "${ICE[pip]}" ]] {
+ if [[ -n "${ICE[pip]}" ]] {
local -a pips srcdst tmpsdst
pips=( "${(s.;.)ICE[pip]}" )
@@ -92,33 +95,33 @@ if [[ -n "${ICE[pip]}" ]] {
integer add_fbin
for pip ( $pips ) {
- srcdst=( ${(@s.->.)pip} )
- tmpsdst=( ${(@s.<-.)srcdst[1]} )
- if (( ${#tmpsdst} > 1 )); then
- srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
- else
- srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
- fi
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- [[ ${srcdst[2]} = \!* ]] && add_fbin=1 || add_fbin=0
- srcdst[2]=${srcdst[2]#\!}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
-
- if (( add_fbin )); then
- local target_binary="p:$dir/venv/bin/${srcdst[1]}"
- ICE[fbin]+="${ICE[fbin]:+;}$target_binary -> ${srcdst[3]}"
- fi
+ srcdst=( ${(@s.->.)pip} )
+ tmpsdst=( ${(@s.<-.)srcdst[1]} )
+ if (( ${#tmpsdst} > 1 )); then
+ srcdst=( "${tmpsdst[1]}" "${tmpsdst[2]}" "${srcdst[2]:-${tmpdist[2]#\!}}" )
+ else
+ srcdst=( "${tmpsdst[1]#\!}" "${tmpsdst[1]}" "${srcdst[2]:-${srcdst[1]#\!}}" )
+ fi
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ [[ ${srcdst[2]} = \!* ]] && add_fbin=1 || add_fbin=0
+ srcdst[2]=${srcdst[2]#\!}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]' 'srcdst[3]'
+
+ if (( add_fbin )); then
+ local target_binary="p:$dir/venv/bin/${srcdst[1]}"
+ ICE[fbin]+="${ICE[fbin]:+;}$target_binary -> ${srcdst[3]}"
+ fi
}
-}
+ }
-#
-# fbin'' ice – also inheriting any exclamation-mark gems
-# or node modules
-#
+ #
+ # fbin'' ice – also inheriting any exclamation-mark gems
+ # or node modules
+ #
-if (( ${+ICE[fbin]}${+ICE[fsrc]}${+ICE[ferc]} > 0 )) {
+ if (( ${+ICE[fbin]}${+ICE[fsrc]}${+ICE[ferc]} > 0 )) {
local -a fbins fsrcs fercs srcdst
fbins=( ${(s.;.)ICE[fbin]} )
fsrcs=( ${(s.;.)ICE[fsrc]} )
@@ -128,99 +131,94 @@ if (( ${+ICE[fbin]}${+ICE[fsrc]}${+ICE[ferc]} > 0 )) {
integer run_type=0
for fbin ( $fbins "" "" $fsrcs "" "" $fercs "" ) {
- integer set_gem_home=0 set_node_path=0 set_virtualenv=0 set_cwd=0 \
- use_all_null=0 use_err_null=0 use_out_null=0
-
- [[ "$fbin" = "" ]] && { run_type=1; continue; }
- [[ "$fbin" = "" ]] && { run_type=2; continue; }
-
- if [[ ( ${+ICE[fbin]} -eq 1 && run_type -eq 0 && -z $fbin && ${#fbins} -eq 0 ) || \
- ( ${+ICE[fsrc]} -eq 1 && run_type -eq 1 && -z $fbin && ${#fsrcs} -eq 0 ) || \
- ( ${+ICE[ferc]} -eq 1 && run_type -eq 2 && -z $fbin && ${#fercs} -eq 0 )
- ]]; then
- if [[ -f $dir/${id_as:t} ]]; then
- fbin="$dir/${id_as:t}"
- elif [[ -n $plugin && -f $dir/$plugin ]]; then
- fbin="$dir/$plugin"
- elif [[ -n $url && -f $dir/${url:t} ]]; then
- fbin="$dir/${url:t}"
- else
- local -a files
- files=( $dir/*(*Non:t) )
- if (( ${#files} )); then
- fbin="${files[1]}"
- else
- print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty fbin ice didn't find any executable files for %F{219}$id_as%f"
- break
- fi
- fi
- elif [[ -z $fbin ]]; then
- continue
+ integer set_gem_home=0 set_node_path=0 set_virtualenv=0 set_cwd=0 \
+ use_all_null=0 use_err_null=0 use_out_null=0
+
+ [[ "$fbin" = "" ]] && { run_type=1; continue; }
+ [[ "$fbin" = "" ]] && { run_type=2; continue; }
+
+ if [[ ( ${+ICE[fbin]} -eq 1 && run_type -eq 0 && -z $fbin && ${#fbins} -eq 0 ) || ( ${+ICE[fsrc]} -eq 1 && run_type -eq 1 && -z $fbin && ${#fsrcs} -eq 0 ) || ( ${+ICE[ferc]} -eq 1 && run_type -eq 2 && -z $fbin && ${#fercs} -eq 0 ) ]]; then
+ if [[ -f $dir/${id_as:t} ]]; then
+ fbin="$dir/${id_as:t}"
+ elif [[ -n $plugin && -f $dir/$plugin ]]; then
+ fbin="$dir/$plugin"
+ elif [[ -n $url && -f $dir/${url:t} ]]; then
+ fbin="$dir/${url:t}"
+ else
+ local -a files
+ files=( $dir/*(*Non:t) )
+ if (( ${#files} )); then
+ fbin="${files[1]}"
+ else
+ print -P -- "%F{38}bin-gem-node annex: %F{160}The automatic-empty fbin ice didn't find any executable files for %F{219}$id_as%f"
+ break
+ fi
fi
-
- srcdst=( ${(@s.->.)fbin} )
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1
- [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1
- [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1
- [[ ${srcdst[1]} = [gnpcNEO]#c[gnpcNEO]#:* ]] && set_cwd=1
- [[ ${srcdst[1]} = [gnpcNEO]#N[gnpcNEO]#:* ]] && use_all_null=1
- [[ ${srcdst[1]} = [gnpcNEO]#E[gnpcNEO]#:* ]] && use_err_null=1
- [[ ${srcdst[1]} = [gnpcNEO]#O[gnpcNEO]#:* ]] && use_out_null=1
- srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]'
-
- local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}"
-
- .za-bgn-bin-or-src-function-body "$run_type" \
- "${srcdst[2]:-${srcdst[1]:t}}" \
- "$target_binary" "$dir" "$set_gem_home" \
- "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
- "$use_err_null" "$use_out_null"
- eval "$REPLY"
+ elif [[ -z $fbin ]]; then
+ continue
+ fi
+
+ srcdst=( ${(@s.->.)fbin} )
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1
+ [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1
+ [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1
+ [[ ${srcdst[1]} = [gnpcNEO]#c[gnpcNEO]#:* ]] && set_cwd=1
+ [[ ${srcdst[1]} = [gnpcNEO]#N[gnpcNEO]#:* ]] && use_all_null=1
+ [[ ${srcdst[1]} = [gnpcNEO]#E[gnpcNEO]#:* ]] && use_err_null=1
+ [[ ${srcdst[1]} = [gnpcNEO]#O[gnpcNEO]#:* ]] && use_out_null=1
+ srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]'
+
+ local target_binary="${${(M)srcdst[1]:#/*}:-$dir/${srcdst[1]}}"
+
+ .za-bgn-bin-or-src-function-body "$run_type" \
+ "${srcdst[2]:-${srcdst[1]:t}}" \
+ "$target_binary" "$dir" "$set_gem_home" \
+ "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
+ "$use_err_null" "$use_out_null"
+ eval "$REPLY"
}
-}
+ }
-#
-# fmod'' ice
-#
+ #
+ # fmod'' ice
+ #
-if [[ -n "${ICE[fmod]}" ]] {
+ if [[ -n "${ICE[fmod]}" ]] {
local -a fmods srcdst
fmods=( "${(s.;.)ICE[fmod]}" )
local fmod
for fmod ( $fmods ) {
- integer set_gem_home=0 set_node_path=0 set_virtualenv=0 set_cwd=0 \
- use_all_null=0 use_err_null=0 use_out_null=0
-
- srcdst=( ${(@s.->.)fmod} )
- srcdst=( "${srcdst[@]//((#s)[[:space:]]##|[[:space:]]##(#e))/}" )
- [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1
- [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1
- [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1
- [[ ${srcdst[1]} = [gnpcNEO]#c[gnpcNEO]#:* ]] && set_cwd=1
- [[ ${srcdst[1]} = [gnpcNEO]#N[gnpcNEO]#:* ]] && use_all_null=1
- [[ ${srcdst[1]} = [gnpcNEO]#E[gnpcNEO]#:* ]] && use_err_null=1
- [[ ${srcdst[1]} = [gnpcNEO]#O[gnpcNEO]#:* ]] && use_out_null=1
- srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
-
- # Substitute the standard keywords and param''-s
- @zinit-substitute 'srcdst[1]' 'srcdst[2]'
-
- local target_function="${srcdst[1]}"
-
- .za-bgn-mod-function-body "${srcdst[2]:-${srcdst[1]}}" \
- "$target_function" "$dir" "$set_gem_home" \
- "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
- "$use_err_null" "$use_out_null"
- eval "$REPLY"
+ integer set_gem_home=0 set_node_path=0 set_virtualenv=0 set_cwd=0 use_all_null=0 use_err_null=0 use_out_null=0
+
+ srcdst=( ${(@s.->.)fmod} )
+ srcdst=( "${srcdst[@]//( (#s)[[:space:]]##|[[:space:]]##(#e) )/}" )
+ [[ ${srcdst[1]} = [gnpcNEO]#g[gnpcNEO]#:* ]] && set_gem_home=1
+ [[ ${srcdst[1]} = [gnpcNEO]#n[gnpcNEO]#:* ]] && set_node_path=1
+ [[ ${srcdst[1]} = [gnpcNEO]#p[gnpcNEO]#:* ]] && set_virtualenv=1
+ [[ ${srcdst[1]} = [gnpcNEO]#c[gnpcNEO]#:* ]] && set_cwd=1
+ [[ ${srcdst[1]} = [gnpcNEO]#N[gnpcNEO]#:* ]] && use_all_null=1
+ [[ ${srcdst[1]} = [gnpcNEO]#E[gnpcNEO]#:* ]] && use_err_null=1
+ [[ ${srcdst[1]} = [gnpcNEO]#O[gnpcNEO]#:* ]] && use_out_null=1
+ srcdst[1]=${srcdst[1]#[a-zA-Z]#:}
+
+ # Substitute the standard keywords and param''-s
+ @zinit-substitute 'srcdst[1]' 'srcdst[2]'
+
+ local target_function="${srcdst[1]}"
+
+ .za-bgn-mod-function-body "${srcdst[2]:-${srcdst[1]}}" \
+ "$target_function" "$dir" "$set_gem_home" \
+ "$set_node_path" "$set_virtualenv" "$set_cwd" "$use_all_null" \
+ "$use_err_null" "$use_out_null"
+ eval "$REPLY"
}
-}
-
+ }
}
# vim:ft=zsh:sw=4:sts=4:et
diff --git a/za-bgn-help-handler b/za-bgn-help-handler
index e69de29..c4f4a04 100644
--- a/za-bgn-help-handler
+++ b/za-bgn-help-handler
@@ -0,0 +1,6 @@
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
+#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
+
diff --git a/za-bgn-shim-list b/za-bgn-shim-list
index 93e4eff..6c338ad 100644
--- a/za-bgn-shim-list
+++ b/za-bgn-shim-list
@@ -1,44 +1,39 @@
-# -*- mode: sh; sh-indentation: 4; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
-
-# Copyright 2020 Sebastian Gniazdowski
-# License: MIT
-
-# Synopsis:
-# zinit shim-list [-t|--this-dir] [-c|--cat] [-i|--from-ices] \
-# [-o|--one-line] [-s|--short]
+#!/usr/bin/env zsh
+# -*- mode: sh; sh-indentation: 2; sh-basic-offset: 2; indent-tabs-mode: nil; -*-
#
+# Copyright (c) 2019-2020 Sebastian Gniazdowski and contributors
+# Copyright (c) 2021-2022 zdharma-continuum and contributors
+
+# Usage:
+# zinit shim-list [-t|--this-dir] [-c|--cat] [-i|--from-ices] [-o|--one-line] [-s|--short]
za-bgn-shim-list() {
-emulate -LR zsh
-setopt extended_glob warn_create_global typeset_silent \
- no_short_loops rc_quotes
-
-autoload is-at-least
-local is_58
-is-at-least 5.8 && is_58=1
-
-local -a opt_help opt_this_dir opt_cat opt_from_ices opt_one_line \
- opt_short
-zparseopts -D -E ${is_58:+-F} \
- h=opt_help -help=opt_help \
- t=opt_this_dir -this-dir=opt_this_dir \
- c=opt_cat -cat=opt_cat \
- i=opt_from_ices -from-ices=opt_from_ices \
- s=opt_short -short=opt_short \
- o=opt_one_line -one-line=opt_one_line || \
- {
- print -Pr "$ZINIT[col-error]Error:$ZINIT[col-msg2]" \
- "Incorrect options given to" \
- "$ZINIT[col-obj]shim-list$ZINIT[col-msg2], try" \
- "$ZINIT[col-obj]--help%f"
- return 1
- }
-
-(( ${#opt_help} )) && {
+ emulate -LR zsh
+ setopt extended_glob warn_create_global typeset_silent \
+ no_short_loops rc_quotes
+
+ autoload is-at-least
+ local is_58
+ is-at-least 5.8 && is_58=1
+
+ local -a opt_help opt_this_dir opt_cat opt_from_ices opt_one_line opt_short
+ zparseopts -D -E ${is_58:+-F} \
+ h=opt_help -help=opt_help \
+ t=opt_this_dir -this-dir=opt_this_dir \
+ c=opt_cat -cat=opt_cat \
+ i=opt_from_ices -from-ices=opt_from_ices \
+ s=opt_short -short=opt_short \
+ o=opt_one_line -one-line=opt_one_line \
+ || {
+ print -Pr "$ZINIT[col-error]Error:$ZINIT[col-msg2] Incorrect options given to $ZINIT[col-obj]shim-list$ZINIT[col-msg2], try $ZINIT[col-obj]--help%f"
+ return 1
+ }
+
+ (( ${#opt_help} )) && {
print -P "$ZINIT[col-obj]Usage:%f\n" \
- "zinit shim-list [-h/--help] [-t|--this-dir] [-i|--from-ices] \\\\\n" \
- " [-o|--one-line] [-s|--short] [-c|--cat]"
+ "zinit shim-list [-h/--help] [-t|--this-dir] [-i|--from-ices] \\\\\n" \
+ " [-o|--one-line] [-s|--short] [-c|--cat]"
cat < longest )) && longest=len
- found+=( $file )
- }
- }
-
- for file ( $found ) {
- local body="$(<$file)" name=$file:t
- print -r ${${:-$opt_one_line${(M)${opt_short:-1}:#1}}:+-n} -- ${file:t}" " \
- ${${(M)${opt_short:-1}:#1}:+${(l:longest+1-${#name}:: :):-}}
-
- if (( !${#opt_short} )) {
- if [[ $body = (#b)$~pattern([^$nl]##)$nl* ]] {
- local pth=${match[1]%\"}
- local id_as=${${${pth##$~rempat}##/##}%\"}
- if [[ $pth = $~snippat ]] {
- if [[ $id_as = ((OMZ|PZT|PZTM|OMZP|OMZT|OMZL)::|(#i)(http(s|)|ftp(s|)|rsync|ssh)--)* ]] {
- { local url="$(<$pth/._zinit/url)" } 2>/dev/null
- } else {
- local -A map
- map=( -- "/" -EQ- "=" -QM- "?" -AMP- "&" )
- local url=${id_as//(#m)(${(~j:|:k)map})/${map[$MATCH]}}
- }
- print -r "$ZINIT[col-obj]$url$ZINIT[col-rst]"
- } else {
- (( ${+functions[.zinit-first]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh"
- .zinit-any-colorify-as-uspl2 "$id_as"
- print -r -- "$REPLY"
- }
- }
- }
- }
- (( ${#opt_one_line} )) && print
-
- } else {
- +zinit-message '[msg2]Listing shims basing on the in-memory ices data...[rst]'
- local p
- local -A ices
- for p ( $ZINIT_REGISTERED_PLUGINS ) {
- if [[ -n $ZINIT_SICE[$p] ]] {
- ices=( "${(@Q)${(@z)ZINIT_SICE[$p]}}" )
- local sbin
- local -a sbins
- sbins=( ${(s.;.)ices[sbin]} )
- if (( ${#sbins} )) {
- .zinit-any-colorify-as-uspl2 "$p"
- }
- for sbin ( $sbins ) {
- print "${(r:50:: :)sbin} $REPLY"
- }
- }
- }
- }
-
-} | if (( !${#opt_short} || ${#opt_one_line} )) {
- cat
- } else {
- pr -4 -T
- }
+ }
+
+ (( !${+functions[.zinit-any-colorify-as-uspl2]} )) && builtin source $ZINIT[BIN_DIR]/zinit-side.zsh
+
+ # To `cat`… or `pr`…:
+ {
+ if (( !${#opt_from_ices} )); then
+ local nl=$'\n' brace='{' quote='"'
+ local pattern='(#s)\#!/usr/bin/env zsh
+
+ () * {
+ local bindir="'
+
+ local -a cands
+ cands=( ${${opt_this_dir:+.}:-$ZPFX/bin}/*(.-NDL-1000) )
+ cands=( ${cands:#.} )
+
+ local rempat="(${ZINIT[PLUGINS_DIR]}|${ZINIT[SNIPPETS_DIR]}"
+ rempat+="|${ZINIT[PLUGINS_DIR]/.zinit/.zplugin}"
+ rempat+="|${ZINIT[SNIPPETS_DIR]/.zinit/.zplugin})"
+ local snippat="(${ZINIT[SNIPPETS_DIR]}|${ZINIT[SNIPPETS_DIR]/.zinit/.zplugin})/*"
+
+ local file
+ local -a found
+ integer longest len
+ for file ( $cands ) {
+ local body="$(<$file)"
+ if [[ -n ${body[(r)$pattern]} ]] {
+ len=${#${file:t}}
+ (( len > longest )) && longest=len
+ found+=( $file )
+ }
+ }
+
+ for file ( $found ) {
+ local body="$(<$file)" name=$file:t
+ print -r ${${:-$opt_one_line${(M)${opt_short:-1}:#1}}:+-n} -- ${file:t} ${${(M)${opt_short:-1}:#1}:+${(l:longest+1-${#name}:: :):-}}
+ if (( !${#opt_short} )); then
+ if [[ $body = (#b)$~pattern([^$nl]##)$nl* ]]; then
+ local pth=${match[1]%\"}
+ local id_as=${${${pth##$~rempat}##/##}%\"}
+ if [[ $pth = $~snippat ]]; then
+ if [[ $id_as = ( (OMZ|PZT|PZTM|OMZP|OMZT|OMZL)::|(#i)(http(s|)|ftp(s|)|rsync|ssh)--)* ]]; then
+ { local url="$(<$pth/._zinit/url)" } 2>/dev/null
+ else
+ local -A map
+ # map=( -- "/" -EQ- "=" -QM- "?" -AMP- "&" )
+ # local url=${id_as//(#m)(${(~j:|:k)map})/${map[$MATCH]}}
+ print -r "$ZINIT[col-obj]$url$ZINIT[col-rst]"
+ fi
+ else
+ (( ${+functions[.zinit-first]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh"
+ .zinit-any-colorify-as-uspl2 "$id_as"
+ print -r -- "$REPLY"
+ fi
+ fi
+ fi
+ fi
+ }
+ (( ${#opt_one_line} )) && print
+
+ else
+ +zinit-message '[msg2]Listing shims basing on the in-memory ices data...[rst]'
+ local p
+ local -A ices
+ for p ( $ZINIT_REGISTERED_PLUGINS ) {
+ if [[ -n $ZINIT_SICE[$p] ]]; then
+ ices=( "${(@Q)${(@z)ZINIT_SICE[$p]}}" )
+ local sbin
+ local -a sbins
+ sbins=( ${(s.;.)ices[sbin]} )
+ if (( ${#sbins} )) {
+ .zinit-any-colorify-as-uspl2 "$p"
+ }
+ for sbin ( $sbins ) {
+ print "${(r:50:: :)sbin} $REPLY"
+ }
+ fi
+ }
+ fi
+ } | \
+ if (( !${#opt_short} || ${#opt_one_line} )); then
+ cat
+ else
+ pr -4 -T
+ fi
}
# vim:ft=zsh:sw=4:sts=4:noet: