diff --git a/.editorconfig b/.editorconfig
index 71e0d04c..1e1705f7 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -4,20 +4,12 @@
root = true
[*]
-indent_style = tab
-indent_size = 4
+indent_style = space
+indent_size = 2
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
-continuation_indent_size = 4
-
-[Makefile]
-indent_style = tab
[**.{md,rst}]
trim_trailing_whitespace = false
-
-[*.{yml,json}]
-indent_style = space
-indent_size = 2
diff --git a/.gitattributes b/.gitattributes
index 91fbd32d..a79428b4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,32 +1,7 @@
# Auto detect text files and perform LF normalization so files in repo had LF and client translates to CRLF on Windows
* text=auto
-*.md text diff=markdown
-*.zsh text diff=zsh eol=lf
-
-*.gitattributes text
-.gitignore text
-
-###############################
-# Git Large File System (LFS) #
-###############################
-
-#*.7z filter=lfs diff=lfs merge=lfs -text
-#*.br filter=lfs diff=lfs merge=lfs -text
-#*.gz filter=lfs diff=lfs merge=lfs -text
-#*.tar filter=lfs diff=lfs merge=lfs -text
-#*.zip filter=lfs diff=lfs merge=lfs -text
-#*.pdf filter=lfs diff=lfs merge=lfs -text
-
-#*.gif filter=lfs diff=lfs merge=lfs -text
-#*.ico filter=lfs diff=lfs merge=lfs -text
-#*.jpg filter=lfs diff=lfs merge=lfs -text
-#*.png filter=lfs diff=lfs merge=lfs -text
-#*.psd filter=lfs diff=lfs merge=lfs -text
-#*.webp filter=lfs diff=lfs merge=lfs -text
-#*.woff2 filter=lfs diff=lfs merge=lfs -text
-
-.gitattributes export-ignore
-.gitignore export-ignore
-.gitkeep export-ignore
-
-*.gitattributes linguist-language=gitattributes
+*.md diff=markdown
+*.zsh diff=zsh eol=lf
+∧* diff=zsh
+\.za-* diff=zsh
+*.zi diff=zsh
diff --git a/.github/workflows/hello.yml b/.github/workflows/hello.yml
deleted file mode 100644
index 6ffca700..00000000
--- a/.github/workflows/hello.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-name: Greetings
-
-on: #[pull_request, issues]
- workflow_dispatch:
-
-jobs:
- greeting:
- runs-on: ubuntu-latest
- permissions:
- issues: write
- pull-requests: write
- steps:
- - uses: actions/first-interaction@v1.1.0
- with:
- repo-token: ${{ secrets.GITHUB_TOKEN }}
- issue-message: "Hi, thank you for opening an issue 🚀. We welcome you to the community!"
- pr-message: "Hi, thanks for your first Pull Request 👍. Someone will review it soon."
diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml
index 82d89057..de1b02d4 100644
--- a/.github/workflows/pr-labels.yml
+++ b/.github/workflows/pr-labels.yml
@@ -3,9 +3,10 @@ name: Verify PR Labels
on:
workflow_dispatch:
- pull_request:
+ pull_request_target:
types: [opened, labeled, unlabeled, synchronize]
+
jobs:
pr_labels:
name: 🏭 Verify PR Labels
diff --git a/.github/workflows/wiki.yml b/.github/workflows/wiki.yml
index 08c37ff1..e3f917d6 100644
--- a/.github/workflows/wiki.yml
+++ b/.github/workflows/wiki.yml
@@ -12,16 +12,21 @@ jobs:
steps:
- uses: actions/checkout@v2
-# - name: Publish to GitHub Wiki
-# uses: SwiftDocOrg/github-wiki-publish-action@1.0.0
-# with:
-# path: docs/wiki
-
- - name: GitHub Wiki Action
- uses: Andrew-Chen-Wang/github-wiki-action@v2
+ - name: Publish to GitHub Wiki
+ uses: SwiftDocOrg/github-wiki-publish-action@1.0.0
+ with:
+ path: docs/wiki
env:
- WIKI_DIR: docs/wiki/
- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- GH_MAIL: ${{ secrets.GH_MAIL }}
- GH_NAME: ${{ github.repository_owner }}
- EXCLUDED_FILES: "docs/wiki/drafts"
+ GH_PERSONAL_ACCESS_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
+
+# - name: wiki-page-creator-action
+# uses: Decathlon/wiki-page-creator-action@v2.0.0
+
+# - name: GitHub Wiki Action
+# uses: Andrew-Chen-Wang/github-wiki-action@v2
+# env:
+# WIKI_DIR: docs/wiki/
+# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+# GH_MAIL: ${{ secrets.GH_MAIL }}
+# GH_NAME: ${{ github.repository_owner }}
+# EXCLUDED_FILES: "docs/wiki/drafts"
diff --git a/.gitignore b/.gitignore
index 7ea6ae57..c373c4a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,6 +8,7 @@
# Exclude for security reasons
.history/
+.dccache
.env
# Zsh compiled script + zrecompile backup
@@ -25,8 +26,6 @@
._zinit
.zi_lastupd
.zinit_lastupd
-
-# A popular older versions plugin manager's files
._zplugin
.zplugin_lstupd
diff --git a/docs/Makefile b/docs/Makefile
index ff590062..4579a73a 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -1,24 +1,24 @@
-all: ../zi.zsh.zwc ../lib/zsh/side.zsh.zwc ../lib/zsh/install.zsh.zwc ../lib/zsh/autoload.zsh.zwc ../lib/zsh/additional.zsh.zwc
+all: ../zi.zsh.zwc ../lib/zsh/side.zsh.zwc ../lib/zsh/install.zsh.zwc ../lib/zsh/autoload.zsh.zwc
%.zwc: %
../lib/zcompile $<
-#alltest: test testB testC testD testE
-#test:
-# make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS=$(OPTS) -C test test
-#testB:
-# make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="kshglob" -C test test
-#testC:
-# make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="noextendedglob" -C test test
-#testD:
-# make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="ksharrays" -C test test
-#testE:
-# make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="ignoreclosebraces" -C test test
+alltest: test testB testC testD testE
+test:
+ make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS=$(OPTS) -C test test
+testB:
+ make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="kshglob" -C test test
+testC:
+ make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="noextendedglob" -C test test
+testD:
+ make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="ksharrays" -C test test
+testE:
+ make VERBOSE=$(VERBOSE) NODIFF=$(NODIFF) DEBUG=$(DEBUG) OPTDUMP=$(OPTDUMP) OPTS="ignoreclosebraces" -C test test
-doc: ../zi.zsh ../lib/zsh/side.zsh ../lib/zsh/install.zsh ../lib/zsh/autoload.zsh ../lib/zsh/additional.zsh
+doc: ../zi.zsh ../lib/zsh/side.zsh ../lib/zsh/install.zsh ../lib/zsh/autoload.zsh
rm -rf zsdoc/data zsdoc/*.adoc
zsd -v --scomm --cignore '(\#*FUNCTION:*{{{*|\#[[:space:]]#}}}*)' \
- ../zi.zsh ../lib/zsh/side.zsh ../lib/zsh/install.zsh ../lib/zsh/autoload.zsh ../lib/zsh/additional.zsh
+ ../zi.zsh ../lib/zsh/side.zsh ../lib/zsh/install.zsh ../lib/zsh/autoload.zsh
html: doc
cd zsdoc && \
@@ -29,7 +29,7 @@ html: doc
asciidoctor additional.zsh.adoc
clean:
- rm -f ../zi.zsh.zwc ../lib/zsh/side.zsh.zwc ../lib/zsh/install.zsh.zwc ../lib/zsh/autoload.zsh.zwc ../lib/zsh/additional.zsh.zwc
+ rm -f ../zi.zsh.zwc ../lib/zsh/side.zsh.zwc ../lib/zsh/install.zsh.zwc ../lib/zsh/autoload.zsh.zwc
rm -rf zsdoc/data
.PHONY: all clean doc html
diff --git a/docs/README.md b/docs/README.md
index b6dcf132..d94109cb 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -6,7 +6,7 @@
-Beta release
+Nightly Release
@@ -102,7 +102,7 @@ _For more information and to report security issues, please refer to our [securi
> **[?]**
> The [Z-Shell](https://github.com/z-shell) was created to recover the `zdharma` organization project which was deleted by the owner.
-> I don't want to depend on an unreliable source. For these reasons, I started maintaining these tools for myself everyone interested is welcome.
+> I don't want to depend on an unreliable source. For these reasons, I started maintaining these tools myself and everyone interested is welcome.
## Roadmap
diff --git a/docs/zsdoc/Makefile b/docs/zsdoc/Makefile
index 65b75f9a..a65d186a 100644
--- a/docs/zsdoc/Makefile
+++ b/docs/zsdoc/Makefile
@@ -8,7 +8,7 @@ all: man pdf
# MAN
# Converted with a2x from asciidoc package
-man: man/zi.zsh.1 man/side.zsh.1 man/install.zsh.1 man/autoload.zsh.1 man/additional.zsh.1
+man: man/zi.zsh.1 man/side.zsh.1 man/install.zsh.1 man/autoload.zsh.1
man/zi.zsh.1:
@mkdir -p man
@@ -24,16 +24,12 @@ man/install.zsh.1:
man/autoload.zsh.1:
@mkdir -p man
- a2x --verbose -L --doctype manpage --format manpage -D man autoload.zsh.adoc
-
-man/additional.zsh.1:
- @mkdir -p man
- a2x --verbose -L --doctype manpage --format manpage -D man additional.zsh.adoc
+ a2x --verbose -L --doctype manpage --format manpage -D man autoload.zsh.doc
# PDF
# Uses asciidoctor not a2x (i.e. not asciidoc)
-pdf: pdf/zi.zsh.pdf pdf/side.zsh.pdf pdf/install.zsh.pdf pdf/autoload.zsh.pdf pdf/additional.zsh.pdf
+pdf: pdf/zi.zsh.pdf pdf/side.zsh.pdf pdf/install.zsh.pdf pdf/autoload.zsh.pdf
pdf/zi.zsh.pdf:
@mkdir -p pdf
@@ -51,10 +47,6 @@ pdf/autoload.zsh.pdf:
@mkdir -p pdf
asciidoctor -a reproducible -b pdf -r asciidoctor-pdf -D pdf autoload.zsh.adoc
-pdf/additional.zsh.pdf:
- @mkdir -p pdf
- asciidoctor -a reproducible -b pdf -r asciidoctor-pdf -D pdf additional.zsh.adoc
-
clean:
rm -rf man pdf data
diff --git a/docs/zsdoc/README.md b/docs/zsdoc/README.md
index 9ef52bfa..d5e9ba7a 100644
--- a/docs/zsdoc/README.md
+++ b/docs/zsdoc/README.md
@@ -1,15 +1,15 @@
# Code documentation
Here is `Asciidoc` code documentation generated using [Zshelldoc](https://github.com/z-shell/zshelldoc).
-There are `4` ZI's source files, the main one is [zinit.zsh](zinit.zsh.adoc). The documentation
+There are `4` ❮ ZI ❯ source files, the main one is [zi.zsh](zi.zsh.adoc). The documentation
lists all functions, interactions between them, their comments and features used.
Github allows to directly view `Asciidoc` documents:
-- [zinit.zsh](zinit.zsh.adoc) – always loaded, in `.zshrc` ([pdf](https://z-shell.github.io/zi/wiki/zinit.zsh))
-- [side.zsh](side.zsh.adoc) – common functions, loaded by `*-install` and `*-autoload` scripts ([pdf](https://z-shell.github.io/zi/wiki/side.zsh))
-- [install.zsh](install.zsh.adoc) – functions used only when installing a plugin or snippet ([pdf](https://z-shell.github.io/zi/wiki/install.zsh))
-- [autoload.zsh](autoload.zsh.adoc) – functions used only in interactive `ZI` invocations ([pdf](https://z-shell.github.io/zi/wiki/autoload.zsh/))
+- [zi.zsh](zi.zsh.adoc) – always loaded, in `.zshrc` ([pdf](https://z-shell.github.io/zi/wiki/zi.zsh))
+- [side.zsh](side.zsh.adoc) – common functions, loaded by `*-install` and `*-autoload` scripts ([pdf](https://z-shell.github.io/zi/wiki/side.zsh))
+- [install.zsh](install.zsh.adoc) – functions used only when installing a plugin or snippet ([pdf](https://z-shell.github.io/zi/wiki/install.zsh))
+- [autoload.zsh](autoload.zsh.adoc) – functions used only in interactive `ZI` invocations ([pdf](https://z-shell.github.io/zi/wiki/autoload.zsh))
# PDFs, man pages, etc.
diff --git a/docs/zsdoc/additional.zsh.adoc b/docs/zsdoc/additional.zsh.adoc
deleted file mode 100644
index 1d888361..00000000
--- a/docs/zsdoc/additional.zsh.adoc
+++ /dev/null
@@ -1,166 +0,0 @@
-additional.zsh(1)
-=================
-:compat-mode!:
-
-NAME
-----
-additional.zsh - a shell script
-
-SYNOPSIS
---------
-Documentation automatically generated with `zshelldoc'
-
-FUNCTIONS
----------
-
- .zi-clear-debug-report
- .zi-debug-start
- .zi-debug-stop
- .zi-debug-unload
- .zi-service
- :zi-tmp-subst-source
- .zi-wrap-track-functions
-
-DETAILS
--------
-
-Script Body
-~~~~~~~~~~~
-
-Has 1 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.).
-
-.zi-clear-debug-report
-~~~~~~~~~~~~~~~~~~~~~~
-
-____
-
- FUNCTION: .zi-clear-debug-report [[[
- Forgets dtrace repport gathered up to this moment.
-____
-
-Has 1 line(s). Calls functions:
-
- .zi-clear-debug-report
- `-- autoload.zsh/.zi-clear-report-for
-
-Called by:
-
- autoload.zsh/.zi-unload
- zi.zsh/zi
-
-.zi-debug-start
-~~~~~~~~~~~~~~~
-
-____
-
- FUNCTION: .zi-debug-start [[[
- Starts Dtrace, i.e. session tracking for changes in Zsh state.
-____
-
-Has 9 line(s). Calls functions:
-
- .zi-debug-start
- |-- zi.zsh/.zi-diff
- |-- zi.zsh/+zi-message
- `-- zi.zsh/.zi-tmp-subst-on
-
-Called by:
-
- zi.zsh/zi
-
-.zi-debug-stop
-~~~~~~~~~~~~~~
-
-____
-
- FUNCTION: .zi-debug-stop [[[
- Stops Dtrace, i.e. session tracking for changes in Zsh state.
-____
-
-Has 3 line(s). Calls functions:
-
- .zi-debug-stop
- |-- zi.zsh/.zi-diff
- `-- zi.zsh/.zi-tmp-subst-off
-
-Called by:
-
- zi.zsh/zi
-
-.zi-debug-unload
-~~~~~~~~~~~~~~~~
-
-____
-
- FUNCTION: .zi-debug-unload [[[
- Reverts changes detected by dtrace run.
-____
-
-Has 6 line(s). Calls functions:
-
- .zi-debug-unload
- |-- autoload.zsh/.zi-unload
- `-- zi.zsh/+zi-message
-
-Uses feature(s): _source_
-
-Called by:
-
- zi.zsh/zi
-
-.zi-service
-~~~~~~~~~~~
-
-____
-
- ]]]
- FUNCTION: .zi-service [[[
- Handles given service, i.e. obtains lock, runs it, or waits if no lock
-
- $1 - type "p" or "s" (plugin or snippet)
- $2 - mode - for plugin (light or load)
- $3 - id - URL or plugin ID or alias name (from id-as'')
-____
-
-Has 33 line(s). Calls functions:
-
- .zi-service
- |-- zi.zsh/.zi-load
- `-- zi.zsh/.zi-load-snippet
-
-Uses feature(s): _kill_, _read_, _setopt_
-
-Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
-
-:zi-tmp-subst-source
-~~~~~~~~~~~~~~~~~~~~
-
-____
-
- FUNCTION: :zi-tmp-subst-source [[[
-____
-
-Has 25 line(s). Calls functions:
-
- :zi-tmp-subst-source
- `-- zi.zsh/+zi-message
-
-Uses feature(s): _eval_
-
-Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
-
-.zi-wrap-track-functions
-~~~~~~~~~~~~~~~~~~~~~~~~
-
-____
-
- ]]]
- FUNCTION: .zi-wrap-track-functions [[[
-____
-
-Has 19 line(s). Doesn't call other functions.
-
-Uses feature(s): _eval_
-
-Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
-
diff --git a/docs/zsdoc/autoload.zsh.adoc b/docs/zsdoc/autoload.zsh.adoc
index 76b91ae2..a857ed4e 100644
--- a/docs/zsdoc/autoload.zsh.adoc
+++ b/docs/zsdoc/autoload.zsh.adoc
@@ -13,6 +13,7 @@ Documentation automatically generated with `zshelldoc'
FUNCTIONS
---------
+ .zi-analytics-menu
.zi-any-to-uspl2
.zi-at-eval
.zi-build-module
@@ -28,6 +29,7 @@ FUNCTIONS
.zi-compiled
.zi-compile-uncompile-all
.zi-confirm
+ .zi-control-menu
.zi-create
.zi-delete
.zi-diff-env-compute
@@ -83,10 +85,27 @@ DETAILS
Script Body
~~~~~~~~~~~
-Has 5 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.).
+Has 4 line(s). No functions are called (may set up e.g. a hook, a Zle widget bound to a key, etc.).
Uses feature(s): _source_
+.zi-analytics-menu
+~~~~~~~~~~~~~~~~~~
+
+____
+
+ FUNCTION: .zi-analytics-menu [[[
+ Shows ZI analytics.
+
+ User-action entry point.
+____
+
+Has 23 line(s). Doesn't call other functions.
+
+Called by:
+
+ zi.zsh/zi
+
.zi-any-to-uspl2
~~~~~~~~~~~~~~~~
@@ -183,7 +202,7 @@ ____
$1 - e.g. "_mkdir" or "mkdir"
____
-Has 30 line(s). Calls functions:
+Has 27 line(s). Calls functions:
.zi-cdisable
@@ -204,7 +223,7 @@ ____
$1 - e.g. "_mkdir" or "mkdir"
____
-Has 31 line(s). Calls functions:
+Has 26 line(s). Calls functions:
.zi-cenable
@@ -227,7 +246,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 9 line(s). Calls functions:
+Has 7 line(s). Calls functions:
.zi-changes
|-- side.zsh/.zi-exists-physically-message
@@ -275,7 +294,7 @@ ____
$1, ... - path to completion within plugin's directory
____
-Has 11 line(s). Doesn't call other functions.
+Has 10 line(s). Doesn't call other functions.
Called by:
@@ -295,7 +314,7 @@ ____
$1, ... - path to completion within plugin's directory
____
-Has 12 line(s). Doesn't call other functions.
+Has 11 line(s). Doesn't call other functions.
Called by:
@@ -315,7 +334,7 @@ ____
User-action entry point.
____
-Has 37 line(s). Calls functions:
+Has 35 line(s). Calls functions:
.zi-clear-completions
`-- side.zsh/.zi-any-colorify-as-uspl2
@@ -347,7 +366,6 @@ Has 23 line(s). Calls functions:
Called by:
.zi-unload
- additional.zsh/.zi-clear-debug-report
.zi-compiled
~~~~~~~~~~~~
@@ -360,7 +378,7 @@ ____
User-action entry point.
____
-Has 26 line(s). Calls functions:
+Has 23 line(s). Calls functions:
.zi-compiled
|-- side.zsh/.zi-any-colorify-as-uspl2
@@ -383,7 +401,7 @@ ____
User-action entry point.
____
-Has 23 line(s). Calls functions:
+Has 19 line(s). Calls functions:
.zi-compile-uncompile-all
|-- install.zsh/.zi-compile-plugin
@@ -417,6 +435,23 @@ Called by:
.zi-delete
+.zi-control-menu
+~~~~~~~~~~~~~~~~
+
+____
+
+ FUNCTION: .zi-control-menu [[[
+ Shows control options.
+
+ User-action entry point.
+____
+
+Has 22 line(s). Doesn't call other functions.
+
+Called by:
+
+ zi.zsh/zi
+
.zi-create
~~~~~~~~~~
@@ -431,7 +466,7 @@ ____
$2 - (optional) plugin (only when $1 - i.e. user - given)
____
-Has 109 line(s). Calls functions:
+Has 103 line(s). Calls functions:
.zi-create
|-- side.zsh/.zi-any-colorify-as-uspl2
@@ -457,13 +492,13 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 99 line(s). Calls functions:
+Has 93 line(s). Calls functions:
.zi-delete
|-- side.zsh/.zi-compute-ice
+ |-- zi.zsh/+zi-prehelp-usage-message
|-- zi.zsh/.zi-any-to-user-plugin
- |-- zi.zsh/.zi-parse-opts
- `-- zi.zsh/+zi-prehelp-usage-message
+ `-- zi.zsh/.zi-parse-opts
Uses feature(s): _setopt_
@@ -481,7 +516,7 @@ ____
$1 - user/plugin
____
-Has 30 line(s). Doesn't call other functions.
+Has 28 line(s). Doesn't call other functions.
Uses feature(s): _setopt_
@@ -502,7 +537,7 @@ ____
$1 - user/plugin
____
-Has 19 line(s). Doesn't call other functions.
+Has 16 line(s). Doesn't call other functions.
Uses feature(s): _setopt_
@@ -523,7 +558,7 @@ ____
$1 - user/plugin
____
-Has 17 line(s). Doesn't call other functions.
+Has 16 line(s). Doesn't call other functions.
Uses feature(s): _setopt_
@@ -545,7 +580,7 @@ ____
$1 - user/plugin
____
-Has 28 line(s). Doesn't call other functions.
+Has 27 line(s). Doesn't call other functions.
Uses feature(s): _setopt_
@@ -569,7 +604,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 22 line(s). Calls functions:
+Has 20 line(s). Calls functions:
.zi-edit
`-- side.zsh/.zi-compute-ice
@@ -612,7 +647,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 6 line(s). Calls functions:
+Has 5 line(s). Calls functions:
.zi-find-completions-of-plugin
`-- zi.zsh/.zi-any-to-user-plugin
@@ -636,7 +671,7 @@ ____
$2 - if 1, then examine PATH, if 2, then examine FPATH
____
-Has 16 line(s). Doesn't call other functions.
+Has 15 line(s). Doesn't call other functions.
Called by:
@@ -654,7 +689,7 @@ ____
$1 - user/plugin (i.e. uspl2 format of plugin-spec)
____
-Has 36 line(s). Doesn't call other functions.
+Has 34 line(s). Doesn't call other functions.
Called by:
@@ -672,7 +707,7 @@ ____
$1 - user/plugin (i.e. uspl2 format of plugin-spec)
____
-Has 21 line(s). Calls functions:
+Has 19 line(s). Calls functions:
.zi-format-options
@@ -692,7 +727,7 @@ ____
$1 - user/plugin (i.e. uspl2 format of plugin-spec)
____
-Has 35 line(s). Doesn't call other functions.
+Has 29 line(s). Doesn't call other functions.
Uses feature(s): _setopt_
@@ -720,7 +755,7 @@ ____
$2 - readlink command (":" or "readlink")
____
-Has 22 line(s). Doesn't call other functions.
+Has 19 line(s). Doesn't call other functions.
Uses feature(s): _setopt_
@@ -758,7 +793,6 @@ Called by:
____
- ]]]
FUNCTION: .zi-get-path [[[
Returns path of given ID-string, which may be a plugin-spec
(like "user/plugin" or "user" "plugin"), an absolute path
@@ -766,7 +800,7 @@ ____
nickname (i.e. id-as'' ice-mod), or a snippet nickname.
____
-Has 8 line(s). Calls functions:
+Has 7 line(s). Calls functions:
.zi-get-path
`-- zi.zsh/.zi-get-object-path
@@ -793,7 +827,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 39 line(s). Calls functions:
+Has 37 line(s). Calls functions:
.zi-glance
|-- side.zsh/.zi-exists-physically-message
@@ -813,7 +847,7 @@ ____
User-action entry point.
____
-Has 66 line(s). Doesn't call other functions.
+Has 29 line(s). Doesn't call other functions.
Called by:
@@ -827,7 +861,7 @@ ____
FUNCTION: .zi-list-bindkeys [[[
____
-Has 44 line(s). Calls functions:
+Has 39 line(s). Calls functions:
.zi-list-bindkeys
`-- side.zsh/.zi-any-colorify-as-uspl2
@@ -939,11 +973,10 @@ Called by:
____
- ]]]
FUNCTION: .zi-recall [[[
____
-Has 38 line(s). Calls functions:
+Has 35 line(s). Calls functions:
.zi-recall
|-- side.zsh/.zi-compute-ice
@@ -966,7 +999,7 @@ ____
$1 - time spec, e.g. "1 week"
____
-Has 28 line(s). Calls functions:
+Has 23 line(s). Calls functions:
.zi-recently
`-- side.zsh/.zi-any-colorify-as-uspl2
@@ -1044,7 +1077,7 @@ ____
User-action entry point.
____
-Has 42 line(s). Calls functions:
+Has 39 line(s). Calls functions:
.zi-search-completions
`-- side.zsh/.zi-any-colorify-as-uspl2
@@ -1060,17 +1093,18 @@ Called by:
____
+ ]]]
FUNCTION: .zi-self-update [[[
Updates ZI code (does a git pull).
User-action entry point.
____
-Has 47 line(s). Calls functions:
+Has 45 line(s). Calls functions:
.zi-self-update
- |-- zi.zsh/.zi-get-mtime-into
- `-- zi.zsh/+zi-message
+ |-- zi.zsh/+zi-message
+ `-- zi.zsh/.zi-get-mtime-into
Uses feature(s): _setopt_, _source_, _zcompile_
@@ -1113,7 +1147,7 @@ ____
User-action entry point.
____
-Has 72 line(s). Calls functions:
+Has 61 line(s). Calls functions:
.zi-show-completions
`-- side.zsh/.zi-any-colorify-as-uspl2
@@ -1154,7 +1188,7 @@ ____
User-action entry point.
____
-Has 22 line(s). Calls functions:
+Has 19 line(s). Calls functions:
.zi-show-registered-plugins
`-- side.zsh/.zi-any-colorify-as-uspl2
@@ -1179,7 +1213,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 71 line(s). Calls functions:
+Has 66 line(s). Calls functions:
.zi-show-report
`-- zi.zsh/.zi-any-to-user-plugin
@@ -1203,7 +1237,7 @@ ____
User-action entry point.
____
-Has 60 line(s). Calls functions:
+Has 51 line(s). Calls functions:
.zi-show-times
`-- side.zsh/.zi-any-colorify-as-uspl2
@@ -1227,7 +1261,7 @@ ____
User-action entry point.
____
-Has 47 line(s). Calls functions:
+Has 44 line(s). Calls functions:
.zi-show-zstatus
`-- zi.zsh/+zi-message
@@ -1256,7 +1290,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 38 line(s). Calls functions:
+Has 31 line(s). Calls functions:
.zi-stress
|-- side.zsh/.zi-exists-physically-message
@@ -1281,7 +1315,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 22 line(s). Calls functions:
+Has 20 line(s). Calls functions:
.zi-uncompile-plugin
|-- side.zsh/.zi-any-colorify-as-uspl2
@@ -1307,7 +1341,7 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 46 line(s). Calls functions:
+Has 39 line(s). Calls functions:
.zi-uninstall-completions
|-- install.zsh/.zi-compinit
@@ -1344,10 +1378,9 @@ ____
$2 - plugin (only when $1 - i.e. user - given)
____
-Has 394 line(s). Calls functions:
+Has 380 line(s). Calls functions:
.zi-unload
- |-- additional.zsh/.zi-clear-debug-report
|-- side.zsh/.zi-any-colorify-as-uspl2
`-- zi.zsh/.zi-any-to-user-plugin
@@ -1355,7 +1388,6 @@ Uses feature(s): _alias_, _bindkey_, _eval_, _setopt_, _unalias_, _unfunction_,
Called by:
- additional.zsh/.zi-debug-unload
zi.zsh/zi
zi.zsh/.zi-run-task
@@ -1386,12 +1418,12 @@ ____
FUNCTION: .zi-update-in-parallel [[[
____
-Has 84 line(s). Calls functions:
+Has 75 line(s). Calls functions:
.zi-update-all-parallel
|-- side.zsh/.zi-any-colorify-as-uspl2
- |-- zi.zsh/.zi-any-to-user-plugin
- `-- zi.zsh/+zi-message
+ |-- zi.zsh/+zi-message
+ `-- zi.zsh/.zi-any-to-user-plugin
Uses feature(s): _setopt_
@@ -1414,7 +1446,7 @@ ____
$3 - plugin (only when $1 - i.e. user - given)
____
-Has 300 line(s). Calls functions:
+Has 295 line(s). Calls functions:
.zi-update-or-status
|-- install.zsh/.zi-get-latest-gh-r-url-part
@@ -1425,8 +1457,8 @@ Has 300 line(s). Calls functions:
|-- side.zsh/.zi-exists-physically-message
|-- side.zsh/.zi-store-ices
|-- side.zsh/.zi-two-paths
- |-- zi.zsh/.zi-any-to-user-plugin
|-- zi.zsh/+zi-message
+ |-- zi.zsh/.zi-any-to-user-plugin
`-- zi.zsh/.zi-set-m-func
Uses feature(s): _kill_, _read_, _setopt_, _source_, _trap_, _wait_
@@ -1451,14 +1483,14 @@ ____
User-action entry point.
____
-Has 124 line(s). Calls functions:
+Has 110 line(s). Calls functions:
.zi-update-or-status-all
|-- install.zsh/.zi-compinit
|-- side.zsh/.zi-any-colorify-as-uspl2
+ |-- zi.zsh/+zi-message
|-- zi.zsh/.zi-any-to-user-plugin
- |-- zi.zsh/.zi-get-mtime-into
- `-- zi.zsh/+zi-message
+ `-- zi.zsh/.zi-get-mtime-into
Uses feature(s): _setopt_, _source_
@@ -1479,7 +1511,7 @@ ____
$2 - snippet URL
____
-Has 34 line(s). Calls functions:
+Has 29 line(s). Calls functions:
.zi-update-or-status-snippet
|-- install.zsh/.zi-update-snippet
diff --git a/docs/zsdoc/install.zsh.adoc b/docs/zsdoc/install.zsh.adoc
index 70853ef2..64edb398 100644
--- a/docs/zsdoc/install.zsh.adoc
+++ b/docs/zsdoc/install.zsh.adoc
@@ -65,9 +65,9 @@ ____
FUNCTION: ∞zi-atclone-hook [[[
____
-Has 8 line(s). Calls functions:
+Has 20 line(s). Calls functions:
- ∞zi-atclone-hook
+ \342\210\236zi-atclone-hook
|-- side.zsh/.zi-countdown
`-- zi.zsh/@zi-substitute
@@ -84,7 +84,7 @@ ____
FUNCTION: .zi-at-eval [[[
____
-Has 5 line(s). Calls functions:
+Has 7 line(s). Calls functions:
.zi-at-eval
`-- zi.zsh/@zi-substitute
@@ -104,9 +104,9 @@ ____
FUNCTION: ∞zi-atpull-e-hook [[[
____
-Has 5 line(s). Calls functions:
+Has 18 line(s). Calls functions:
- ∞zi-atpull-e-hook
+ \342\210\236zi-atpull-e-hook
`-- side.zsh/.zi-countdown
Uses feature(s): _setopt_
@@ -121,9 +121,9 @@ ____
FUNCTION: ∞zi-atpull-hook [[[
____
-Has 5 line(s). Calls functions:
+Has 18 line(s). Calls functions:
- ∞zi-atpull-hook
+ \342\210\236zi-atpull-hook
`-- side.zsh/.zi-countdown
Uses feature(s): _setopt_
@@ -166,9 +166,9 @@ ____
FUNCTION: ∞zi-compile-plugin-hook [[[
____
-Has 19 line(s). Calls functions:
+Has 20 line(s). Calls functions:
- ∞zi-compile-plugin-hook
+ \342\210\236zi-compile-plugin-hook
Uses feature(s): _setopt_
@@ -233,7 +233,7 @@ ____
Has 27 line(s). Calls functions:
- ∞zi-cp-hook
+ \342\210\236zi-cp-hook
`-- zi.zsh/@zi-substitute
Uses feature(s): _setopt_
@@ -276,7 +276,7 @@ ____
This is used to provide a layer of support for Oh-My-Zsh and Prezto.
____
-Has 323 line(s). Calls functions:
+Has 354 line(s). Calls functions:
.zi-download-snippet
|-- side.zsh/.zi-store-ices
@@ -301,9 +301,9 @@ ____
Has 30 line(s). Calls functions:
.zi-extract
- |-- ziextract
- | `-- zi.zsh/+zi-message
- `-- zi.zsh/+zi-message
+ |-- zi.zsh/+zi-message
+ `-- ziextract
+ `-- zi.zsh/+zi-message
Uses feature(s): _setopt_
@@ -349,9 +349,9 @@ ____
FUNCTION: ∞zi-extract-hook [[[
____
-Has 8 line(s). Calls functions:
+Has 7 line(s). Calls functions:
- ∞zi-extract-hook
+ \342\210\236zi-extract-hook
`-- zi.zsh/@zi-substitute
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
@@ -435,10 +435,10 @@ ____
Has 195 line(s). Calls functions:
.zi-get-package
- |-- ziextract
- | `-- zi.zsh/+zi-message
|-- zi.zsh/+zi-message
- `-- zi.zsh/@zi-substitute
+ |-- zi.zsh/@zi-substitute
+ `-- ziextract
+ `-- zi.zsh/+zi-message
Uses feature(s): _eval_, _setopt_, _trap_
@@ -487,8 +487,8 @@ Has 61 line(s). Calls functions:
.zi-install-completions
|-- side.zsh/.zi-any-colorify-as-uspl2
|-- side.zsh/.zi-exists-physically-message
- |-- zi.zsh/.zi-any-to-user-plugin
- `-- zi.zsh/+zi-message
+ |-- zi.zsh/+zi-message
+ `-- zi.zsh/.zi-any-to-user-plugin
Uses feature(s): _setopt_
@@ -506,9 +506,9 @@ ____
FUNCTION: ∞zi-make-ee-hook [[[
____
-Has 9 line(s). Calls functions:
+Has 10 line(s). Calls functions:
- ∞zi-make-ee-hook
+ \342\210\236zi-make-ee-hook
|-- side.zsh/.zi-countdown
`-- zi.zsh/@zi-substitute
@@ -522,9 +522,9 @@ ____
FUNCTION: ∞zi-make-e-hook [[[
____
-Has 9 line(s). Calls functions:
+Has 11 line(s). Calls functions:
- ∞zi-make-e-hook
+ \342\210\236zi-make-e-hook
|-- side.zsh/.zi-countdown
`-- zi.zsh/@zi-substitute
@@ -535,13 +535,12 @@ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
____
- ]]]
FUNCTION: ∞zi-make-hook [[[
____
Has 10 line(s). Calls functions:
- ∞zi-make-hook
+ \342\210\236zi-make-hook
|-- side.zsh/.zi-countdown
`-- zi.zsh/@zi-substitute
@@ -577,6 +576,7 @@ zimv
____
+ ]]]
FUNCTION zimv [[[
____
@@ -595,9 +595,9 @@ ____
FUNCTION: ∞zi-mv-hook [[[
____
-Has 27 line(s). Calls functions:
+Has 25 line(s). Calls functions:
- ∞zi-mv-hook
+ \342\210\236zi-mv-hook
`-- zi.zsh/@zi-substitute
Uses feature(s): _setopt_
@@ -632,9 +632,9 @@ ____
FUNCTION: ∞zi-ps-on-update-hook [[[
____
-Has 18 line(s). Calls functions:
+Has 17 line(s). Calls functions:
- ∞zi-ps-on-update-hook
+ \342\210\236zi-ps-on-update-hook
`-- zi.zsh/+zi-message
Uses feature(s): _eval_
@@ -652,7 +652,7 @@ ____
Has 79 line(s). Calls functions:
- ∞zi-reset-hook
+ \342\210\236zi-reset-hook
`-- zi.zsh/+zi-message
Uses feature(s): _eval_
@@ -664,7 +664,6 @@ Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
____
- ]]]
FUNCTION: .zi-setup-plugin-dir [[[
Clones given plugin into PLUGIN_DIR. Supports multiple
sites (respecting `from' and `proto' ice modifiers).
@@ -674,22 +673,21 @@ ____
$2 - plugin
____
-Has 198 line(s). Calls functions:
+Has 209 line(s). Calls functions:
.zi-setup-plugin-dir
|-- side.zsh/.zi-any-colorify-as-uspl2
|-- side.zsh/.zi-store-ices
- |-- ziextract
- | `-- zi.zsh/+zi-message
+ |-- zi.zsh/+zi-message
|-- zi.zsh/.zi-get-object-path
- `-- zi.zsh/+zi-message
+ `-- ziextract
+ `-- zi.zsh/+zi-message
Uses feature(s): _setopt_, _trap_
Called by:
autoload.zsh/.zi-update-or-status
- zi.zsh/.zi-load
.zi-update-snippet
~~~~~~~~~~~~~~~~~~
@@ -703,8 +701,8 @@ ____
Has 76 line(s). Calls functions:
.zi-update-snippet
- |-- zi.zsh/.zi-get-object-path
|-- zi.zsh/+zi-message
+ |-- zi.zsh/.zi-get-object-path
`-- zi.zsh/.zi-pack-ice
Uses feature(s): _eval_, _setopt_
diff --git a/docs/zsdoc/side.zsh.adoc b/docs/zsdoc/side.zsh.adoc
index 15d3eca2..b9e49a2f 100644
--- a/docs/zsdoc/side.zsh.adoc
+++ b/docs/zsdoc/side.zsh.adoc
@@ -188,9 +188,9 @@ ____
Has 23 line(s). Calls functions:
.zi-exists-physically-message
+ |-- zi.zsh/+zi-message
|-- zi.zsh/.zi-any-to-pid
- |-- zi.zsh/.zi-any-to-user-plugin
- `-- zi.zsh/+zi-message
+ `-- zi.zsh/.zi-any-to-user-plugin
Uses feature(s): _setopt_
diff --git a/docs/zsdoc/zi.zsh.adoc b/docs/zsdoc/zi.zsh.adoc
index 3186e3a8..42f111fb 100644
--- a/docs/zsdoc/zi.zsh.adoc
+++ b/docs/zsdoc/zi.zsh.adoc
@@ -79,6 +79,7 @@ FUNCTIONS
zpcompinit
@zsh-plugin-run-on-unload
@zsh-plugin-run-on-update
+ zt
AUTOLOAD add-zsh-hook
AUTOLOAD compinit
AUTOLOAD is-at-least
@@ -90,14 +91,14 @@ DETAILS
Script Body
~~~~~~~~~~~
-Has 212 line(s). Calls functions:
+Has 219 line(s). Calls functions:
Script-Body
+ |-- +zi-message
+ |-- @zi-register-hook
|-- add-zsh-hook
|-- autoload.zsh/.zi-module
- |-- is-at-least
- |-- +zi-message
- `-- @zi-register-hook
+ `-- is-at-least
Uses feature(s): _add-zsh-hook_, _alias_, _autoload_, _export_, _is-at-least_, _setopt_, _source_, _zmodload_, _zstyle_
@@ -116,8 +117,8 @@ Has 3 line(s). Calls functions:
@autoload
`-- :zi-tmp-subst-autoload
- |-- is-at-least
- `-- +zi-message
+ |-- +zi-message
+ `-- is-at-least
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
@@ -148,18 +149,19 @@ ____
arguments, has completion.
____
-Has 555 line(s). Calls functions:
+Has 561 line(s). Calls functions:
zi
- |-- additional.zsh/.zi-clear-debug-report
- |-- additional.zsh/.zi-debug-start
- |-- additional.zsh/.zi-debug-stop
- |-- additional.zsh/.zi-debug-unload
+ |-- +zi-message
+ |-- +zi-prehelp-usage-message
+ | `-- +zi-message
+ |-- autoload.zsh/.zi-analytics-menu
|-- autoload.zsh/.zi-cdisable
|-- autoload.zsh/.zi-cenable
|-- autoload.zsh/.zi-clear-completions
- |-- autoload.zsh/.zi-compiled
|-- autoload.zsh/.zi-compile-uncompile-all
+ |-- autoload.zsh/.zi-compiled
+ |-- autoload.zsh/.zi-control-menu
|-- autoload.zsh/.zi-help
|-- autoload.zsh/.zi-list-bindkeys
|-- autoload.zsh/.zi-list-compdef-replay
@@ -184,16 +186,14 @@ Has 555 line(s). Calls functions:
|-- install.zsh/.zi-compile-plugin
|-- install.zsh/.zi-compinit
|-- install.zsh/.zi-forget-completion
- |-- install.zsh/.zi-install-completions
- |-- +zi-message
- `-- +zi-prehelp-usage-message
- `-- +zi-message
+ `-- install.zsh/.zi-install-completions
Uses feature(s): _autoload_, _compinit_, _eval_, _setopt_, _source_
Called by:
zinit
+ zt
.zi-add-fpath
~~~~~~~~~~~~~
@@ -458,8 +458,6 @@ Has 4 line(s). Calls functions:
Called by:
.zi-load-plugin
- additional.zsh/.zi-debug-start
- additional.zsh/.zi-debug-stop
.zi-diff-env
~~~~~~~~~~~~
@@ -705,12 +703,11 @@ ____
$2 - plugin name, if the third format is used
____
-Has 92 line(s). Calls functions:
+Has 94 line(s). Calls functions:
.zi-load
- |-- install.zsh/.zi-get-package
- |-- install.zsh/.zi-setup-plugin-dir
- `-- +zi-deploy-message
+ |-- +zi-deploy-message
+ `-- install.zsh/.zi-get-package
Uses feature(s): _eval_, _setopt_, _source_, _zle_
@@ -718,7 +715,6 @@ Called by:
.zi-load-object
.zi-run-task
- additional.zsh/.zi-service
.zi-load-ices
~~~~~~~~~~~~~
@@ -771,8 +767,8 @@ Has 126 line(s). Calls functions:
.zi-load-plugin
`-- :zi-tmp-subst-autoload
- |-- is-at-least
- `-- +zi-message
+ |-- +zi-message
+ `-- is-at-least
Uses feature(s): _eval_, _setopt_, _source_, _unfunction_, _zle_
@@ -795,9 +791,9 @@ ____
Has 203 line(s). Calls functions:
.zi-load-snippet
- |-- install.zsh/.zi-download-snippet
|-- +zi-deploy-message
- `-- +zi-message
+ |-- +zi-message
+ `-- install.zsh/.zi-download-snippet
Uses feature(s): _autoload_, _eval_, _setopt_, _source_, _unfunction_, _zparseopts_, _zstyle_
@@ -807,7 +803,6 @@ Called by:
.zi-load-object
.zi-load
.zi-run-task
- additional.zsh/.zi-service
.zi-main-message-formatter
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -845,9 +840,6 @@ Called by:
.zi-set-m-func
:zi-tmp-subst-autoload
zi
- additional.zsh/.zi-debug-start
- additional.zsh/.zi-debug-unload
- additional.zsh/:zi-tmp-subst-source
autoload.zsh/.zi-build-module
autoload.zsh/.zi-cd
autoload.zsh/.zi-self-update
@@ -887,15 +879,16 @@ Has 1 line(s). Calls functions:
zinit
`-- zi
- |-- additional.zsh/.zi-clear-debug-report
- |-- additional.zsh/.zi-debug-start
- |-- additional.zsh/.zi-debug-stop
- |-- additional.zsh/.zi-debug-unload
+ |-- +zi-message
+ |-- +zi-prehelp-usage-message
+ | `-- +zi-message
+ |-- autoload.zsh/.zi-analytics-menu
|-- autoload.zsh/.zi-cdisable
|-- autoload.zsh/.zi-cenable
|-- autoload.zsh/.zi-clear-completions
- |-- autoload.zsh/.zi-compiled
|-- autoload.zsh/.zi-compile-uncompile-all
+ |-- autoload.zsh/.zi-compiled
+ |-- autoload.zsh/.zi-control-menu
|-- autoload.zsh/.zi-help
|-- autoload.zsh/.zi-list-bindkeys
|-- autoload.zsh/.zi-list-compdef-replay
@@ -920,10 +913,7 @@ Has 1 line(s). Calls functions:
|-- install.zsh/.zi-compile-plugin
|-- install.zsh/.zi-compinit
|-- install.zsh/.zi-forget-completion
- |-- install.zsh/.zi-install-completions
- |-- +zi-message
- `-- +zi-prehelp-usage-message
- `-- +zi-message
+ `-- install.zsh/.zi-install-completions
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
@@ -1308,8 +1298,8 @@ ____
Has 111 line(s). Calls functions:
:zi-tmp-subst-autoload
- |-- is-at-least
- `-- +zi-message
+ |-- +zi-message
+ `-- is-at-least
Uses feature(s): _autoload_, _eval_, _is-at-least_, _setopt_, _zparseopts_
@@ -1374,7 +1364,6 @@ Uses feature(s): _setopt_, _unfunction_
Called by:
.zi-load-plugin
- additional.zsh/.zi-debug-stop
.zi-tmp-subst-on
~~~~~~~~~~~~~~~~
@@ -1395,7 +1384,6 @@ Uses feature(s): _source_
Called by:
.zi-load-plugin
- additional.zsh/.zi-debug-start
:zi-tmp-subst-zle
~~~~~~~~~~~~~~~~~
@@ -1524,6 +1512,58 @@ Has 2 line(s). Calls functions:
Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
+zt
+~~
+
+____
+
+ ]]]
+ FUNCTION: zt. [[[
+ Common ICE modifier to simplify Turbo mode.
+____
+
+Has 1 line(s). Calls functions:
+
+ zt
+ `-- zi
+ |-- +zi-message
+ |-- +zi-prehelp-usage-message
+ | `-- +zi-message
+ |-- autoload.zsh/.zi-analytics-menu
+ |-- autoload.zsh/.zi-cdisable
+ |-- autoload.zsh/.zi-cenable
+ |-- autoload.zsh/.zi-clear-completions
+ |-- autoload.zsh/.zi-compile-uncompile-all
+ |-- autoload.zsh/.zi-compiled
+ |-- autoload.zsh/.zi-control-menu
+ |-- autoload.zsh/.zi-help
+ |-- autoload.zsh/.zi-list-bindkeys
+ |-- autoload.zsh/.zi-list-compdef-replay
+ |-- autoload.zsh/.zi-ls
+ |-- autoload.zsh/.zi-module
+ |-- autoload.zsh/.zi-recently
+ |-- autoload.zsh/.zi-search-completions
+ |-- autoload.zsh/.zi-self-update
+ |-- autoload.zsh/.zi-show-all-reports
+ |-- autoload.zsh/.zi-show-completions
+ |-- autoload.zsh/.zi-show-debug-report
+ |-- autoload.zsh/.zi-show-registered-plugins
+ |-- autoload.zsh/.zi-show-report
+ |-- autoload.zsh/.zi-show-times
+ |-- autoload.zsh/.zi-show-zstatus
+ |-- autoload.zsh/.zi-uncompile-plugin
+ |-- autoload.zsh/.zi-uninstall-completions
+ |-- autoload.zsh/.zi-unload
+ |-- autoload.zsh/.zi-update-or-status
+ |-- autoload.zsh/.zi-update-or-status-all
+ |-- compinit
+ |-- install.zsh/.zi-compile-plugin
+ |-- install.zsh/.zi-compinit
+ |-- install.zsh/.zi-forget-completion
+ `-- install.zsh/.zi-install-completions
+
+Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).
+
add-zsh-hook
~~~~~~~~~~~~
diff --git a/lib/_zi b/lib/_zi
index 1aead300..c64d9aeb 100755
--- a/lib/_zi
+++ b/lib/_zi
@@ -6,130 +6,118 @@ local curcontext="$curcontext" state state_descr line ret=1
local -a expl
typeset -a commands
-commands=(
- analytics:'Show ZI Analytics'
- control:'ZI Control commands'
- zstatus:'Checks ZI Status'
- times:'Statistics on plugin loading times'
- self-update:'Updates and Compile ZI'
- help:'Usage Information'
- man:'Manpage'
- load:'Load plugin'
- delete:'Delete plugin'
- unload:'Unload plugin'
- snippet:"Source (or add to PATH with --command) local or remote file (-f: force - don't use cache)"
- update:'Git update plugin (or all plugins and snippets if --all passed)'
- status:'Git status for plugin (or all plugins if --all passed)'
- report:'Show plugin'"'"'s report (or all plugins'"'"' if --all passed)'
- loaded:'Show what plugins are loaded'
- list:'Show what plugins are loaded'
- ls:'List snippets in formatted and colorized manner'
- cd:"Go into plugin's directory"
- create:'Create plugin (also together with Github repository)'
- edit:"Edit plugin's file with \$EDITOR"
- glance:"Look at plugin's source (pygmentize, {,source-}highlight)"
- stress:'Test plugin for compatibility with set of options'
- changes:"View plugin's git log"
- recently:"Show plugins that changed recently, argument is e.g. 1 month 2 days"
- clist:'List completions in use'
- cclear:'Clear stray and improper completions'
- completions:'List completions in use'
- cdisable:'Disable completion'
- cenable:'Enable completion'
- creinstall:'Install completions for plugin'
- cuninstall:'Uninstall completions for plugin'
- csearch:'Search for available completions from any plugin'
- compinit:'Refresh installed completions'
- dtrace:"Start tracking what's going on in session"
- dstart:"Start tracking what's going on in session"
- dstop:"Stop tracking what's going on in session"
- dunload:'Revert changes recorded between dstart and dstop'
- dreport:"Report what was going on in session"
- dclear:'Clear report of what was going on in session'
- compile:'Compile plugin (or all plugins if --all passed)'
- uncompile:'Remove compiled version of plugin (or of all plugins if --all passed)'
- compiled:'Show which plugins are compiled'
- cdlist:'Show compdef replay list'
- cdreplay:'Replay compdefs (to be done after compinit)'
- cdclear:'Clear compdef replay list'
- srv:'Control a service, command can be: stop,start,restart,next,quit; `next'' moves the service to another Zshell'
- recall:'Fetch saved ice modifiers and construct `zi ice ...'' command'
- env-whitelist:'Allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose'
- bindkeys:'Lists bindkeys set up by each plugin'
- module:'Manage binary Zsh module shipped with ZI, see `zi module help'''
- run:"Execute code inside plugin's folder"
- {add-fpath}:'Add plugin folder to $fpath'
+commands=(
+ analytics:'Show ❮ ZI ❯ Analytics'
+ control:'❮ ZI ❯ Control commands'
+ zstatus:'Checks ❮ ZI ❯ Status'
+ times:'Statistics on plugin loading times'
+ self-update:'Updates and Compile ZI'
+ help:'Usage Information'
+ man:'Manpage'
+ load:'Load plugin'
+ delete:'Delete plugin'
+ unload:'Unload plugin'
+ snippet:"Source (or add to PATH with --command) local or remote file (-f: force - don't use cache)"
+ update:'Git update plugin (or all plugins and snippets if --all passed)'
+ status:'Git status for plugin (or all plugins if --all passed)'
+ report:'Show plugin'"'"'s report (or all plugins'"'"' if --all passed)'
+ loaded:'Show what plugins are loaded'
+ list:'Show what plugins are loaded'
+ ls:'List snippets in formatted and colorized manner'
+ cd:"Go into plugin's directory"
+ create:'Create plugin (also together with Github repository)'
+ edit:"Edit plugin's file with \$EDITOR"
+ glance:"Look at plugin's source (pygmentize, {,source-}highlight)"
+ stress:'Test plugin for compatibility with set of options'
+ changes:"View plugin's git log"
+ recently:"Show plugins that changed recently, argument is e.g. 1 month 2 days"
+ clist:'List completions in use'
+ cclear:'Clear stray and improper completions'
+ completions:'List completions in use'
+ cdisable:'Disable completion'
+ cenable:'Enable completion'
+ creinstall:'Install completions for plugin'
+ cuninstall:'Uninstall completions for plugin'
+ csearch:'Search for available completions from any plugin'
+ compinit:'Refresh installed completions'
+ dtrace:"Start tracking what's going on in session"
+ dstart:"Start tracking what's going on in session"
+ dstop:"Stop tracking what's going on in session"
+ dunload:'Revert changes recorded between dstart and dstop'
+ dreport:"Report what was going on in session"
+ dclear:'Clear report of what was going on in session'
+ compile:'Compile plugin (or all plugins if --all passed)'
+ uncompile:'Remove compiled version of plugin (or of all plugins if --all passed)'
+ compiled:'Show which plugins are compiled'
+ cdlist:'Show compdef replay list'
+ cdreplay:'Replay compdefs (to be done after compinit)'
+ cdclear:'Clear compdef replay list'
+ srv:'Control a service, command can be: stop,start,restart,next,quit; `next'' moves the service to another Zshell'
+ recall:'Fetch saved ice modifiers and construct `zi ice ...'' command'
+ env-whitelist:'Allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose'
+ bindkeys:'Lists bindkeys set up by each plugin'
+ module:'Manage binary Zsh module shipped with ZI, see `zi module help'''
+ run:"Execute code inside plugin's folder"
+ {add-fpath}:'Add plugin folder to $fpath'
)
_arguments -C \
- '1: :->command'\
- '*: :->argument' && ret=0
+ '1: :->command'\
+ '*: :->argument' && ret=0
case $state in
- command)
- _describe -t commands "ZI command" commands && ret=0
- ;;
-
+ command)
+ _describe -t commands "❮ ZI ❯ command" commands && ret=0
+ ;;
argument)
- case $words[2] in
- help)
- _message "Hit enter to get usage information" && ret=0
- ;;
-
- control)
- _message "Hit enter to get commands list" && ret=0
- ;;
-
- analytics)
- _message "Hit enter to show commands for stats" && ret=0
- ;;
-
- man)
+ case $words[2] in
+ help)
+ _message "Hit enter to get usage information" && ret=0
+ ;;
+ control)
+ _message "Hit enter to get commands list" && ret=0
+ ;;
+ analytics)
+ _message "Hit enter to show commands for stats" && ret=0
+ ;;
+ man)
_message "Hit enter to view manual" && ret=0
;;
-
zstatus)
_message "Hit enter to get overall status information" && ret=0
;;
-
times)
_message "Hit enter to get plugin load time statistics" && ret=0
;;
-
load|light)
typeset -a plugins
plugins=( "${ZI[PLUGINS_DIR]}"/*(N:t) )
plugins=( "${plugins[@]//---//}" )
plugins=( "${plugins[@]:#_local/zi}" )
plugins=( "${plugins[@]:#custom}" )
-
_alternative \
'plugins:-- Plugin --:compadd -a - plugins' \
'directories:-- Directory --:_directories' && \
ret=0
;;
-
run|add-fpath)
typeset -a plugins
plugins=( "${ZI[PLUGINS_DIR]}"/*(N:t) )
plugins=( "${plugins[@]//---//}" )
plugins=( "${plugins[@]:#_local/zi}" )
plugins=( "${plugins[@]:#custom}" )
-
local -a opts
if [[ $words[2] = run ]]; then
opts=( -l )
else
opts=( -f --front )
fi
-
_alternative \
'plugins:-- Plugin --:compadd -a - plugins' \
'directories:-- Directory --:_directories' \
'opts:-- Option --:compadd -a - opts' && \
ret=0
;;
-
compile|stress|edit|glance|recall|update|status|cd|changes|delete)
# Plugins
typeset -a plugins
@@ -137,29 +125,24 @@ case $state in
plugins=( "${plugins[@]//---//}" )
plugins=( "${plugins[@]:#_local/zi}" )
plugins=( "${plugins[@]:#custom}" )
-
# Snippets
local -a snippets snippets_alreadyld
local sni
-
snippets=( "${ZI[SNIPPETS_DIR]}"/**/._zi(D/:h) )
snippets=( ${snippets[@]#${ZI[SNIPPETS_DIR]}/} )
snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} )
snippets=( ${snippets[@]/--//} )
-
for sni ( ${snippets[@]} ) {
if [[ -n ${ZI_SNIPPETS[$sni]} ]]; then
snippets_alreadyld+=( $sni )
snippets=( ${snippets[@]:#$sni} )
fi
}
-
_alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' \
'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \
'plugins:-- Plugin --:compadd -a - plugins' && \
ret=0
;;
-
unload|report)
typeset -a plugins absolute normal
plugins=( "${ZI_REGISTERED_PLUGINS[@]:#_local/zi}" )
@@ -169,28 +152,22 @@ case $state in
local hm="${HOME%/}"
absolute=( "${absolute[@]/$hm/HOME}" )
plugins=( $normal $absolute )
-
_wanted plugins expl "-- Plugin --" \
compadd "$@" -a - plugins && \
ret=0
;;
-
all-reports)
_message "Hit enter to get all reports (for all loaded plugins)" && ret=0
;;
-
loaded|list)
_message "Hit enter or give part of plugin name" && ret=0
;;
-
clist|completions)
_message "Hit enter to get list of completions" && ret=0
;;
-
cclear)
_message "Hit enter to clear stray and improper completions" && ret=0
;;
-
cdisable)
# Find enabled completions
typeset -a completions
@@ -200,7 +177,6 @@ case $state in
compadd "$@" -a - completions && \
ret=0
;;
-
cenable)
# Find disabled
typeset -a completions
@@ -209,7 +185,6 @@ case $state in
compadd "$@" -a - completions && \
ret=0
;;
-
creinstall)
# Complete only plugins that have any completions
# We must iterate each plugin to check
@@ -231,7 +206,6 @@ case $state in
compadd "$@" -a - plugins && \
ret=0
;;
-
cuninstall)
# We must iterate each plugin and check if
# it has completions that are installed
@@ -257,61 +231,48 @@ case $state in
compadd "$@" -a - plugins && \
ret=0
;;
-
compinit)
_message "Hit enter to refresh completion system" && ret=0
;;
-
snippet)
local -a snippets snippets_alreadyld
local sni
-
snippets=( "${ZI[SNIPPETS_DIR]}"/**/._zi(D/:h) )
snippets=( ${snippets[@]#${ZI[SNIPPETS_DIR]}/} )
snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} )
snippets=( ${snippets[@]/--//} )
-
for sni ( ${snippets[@]} ) {
if [[ -n ${ZI_SNIPPETS[$sni]} ]]; then
snippets_alreadyld+=( $sni )
snippets=( ${snippets[@]:#$sni} )
fi
}
-
_alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' \
'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \
'files:-- File --:_files' && \
ret=0
;;
-
dstart|dtrace)
_message "Hit enter to start tracking this session" && ret=0
;;
-
dstop)
_message "Hit enter to stop tracking this session" && ret=0
;;
-
dunload)
_message "Hit enter to revert changes recorded between dstart and dstop" && ret=0
;;
-
dreport)
_message "Hit enter to show report of what was going on in session" && ret=0
;;
-
dclear)
_message "Hit enter to clear report of what was going on in session" && ret=0
;;
-
compile-all)
_message 'Hit enter to compile all downloaded plugins' && ret=0
;;
-
uncompile)
typeset -a plugins
plugins=( "${ZI[PLUGINS_DIR]}"/*(N) )
-
typeset -a show_plugins p matches
for p in "${plugins[@]}"; do
matches=( $p/*.zwc(N) )
@@ -323,32 +284,25 @@ case $state in
show_plugins+=( "$p" )
fi
done
-
_wanted show_plugins expl "-- Plugin --" \
compadd "$@" -a - show_plugins && \
ret=0
;;
-
uncompile-all)
_message 'Hit enter remove compiled versions of all downloaded plugins' && ret=0
;;
-
compiled)
_message 'Hit enter to get list of compiled plugins' && ret=0
;;
-
cdlist)
_message 'Hit enter to show compdef replay list' && ret=0
;;
-
cdreplay)
_message 'Hit enter to replay recorded compdefs' && ret=0
;;
-
cdclear)
_message 'Hit enter to clear compdef replay list' && ret=0
;;
-
recently)
typeset -a timespecs
timespecs=(
@@ -358,11 +312,9 @@ case $state in
)
_describe -t timespecs "Time spec" timespecs && ret=0
;;
-
create)
_message 'Plugin spec or just enter, to create new plugin' && ret=0
;;
-
env-whitelist)
_wanted plugins expl "-- Parameter To White List During Any Plugin Unload --" \
_parameters && ret=0
@@ -373,4 +325,4 @@ case $state in
esac
esac
-return $ret
\ No newline at end of file
+return $ret
diff --git a/lib/templates/p10k b/lib/templates/p10k
new file mode 100755
index 00000000..65cc801b
--- /dev/null
+++ b/lib/templates/p10k
@@ -0,0 +1,1618 @@
+# Generated by Powerlevel10k configuration wizard on 2021-11-27 at 23:27 GMT.
+# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 54401.
+# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 24h time,
+# 2 lines, disconnected, no frame, compact, many icons, concise, transient_prompt,
+# instant_prompt=quiet.
+# Type `p10k configure` to generate another config.
+#
+# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
+# your own config based on it.
+#
+# Tip: Looking for a nice color? Here's a one-liner to print colormap.
+#
+# for i in {0..255}; do print -Pn "%K{$i} %k%F{$i}${(l:3::0:)i}%f " ${${(M)$((i%6)):#3}:+$'\n'}; done
+
+# Temporarily change options.
+'builtin' 'local' '-a' 'p10k_config_opts'
+[[ ! -o 'aliases' ]] || p10k_config_opts+=('aliases')
+[[ ! -o 'sh_glob' ]] || p10k_config_opts+=('sh_glob')
+[[ ! -o 'no_brace_expand' ]] || p10k_config_opts+=('no_brace_expand')
+'builtin' 'setopt' 'no_aliases' 'no_sh_glob' 'brace_expand'
+
+() {
+ emulate -L zsh -o extended_glob
+
+ # Unset all configuration options. This allows you to apply configuration changes without
+ # restarting zsh. Edit ~/.p10k.zsh and type `source ~/.p10k.zsh`.
+ unset -m '(POWERLEVEL9K_*|DEFAULT_USER)~POWERLEVEL9K_GITSTATUS_DIR'
+
+ # Zsh >= 5.1 is required.
+ autoload -Uz is-at-least && is-at-least 5.1 || return
+
+ # The list of segments shown on the left. Fill it with the most important segments.
+ typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
+ # =========================[ Line #1 ]=========================
+ os_icon # os identifier
+ dir # current directory
+ vcs # git status
+ # =========================[ Line #2 ]=========================
+ newline # \n
+ prompt_char # prompt symbol
+ )
+
+ # The list of segments shown on the right. Fill it with less important segments.
+ # Right prompt on the last prompt line (where you are typing your commands) gets
+ # automatically hidden when the input line reaches it. Right prompt above the
+ # last prompt line gets hidden if it would overlap with left prompt.
+ typeset -g POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(
+ # =========================[ Line #1 ]=========================
+ status # exit code of the last command
+ command_execution_time # duration of the last command
+ background_jobs # presence of background jobs
+ direnv # direnv status (https://direnv.net/)
+ asdf # asdf version manager (https://github.com/asdf-vm/asdf)
+ virtualenv # python virtual environment (https://docs.python.org/3/library/venv.html)
+ anaconda # conda environment (https://conda.io/)
+ pyenv # python environment (https://github.com/pyenv/pyenv)
+ goenv # go environment (https://github.com/syndbg/goenv)
+ nodenv # node.js version from nodenv (https://github.com/nodenv/nodenv)
+ nvm # node.js version from nvm (https://github.com/nvm-sh/nvm)
+ nodeenv # node.js environment (https://github.com/ekalinin/nodeenv)
+ # node_version # node.js version
+ # go_version # go version (https://golang.org)
+ # rust_version # rustc version (https://www.rust-lang.org)
+ # dotnet_version # .NET version (https://dotnet.microsoft.com)
+ # php_version # php version (https://www.php.net/)
+ # laravel_version # laravel php framework version (https://laravel.com/)
+ # java_version # java version (https://www.java.com/)
+ # package # name@version from package.json (https://docs.npmjs.com/files/package.json)
+ rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
+ rvm # ruby version from rvm (https://rvm.io)
+ fvm # flutter version management (https://github.com/leoafarias/fvm)
+ luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
+ jenv # java version from jenv (https://github.com/jenv/jenv)
+ plenv # perl version from plenv (https://github.com/tokuhirom/plenv)
+ phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
+ scalaenv # scala version from scalaenv (https://github.com/scalaenv/scalaenv)
+ haskell_stack # haskell version from stack (https://haskellstack.org/)
+ kubecontext # current kubernetes context (https://kubernetes.io/)
+ terraform # terraform workspace (https://www.terraform.io)
+ # terraform_version # terraform version (https://www.terraform.io)
+ aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
+ aws_eb_env # aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/)
+ azure # azure account name (https://docs.microsoft.com/en-us/cli/azure)
+ gcloud # google cloud cli account and project (https://cloud.google.com/)
+ google_app_cred # google application credentials (https://cloud.google.com/docs/authentication/production)
+ toolbox # toolbox name (https://github.com/containers/toolbox)
+ context # user@hostname
+ nordvpn # nordvpn connection status, linux only (https://nordvpn.com/)
+ ranger # ranger shell (https://github.com/ranger/ranger)
+ nnn # nnn shell (https://github.com/jarun/nnn)
+ xplr # xplr shell (https://github.com/sayanarijit/xplr)
+ vim_shell # vim shell indicator (:sh)
+ midnight_commander # midnight commander shell (https://midnight-commander.org/)
+ nix_shell # nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html)
+ # vpn_ip # virtual private network indicator
+ # load # CPU load
+ # disk_usage # disk usage
+ # ram # free RAM
+ # swap # used swap
+ todo # todo items (https://github.com/todotxt/todo.txt-cli)
+ timewarrior # timewarrior tracking status (https://timewarrior.net/)
+ taskwarrior # taskwarrior task count (https://taskwarrior.org/)
+ time # current time
+ # =========================[ Line #2 ]=========================
+ newline
+ # ip # ip address and bandwidth usage for a specified network interface
+ # public_ip # public IP address
+ # proxy # system-wide http/https/ftp proxy
+ # battery # internal battery
+ # wifi # wifi speed
+ # example # example user-defined segment (see prompt_example function below)
+ )
+
+ # Defines character set used by powerlevel10k. It's best to let `p10k configure` set it for you.
+ typeset -g POWERLEVEL9K_MODE=nerdfont-complete
+ # When set to `moderate`, some icons will have an extra space after them. This is meant to avoid
+ # icon overlap when using non-monospace fonts. When set to `none`, spaces are not added.
+ typeset -g POWERLEVEL9K_ICON_PADDING=none
+
+ # Basic style options that define the overall look of your prompt. You probably don't want to
+ # change them.
+ typeset -g POWERLEVEL9K_BACKGROUND= # transparent background
+ typeset -g POWERLEVEL9K_{LEFT,RIGHT}_{LEFT,RIGHT}_WHITESPACE= # no surrounding whitespace
+ typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SUBSEGMENT_SEPARATOR=' ' # separate segments with a space
+ typeset -g POWERLEVEL9K_{LEFT,RIGHT}_SEGMENT_SEPARATOR= # no end-of-line symbol
+
+ # When set to true, icons appear before content on both sides of the prompt. When set
+ # to false, icons go after content. If empty or not set, icons go before content in the left
+ # prompt and after content in the right prompt.
+ #
+ # You can also override it for a specific segment:
+ #
+ # POWERLEVEL9K_STATUS_ICON_BEFORE_CONTENT=false
+ #
+ # Or for a specific segment in specific state:
+ #
+ # POWERLEVEL9K_DIR_NOT_WRITABLE_ICON_BEFORE_CONTENT=false
+ typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true
+
+ # Add an empty line before each prompt.
+ typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false
+
+ # Connect left prompt lines with these symbols.
+ typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX=
+ typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_PREFIX=
+ typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX=
+ # Connect right prompt lines with these symbols.
+ typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_SUFFIX=
+ typeset -g POWERLEVEL9K_MULTILINE_NEWLINE_PROMPT_SUFFIX=
+ typeset -g POWERLEVEL9K_MULTILINE_LAST_PROMPT_SUFFIX=
+
+ # The left end of left prompt.
+ typeset -g POWERLEVEL9K_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=
+ # The right end of right prompt.
+ typeset -g POWERLEVEL9K_RIGHT_PROMPT_LAST_SEGMENT_END_SYMBOL=
+
+ # Ruler, a.k.a. the horizontal line before each prompt. If you set it to true, you'll
+ # probably want to set POWERLEVEL9K_PROMPT_ADD_NEWLINE=false above and
+ # POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' ' below.
+ typeset -g POWERLEVEL9K_SHOW_RULER=false
+ typeset -g POWERLEVEL9K_RULER_CHAR='─' # reasonable alternative: '·'
+ typeset -g POWERLEVEL9K_RULER_FOREGROUND=242
+
+ # Filler between left and right prompt on the first prompt line. You can set it to '·' or '─'
+ # to make it easier to see the alignment between left and right prompt and to separate prompt
+ # from command output. It serves the same purpose as ruler (see above) without increasing
+ # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false
+ # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact
+ # prompt.
+ typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR=' '
+ if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then
+ # The color of the filler.
+ typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=242
+ # Add a space between the end of left prompt and the filler.
+ typeset -g POWERLEVEL9K_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=' '
+ # Add a space between the filler and the start of right prompt.
+ typeset -g POWERLEVEL9K_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL=' '
+ # Start filler from the edge of the screen if there are no left segments on the first line.
+ typeset -g POWERLEVEL9K_EMPTY_LINE_LEFT_PROMPT_FIRST_SEGMENT_END_SYMBOL='%{%}'
+ # End filler on the edge of the screen if there are no right segments on the first line.
+ typeset -g POWERLEVEL9K_EMPTY_LINE_RIGHT_PROMPT_FIRST_SEGMENT_START_SYMBOL='%{%}'
+ fi
+
+ #################################[ os_icon: os identifier ]##################################
+ # OS identifier color.
+ typeset -g POWERLEVEL9K_OS_ICON_FOREGROUND=
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='⭐'
+
+ ################################[ prompt_char: prompt symbol ]################################
+ # Green prompt symbol if the last command succeeded.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_OK_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=76
+ # Red prompt symbol if the last command failed.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_ERROR_{VIINS,VICMD,VIVIS,VIOWR}_FOREGROUND=196
+ # Default prompt symbol.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIINS_CONTENT_EXPANSION='❯'
+ # Prompt symbol in command vi mode.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VICMD_CONTENT_EXPANSION='❮'
+ # Prompt symbol in visual vi mode.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIVIS_CONTENT_EXPANSION='V'
+ # Prompt symbol in overwrite vi mode.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_{OK,ERROR}_VIOWR_CONTENT_EXPANSION='▶'
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_OVERWRITE_STATE=true
+ # No line terminator if prompt_char is the last segment.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_LAST_SEGMENT_END_SYMBOL=''
+ # No line introducer if prompt_char is the first segment.
+ typeset -g POWERLEVEL9K_PROMPT_CHAR_LEFT_PROMPT_FIRST_SEGMENT_START_SYMBOL=
+
+ ##################################[ dir: current directory ]##################################
+ # Default current directory color.
+ typeset -g POWERLEVEL9K_DIR_FOREGROUND=31
+ # If directory is too long, shorten some of its segments to the shortest possible unique
+ # prefix. The shortened directory can be tab-completed to the original.
+ typeset -g POWERLEVEL9K_SHORTEN_STRATEGY=truncate_to_unique
+ # Replace removed segment suffixes with this symbol.
+ typeset -g POWERLEVEL9K_SHORTEN_DELIMITER=
+ # Color of the shortened directory segments.
+ typeset -g POWERLEVEL9K_DIR_SHORTENED_FOREGROUND=103
+ # Color of the anchor directory segments. Anchor segments are never shortened. The first
+ # segment is always an anchor.
+ typeset -g POWERLEVEL9K_DIR_ANCHOR_FOREGROUND=39
+ # Display anchor directory segments in bold.
+ typeset -g POWERLEVEL9K_DIR_ANCHOR_BOLD=true
+ # Don't shorten directories that contain any of these files. They are anchors.
+ local anchor_files=(
+ .bzr
+ .citc
+ .git
+ .hg
+ .node-version
+ .python-version
+ .go-version
+ .ruby-version
+ .lua-version
+ .java-version
+ .perl-version
+ .php-version
+ .tool-version
+ .shorten_folder_marker
+ .svn
+ .terraform
+ CVS
+ Cargo.toml
+ composer.json
+ go.mod
+ package.json
+ stack.yaml
+ )
+ typeset -g POWERLEVEL9K_SHORTEN_FOLDER_MARKER="(${(j:|:)anchor_files})"
+ # If set to "first" ("last"), remove everything before the first (last) subdirectory that contains
+ # files matching $POWERLEVEL9K_SHORTEN_FOLDER_MARKER. For example, when the current directory is
+ # /foo/bar/git_repo/nested_git_repo/baz, prompt will display git_repo/nested_git_repo/baz (first)
+ # or nested_git_repo/baz (last). This assumes that git_repo and nested_git_repo contain markers
+ # and other directories don't.
+ #
+ # Optionally, "first" and "last" can be followed by ":" where is an integer.
+ # This moves the truncation point to the right (positive offset) or to the left (negative offset)
+ # relative to the marker. Plain "first" and "last" are equivalent to "first:0" and "last:0"
+ # respectively.
+ typeset -g POWERLEVEL9K_DIR_TRUNCATE_BEFORE_MARKER=false
+ # Don't shorten this many last directory segments. They are anchors.
+ typeset -g POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
+ # Shorten directory if it's longer than this even if there is space for it. The value can
+ # be either absolute (e.g., '80') or a percentage of terminal width (e.g, '50%'). If empty,
+ # directory will be shortened only when prompt doesn't fit or when other parameters demand it
+ # (see POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS and POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT below).
+ # If set to `0`, directory will always be shortened to its minimum length.
+ typeset -g POWERLEVEL9K_DIR_MAX_LENGTH=80
+ # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least this
+ # many columns for typing commands.
+ typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS=40
+ # When `dir` segment is on the last prompt line, try to shorten it enough to leave at least
+ # COLUMNS * POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT * 0.01 columns for typing commands.
+ typeset -g POWERLEVEL9K_DIR_MIN_COMMAND_COLUMNS_PCT=50
+ # If set to true, embed a hyperlink into the directory. Useful for quickly
+ # opening a directory in the file manager simply by clicking the link.
+ # Can also be handy when the directory is shortened, as it allows you to see
+ # the full directory that was used in previous commands.
+ typeset -g POWERLEVEL9K_DIR_HYPERLINK=false
+
+ # Enable special styling for non-writable and non-existent directories. See POWERLEVEL9K_LOCK_ICON
+ # and POWERLEVEL9K_DIR_CLASSES below.
+ typeset -g POWERLEVEL9K_DIR_SHOW_WRITABLE=v3
+
+ # The default icon shown next to non-writable and non-existent directories when
+ # POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3.
+ # typeset -g POWERLEVEL9K_LOCK_ICON='⭐'
+
+ # POWERLEVEL9K_DIR_CLASSES allows you to specify custom icons and colors for different
+ # directories. It must be an array with 3 * N elements. Each triplet consists of:
+ #
+ # 1. A pattern against which the current directory ($PWD) is matched. Matching is done with
+ # extended_glob option enabled.
+ # 2. Directory class for the purpose of styling.
+ # 3. An empty string.
+ #
+ # Triplets are tried in order. The first triplet whose pattern matches $PWD wins.
+ #
+ # If POWERLEVEL9K_DIR_SHOW_WRITABLE is set to v3, non-writable and non-existent directories
+ # acquire class suffix _NOT_WRITABLE and NON_EXISTENT respectively.
+ #
+ # For example, given these settings:
+ #
+ # typeset -g POWERLEVEL9K_DIR_CLASSES=(
+ # '~/work(|/*)' WORK ''
+ # '~(|/*)' HOME ''
+ # '*' DEFAULT '')
+ #
+ # Whenever the current directory is ~/work or a subdirectory of ~/work, it gets styled with one
+ # of the following classes depending on its writability and existence: WORK, WORK_NOT_WRITABLE or
+ # WORK_NON_EXISTENT.
+ #
+ # Simply assigning classes to directories doesn't have any visible effects. It merely gives you an
+ # option to define custom colors and icons for different directory classes.
+ #
+ # # Styling for WORK.
+ # typeset -g POWERLEVEL9K_DIR_WORK_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_DIR_WORK_FOREGROUND=31
+ # typeset -g POWERLEVEL9K_DIR_WORK_SHORTENED_FOREGROUND=103
+ # typeset -g POWERLEVEL9K_DIR_WORK_ANCHOR_FOREGROUND=39
+ #
+ # # Styling for WORK_NOT_WRITABLE.
+ # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND=31
+ # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_SHORTENED_FOREGROUND=103
+ # typeset -g POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_ANCHOR_FOREGROUND=39
+ #
+ # # Styling for WORK_NON_EXISTENT.
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_FOREGROUND=31
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_SHORTENED_FOREGROUND=103
+ # typeset -g POWERLEVEL9K_DIR_WORK_NON_EXISTENT_ANCHOR_FOREGROUND=39
+ #
+ # If a styling parameter isn't explicitly defined for some class, it falls back to the classless
+ # parameter. For example, if POWERLEVEL9K_DIR_WORK_NOT_WRITABLE_FOREGROUND is not set, it falls
+ # back to POWERLEVEL9K_DIR_FOREGROUND.
+ #
+ # typeset -g POWERLEVEL9K_DIR_CLASSES=()
+
+ # Custom prefix.
+ # typeset -g POWERLEVEL9K_DIR_PREFIX='%fin '
+
+ #####################################[ vcs: git status ]######################################
+ # Branch icon. Set this parameter to '\uF126 ' for the popular Powerline branch icon.
+ typeset -g POWERLEVEL9K_VCS_BRANCH_ICON='\uF126 '
+
+ # Untracked files icon. It's really a question mark, your font isn't broken.
+ # Change the value of this parameter to show a different icon.
+ typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?'
+
+ # Formatter for Git status.
+ #
+ # Example output: master wip ⇣42⇡42 *42 merge ~42 +42 !42 ?42.
+ #
+ # You can edit the function to customize how Git status looks.
+ #
+ # VCS_STATUS_* parameters are set by gitstatus plugin. See reference:
+ # https://github.com/romkatv/gitstatus/blob/master/gitstatus.plugin.zsh.
+ function my_git_formatter() {
+ emulate -L zsh
+
+ if [[ -n $P9K_CONTENT ]]; then
+ # If P9K_CONTENT is not empty, use it. It's either "loading" or from vcs_info (not from
+ # gitstatus plugin). VCS_STATUS_* parameters are not available in this case.
+ typeset -g my_git_format=$P9K_CONTENT
+ return
+ fi
+
+ if (( $1 )); then
+ # Styling for up-to-date Git status.
+ local meta='%f' # default foreground
+ local clean='%76F' # green foreground
+ local modified='%178F' # yellow foreground
+ local untracked='%39F' # blue foreground
+ local conflicted='%196F' # red foreground
+ else
+ # Styling for incomplete and stale Git status.
+ local meta='%244F' # grey foreground
+ local clean='%244F' # grey foreground
+ local modified='%244F' # grey foreground
+ local untracked='%244F' # grey foreground
+ local conflicted='%244F' # grey foreground
+ fi
+
+ local res
+
+ if [[ -n $VCS_STATUS_LOCAL_BRANCH ]]; then
+ local branch=${(V)VCS_STATUS_LOCAL_BRANCH}
+ # If local branch name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 … the last 12.
+ # Tip: To always show local branch name in full without truncation, delete the next line.
+ (( $#branch > 32 )) && branch[13,-13]="…" # <-- this line
+ res+="${clean}${(g::)POWERLEVEL9K_VCS_BRANCH_ICON}${branch//\%/%%}"
+ fi
+
+ if [[ -n $VCS_STATUS_TAG
+ # Show tag only if not on a branch.
+ # Tip: To always show tag, delete the next line.
+ && -z $VCS_STATUS_LOCAL_BRANCH # <-- this line
+ ]]; then
+ local tag=${(V)VCS_STATUS_TAG}
+ # If tag name is at most 32 characters long, show it in full.
+ # Otherwise show the first 12 … the last 12.
+ # Tip: To always show tag name in full without truncation, delete the next line.
+ (( $#tag > 32 )) && tag[13,-13]="…" # <-- this line
+ res+="${meta}#${clean}${tag//\%/%%}"
+ fi
+
+ # Display the current Git commit if there is no branch and no tag.
+ # Tip: To always display the current Git commit, delete the next line.
+ [[ -z $VCS_STATUS_LOCAL_BRANCH && -z $VCS_STATUS_TAG ]] && # <-- this line
+ res+="${meta}@${clean}${VCS_STATUS_COMMIT[1,8]}"
+
+ # Show tracking branch name if it differs from local branch.
+ if [[ -n ${VCS_STATUS_REMOTE_BRANCH:#$VCS_STATUS_LOCAL_BRANCH} ]]; then
+ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}"
+ fi
+
+ # Display "wip" if the latest commit's summary contains "wip" or "WIP".
+ if [[ $VCS_STATUS_COMMIT_SUMMARY == (|*[^[:alnum:]])(wip|WIP)(|[^[:alnum:]]*) ]]; then
+ res+=" ${modified}wip"
+ fi
+
+ # ⇣42 if behind the remote.
+ (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}"
+ # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42.
+ (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" "
+ (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}"
+ # ⇠42 if behind the push remote.
+ (( VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" ${clean}⇠${VCS_STATUS_PUSH_COMMITS_BEHIND}"
+ (( VCS_STATUS_PUSH_COMMITS_AHEAD && !VCS_STATUS_PUSH_COMMITS_BEHIND )) && res+=" "
+ # ⇢42 if ahead of the push remote; no leading space if also behind: ⇠42⇢42.
+ (( VCS_STATUS_PUSH_COMMITS_AHEAD )) && res+="${clean}⇢${VCS_STATUS_PUSH_COMMITS_AHEAD}"
+ # *42 if have stashes.
+ (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}"
+ # 'merge' if the repo is in an unusual state.
+ [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}"
+ # ~42 if have merge conflicts.
+ (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}"
+ # +42 if have staged changes.
+ (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}"
+ # !42 if have unstaged changes.
+ (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}"
+ # ?42 if have untracked files. It's really a question mark, your font isn't broken.
+ # See POWERLEVEL9K_VCS_UNTRACKED_ICON above if you want to use a different icon.
+ # Remove the next line if you don't want to see untracked files at all.
+ (( VCS_STATUS_NUM_UNTRACKED )) && res+=" ${untracked}${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON}${VCS_STATUS_NUM_UNTRACKED}"
+ # "─" if the number of unstaged files is unknown. This can happen due to
+ # POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY (see below) being set to a non-negative number lower
+ # than the number of files in the Git index, or due to bash.showDirtyState being set to false
+ # in the repository config. The number of staged and untracked files may also be unknown
+ # in this case.
+ (( VCS_STATUS_HAS_UNSTAGED == -1 )) && res+=" ${modified}─"
+
+ typeset -g my_git_format=$res
+ }
+ functions -M my_git_formatter 2>/dev/null
+
+ # Don't count the number of unstaged, untracked and conflicted files in Git repositories with
+ # more than this many files in the index. Negative value means infinity.
+ #
+ # If you are working in Git repositories with tens of millions of files and seeing performance
+ # sagging, try setting POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY to a number lower than the output
+ # of `git ls-files | wc -l`. Alternatively, add `bash.showDirtyState = false` to the repository's
+ # config: `git config bash.showDirtyState false`.
+ typeset -g POWERLEVEL9K_VCS_MAX_INDEX_SIZE_DIRTY=-1
+
+ # Don't show Git status in prompt for repositories whose workdir matches this pattern.
+ # For example, if set to '~', the Git repository at $HOME/.git will be ignored.
+ # Multiple patterns can be combined with '|': '~(|/foo)|/bar/baz/*'.
+ typeset -g POWERLEVEL9K_VCS_DISABLED_WORKDIR_PATTERN='~'
+
+ # Disable the default Git status formatting.
+ typeset -g POWERLEVEL9K_VCS_DISABLE_GITSTATUS_FORMATTING=true
+ # Install our own Git status formatter.
+ typeset -g POWERLEVEL9K_VCS_CONTENT_EXPANSION='${$((my_git_formatter(1)))+${my_git_format}}'
+ typeset -g POWERLEVEL9K_VCS_LOADING_CONTENT_EXPANSION='${$((my_git_formatter(0)))+${my_git_format}}'
+ # Enable counters for staged, unstaged, etc.
+ typeset -g POWERLEVEL9K_VCS_{STAGED,UNSTAGED,UNTRACKED,CONFLICTED,COMMITS_AHEAD,COMMITS_BEHIND}_MAX_NUM=-1
+
+ # Icon color.
+ typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_COLOR=76
+ typeset -g POWERLEVEL9K_VCS_LOADING_VISUAL_IDENTIFIER_COLOR=244
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_VCS_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # Custom prefix.
+ # typeset -g POWERLEVEL9K_VCS_PREFIX='%fon '
+
+ # Show status of repositories of these types. You can add svn and/or hg if you are
+ # using them. If you do, your prompt may become slow even when your current directory
+ # isn't in an svn or hg reposotiry.
+ typeset -g POWERLEVEL9K_VCS_BACKENDS=(git)
+
+ # These settings are used for repositories other than Git or when gitstatusd fails and
+ # Powerlevel10k has to fall back to using vcs_info.
+ typeset -g POWERLEVEL9K_VCS_CLEAN_FOREGROUND=76
+ typeset -g POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND=76
+ typeset -g POWERLEVEL9K_VCS_MODIFIED_FOREGROUND=178
+
+ ##########################[ status: exit code of the last command ]###########################
+ # Enable OK_PIPE, ERROR_PIPE and ERROR_SIGNAL status states to allow us to enable, disable and
+ # style them independently from the regular OK and ERROR state.
+ typeset -g POWERLEVEL9K_STATUS_EXTENDED_STATES=true
+
+ # Status on success. No content, just an icon. No need to show it if prompt_char is enabled as
+ # it will signify success by turning green.
+ typeset -g POWERLEVEL9K_STATUS_OK=false
+ typeset -g POWERLEVEL9K_STATUS_OK_FOREGROUND=70
+ typeset -g POWERLEVEL9K_STATUS_OK_VISUAL_IDENTIFIER_EXPANSION='✔'
+
+ # Status when some part of a pipe command fails but the overall exit status is zero. It may look
+ # like this: 1|0.
+ typeset -g POWERLEVEL9K_STATUS_OK_PIPE=true
+ typeset -g POWERLEVEL9K_STATUS_OK_PIPE_FOREGROUND=70
+ typeset -g POWERLEVEL9K_STATUS_OK_PIPE_VISUAL_IDENTIFIER_EXPANSION='✔'
+
+ # Status when it's just an error code (e.g., '1'). No need to show it if prompt_char is enabled as
+ # it will signify error by turning red.
+ typeset -g POWERLEVEL9K_STATUS_ERROR=false
+ typeset -g POWERLEVEL9K_STATUS_ERROR_FOREGROUND=160
+ typeset -g POWERLEVEL9K_STATUS_ERROR_VISUAL_IDENTIFIER_EXPANSION='✘'
+
+ # Status when the last command was terminated by a signal.
+ typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL=true
+ typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_FOREGROUND=160
+ # Use terse signal names: "INT" instead of "SIGINT(2)".
+ typeset -g POWERLEVEL9K_STATUS_VERBOSE_SIGNAME=false
+ typeset -g POWERLEVEL9K_STATUS_ERROR_SIGNAL_VISUAL_IDENTIFIER_EXPANSION='✘'
+
+ # Status when some part of a pipe command fails and the overall exit status is also non-zero.
+ # It may look like this: 1|0.
+ typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE=true
+ typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_FOREGROUND=160
+ typeset -g POWERLEVEL9K_STATUS_ERROR_PIPE_VISUAL_IDENTIFIER_EXPANSION='✘'
+
+ ###################[ command_execution_time: duration of the last command ]###################
+ # Show duration of the last command if takes at least this many seconds.
+ typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=3
+ # Show this many fractional digits. Zero means round to seconds.
+ typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=0
+ # Execution time color.
+ typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=101
+ # Duration format: 1d 2h 3m 4s.
+ typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_FORMAT='d h m s'
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # Custom prefix.
+ # typeset -g POWERLEVEL9K_COMMAND_EXECUTION_TIME_PREFIX='%ftook '
+
+ #######################[ background_jobs: presence of background jobs ]#######################
+ # Don't show the number of background jobs.
+ typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VERBOSE=false
+ # Background jobs color.
+ typeset -g POWERLEVEL9K_BACKGROUND_JOBS_FOREGROUND=70
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_BACKGROUND_JOBS_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #######################[ direnv: direnv status (https://direnv.net/) ]########################
+ # Direnv color.
+ typeset -g POWERLEVEL9K_DIRENV_FOREGROUND=178
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_DIRENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###############[ asdf: asdf version manager (https://github.com/asdf-vm/asdf) ]###############
+ # Default asdf color. Only used to display tools for which there is no color override (see below).
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_FOREGROUND.
+ typeset -g POWERLEVEL9K_ASDF_FOREGROUND=66
+
+ # There are four parameters that can be used to hide asdf tools. Each parameter describes
+ # conditions under which a tool gets hidden. Parameters can hide tools but not unhide them. If at
+ # least one parameter decides to hide a tool, that tool gets hidden. If no parameter decides to
+ # hide a tool, it gets shown.
+ #
+ # Special note on the difference between POWERLEVEL9K_ASDF_SOURCES and
+ # POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW. Consider the effect of the following commands:
+ #
+ # asdf local python 3.8.1
+ # asdf global python 3.8.1
+ #
+ # After running both commands the current python version is 3.8.1 and its source is "local" as
+ # it takes precedence over "global". If POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW is set to false,
+ # it'll hide python version in this case because 3.8.1 is the same as the global version.
+ # POWERLEVEL9K_ASDF_SOURCES will hide python version only if the value of this parameter doesn't
+ # contain "local".
+
+ # Hide tool versions that don't come from one of these sources.
+ #
+ # Available sources:
+ #
+ # - shell `asdf current` says "set by ASDF_${TOOL}_VERSION environment variable"
+ # - local `asdf current` says "set by /some/not/home/directory/file"
+ # - global `asdf current` says "set by /home/username/file"
+ #
+ # Note: If this parameter is set to (shell local global), it won't hide tools.
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SOURCES.
+ typeset -g POWERLEVEL9K_ASDF_SOURCES=(shell local global)
+
+ # If set to false, hide tool versions that are the same as global.
+ #
+ # Note: The name of this parameter doesn't reflect its meaning at all.
+ # Note: If this parameter is set to true, it won't hide tools.
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_PROMPT_ALWAYS_SHOW.
+ typeset -g POWERLEVEL9K_ASDF_PROMPT_ALWAYS_SHOW=false
+
+ # If set to false, hide tool versions that are equal to "system".
+ #
+ # Note: If this parameter is set to true, it won't hide tools.
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_SYSTEM.
+ typeset -g POWERLEVEL9K_ASDF_SHOW_SYSTEM=true
+
+ # If set to non-empty value, hide tools unless there is a file matching the specified file pattern
+ # in the current directory, or its parent directory, or its grandparent directory, and so on.
+ #
+ # Note: If this parameter is set to empty value, it won't hide tools.
+ # Note: SHOW_ON_UPGLOB isn't specific to asdf. It works with all prompt segments.
+ # Tip: Override this parameter for ${TOOL} with POWERLEVEL9K_ASDF_${TOOL}_SHOW_ON_UPGLOB.
+ #
+ # Example: Hide nodejs version when there is no package.json and no *.js files in the current
+ # directory, in `..`, in `../..` and so on.
+ #
+ # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.js|package.json'
+ typeset -g POWERLEVEL9K_ASDF_SHOW_ON_UPGLOB=
+
+ # Ruby version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_RUBY_FOREGROUND=168
+ # typeset -g POWERLEVEL9K_ASDF_RUBY_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_RUBY_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Python version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_PYTHON_FOREGROUND=37
+ # typeset -g POWERLEVEL9K_ASDF_PYTHON_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_PYTHON_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Go version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_GOLANG_FOREGROUND=37
+ # typeset -g POWERLEVEL9K_ASDF_GOLANG_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_GOLANG_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Node.js version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_NODEJS_FOREGROUND=70
+ # typeset -g POWERLEVEL9K_ASDF_NODEJS_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_NODEJS_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Rust version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_RUST_FOREGROUND=37
+ # typeset -g POWERLEVEL9K_ASDF_RUST_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_RUST_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # .NET Core version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_FOREGROUND=134
+ # typeset -g POWERLEVEL9K_ASDF_DOTNET_CORE_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_DOTNET_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Flutter version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_FLUTTER_FOREGROUND=38
+ # typeset -g POWERLEVEL9K_ASDF_FLUTTER_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_FLUTTER_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Lua version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_LUA_FOREGROUND=32
+ # typeset -g POWERLEVEL9K_ASDF_LUA_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_LUA_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Java version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_JAVA_FOREGROUND=32
+ # typeset -g POWERLEVEL9K_ASDF_JAVA_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_JAVA_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Perl version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_PERL_FOREGROUND=67
+ # typeset -g POWERLEVEL9K_ASDF_PERL_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_PERL_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Erlang version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_ERLANG_FOREGROUND=125
+ # typeset -g POWERLEVEL9K_ASDF_ERLANG_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_ERLANG_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Elixir version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_ELIXIR_FOREGROUND=129
+ # typeset -g POWERLEVEL9K_ASDF_ELIXIR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_ELIXIR_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Postgres version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_POSTGRES_FOREGROUND=31
+ # typeset -g POWERLEVEL9K_ASDF_POSTGRES_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_POSTGRES_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # PHP version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_PHP_FOREGROUND=99
+ # typeset -g POWERLEVEL9K_ASDF_PHP_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_PHP_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Haskell version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_HASKELL_FOREGROUND=172
+ # typeset -g POWERLEVEL9K_ASDF_HASKELL_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_HASKELL_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ # Julia version from asdf.
+ typeset -g POWERLEVEL9K_ASDF_JULIA_FOREGROUND=70
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_ASDF_JULIA_SHOW_ON_UPGLOB='*.foo|*.bar'
+
+ ##########[ nordvpn: nordvpn connection status, linux only (https://nordvpn.com/) ]###########
+ # NordVPN connection indicator color.
+ typeset -g POWERLEVEL9K_NORDVPN_FOREGROUND=39
+ # Hide NordVPN connection indicator when not connected.
+ typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_CONTENT_EXPANSION=
+ typeset -g POWERLEVEL9K_NORDVPN_{DISCONNECTED,CONNECTING,DISCONNECTING}_VISUAL_IDENTIFIER_EXPANSION=
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_NORDVPN_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #################[ ranger: ranger shell (https://github.com/ranger/ranger) ]##################
+ # Ranger shell color.
+ typeset -g POWERLEVEL9K_RANGER_FOREGROUND=178
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_RANGER_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ######################[ nnn: nnn shell (https://github.com/jarun/nnn) ]#######################
+ # Nnn shell color.
+ typeset -g POWERLEVEL9K_NNN_FOREGROUND=72
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_NNN_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##################[ xplr: xplr shell (https://github.com/sayanarijit/xplr) ]##################
+ # xplr shell color.
+ typeset -g POWERLEVEL9K_XPLR_FOREGROUND=72
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_XPLR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###########################[ vim_shell: vim shell indicator (:sh) ]###########################
+ # Vim shell indicator color.
+ typeset -g POWERLEVEL9K_VIM_SHELL_FOREGROUND=34
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_VIM_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ######[ midnight_commander: midnight commander shell (https://midnight-commander.org/) ]######
+ # Midnight Commander shell color.
+ typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_FOREGROUND=178
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_MIDNIGHT_COMMANDER_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #[ nix_shell: nix shell (https://nixos.org/nixos/nix-pills/developing-with-nix-shell.html) ]##
+ # Nix shell color.
+ typeset -g POWERLEVEL9K_NIX_SHELL_FOREGROUND=74
+
+ # Tip: If you want to see just the icon without "pure" and "impure", uncomment the next line.
+ # typeset -g POWERLEVEL9K_NIX_SHELL_CONTENT_EXPANSION=
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_NIX_SHELL_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##################################[ disk_usage: disk usage ]##################################
+ # Colors for different levels of disk usage.
+ typeset -g POWERLEVEL9K_DISK_USAGE_NORMAL_FOREGROUND=35
+ typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_FOREGROUND=220
+ typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_FOREGROUND=160
+ # Thresholds for different levels of disk usage (percentage points).
+ typeset -g POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL=90
+ typeset -g POWERLEVEL9K_DISK_USAGE_CRITICAL_LEVEL=95
+ # If set to true, hide disk usage when below $POWERLEVEL9K_DISK_USAGE_WARNING_LEVEL percent.
+ typeset -g POWERLEVEL9K_DISK_USAGE_ONLY_WARNING=false
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_DISK_USAGE_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ######################################[ ram: free RAM ]#######################################
+ # RAM color.
+ typeset -g POWERLEVEL9K_RAM_FOREGROUND=66
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_RAM_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #####################################[ swap: used swap ]######################################
+ # Swap color.
+ typeset -g POWERLEVEL9K_SWAP_FOREGROUND=96
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_SWAP_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ######################################[ load: CPU load ]######################################
+ # Show average CPU load over this many last minutes. Valid values are 1, 5 and 15.
+ typeset -g POWERLEVEL9K_LOAD_WHICH=5
+ # Load color when load is under 50%.
+ typeset -g POWERLEVEL9K_LOAD_NORMAL_FOREGROUND=66
+ # Load color when load is between 50% and 70%.
+ typeset -g POWERLEVEL9K_LOAD_WARNING_FOREGROUND=178
+ # Load color when load is over 70%.
+ typeset -g POWERLEVEL9K_LOAD_CRITICAL_FOREGROUND=166
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_LOAD_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ################[ todo: todo items (https://github.com/todotxt/todo.txt-cli) ]################
+ # Todo color.
+ typeset -g POWERLEVEL9K_TODO_FOREGROUND=110
+ # Hide todo when the total number of tasks is zero.
+ typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_TOTAL=true
+ # Hide todo when the number of tasks after filtering is zero.
+ typeset -g POWERLEVEL9K_TODO_HIDE_ZERO_FILTERED=false
+
+ # Todo format. The following parameters are available within the expansion.
+ #
+ # - P9K_TODO_TOTAL_TASK_COUNT The total number of tasks.
+ # - P9K_TODO_FILTERED_TASK_COUNT The number of tasks after filtering.
+ #
+ # These variables correspond to the last line of the output of `todo.sh -p ls`:
+ #
+ # TODO: 24 of 42 tasks shown
+ #
+ # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT.
+ #
+ # typeset -g POWERLEVEL9K_TODO_CONTENT_EXPANSION='$P9K_TODO_FILTERED_TASK_COUNT'
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TODO_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###########[ timewarrior: timewarrior tracking status (https://timewarrior.net/) ]############
+ # Timewarrior color.
+ typeset -g POWERLEVEL9K_TIMEWARRIOR_FOREGROUND=110
+ # If the tracked task is longer than 24 characters, truncate and append "…".
+ # Tip: To always display tasks without truncation, delete the following parameter.
+ # Tip: To hide task names and display just the icon when time tracking is enabled, set the
+ # value of the following parameter to "".
+ typeset -g POWERLEVEL9K_TIMEWARRIOR_CONTENT_EXPANSION='${P9K_CONTENT:0:24}${${P9K_CONTENT:24}:+…}'
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TIMEWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##############[ taskwarrior: taskwarrior task count (https://taskwarrior.org/) ]##############
+ # Taskwarrior color.
+ typeset -g POWERLEVEL9K_TASKWARRIOR_FOREGROUND=74
+
+ # Taskwarrior segment format. The following parameters are available within the expansion.
+ #
+ # - P9K_TASKWARRIOR_PENDING_COUNT The number of pending tasks: `task +PENDING count`.
+ # - P9K_TASKWARRIOR_OVERDUE_COUNT The number of overdue tasks: `task +OVERDUE count`.
+ #
+ # Zero values are represented as empty parameters.
+ #
+ # The default format:
+ #
+ # '${P9K_TASKWARRIOR_OVERDUE_COUNT:+"!$P9K_TASKWARRIOR_OVERDUE_COUNT/"}$P9K_TASKWARRIOR_PENDING_COUNT'
+ #
+ # typeset -g POWERLEVEL9K_TASKWARRIOR_CONTENT_EXPANSION='$P9K_TASKWARRIOR_PENDING_COUNT'
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TASKWARRIOR_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##################################[ context: user@hostname ]##################################
+ # Context color when running with privileges.
+ typeset -g POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND=178
+ # Context color in SSH without privileges.
+ typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_FOREGROUND=180
+ # Default context color (no privileges, no SSH).
+ typeset -g POWERLEVEL9K_CONTEXT_FOREGROUND=180
+
+ # Context format when running with privileges: bold user@hostname.
+ typeset -g POWERLEVEL9K_CONTEXT_ROOT_TEMPLATE='%B%n@%m'
+ # Context format when in SSH without privileges: user@hostname.
+ typeset -g POWERLEVEL9K_CONTEXT_{REMOTE,REMOTE_SUDO}_TEMPLATE='%n@%m'
+ # Default context format (no privileges, no SSH): user@hostname.
+ typeset -g POWERLEVEL9K_CONTEXT_TEMPLATE='%n@%m'
+
+ # Don't show context unless running with privileges or in SSH.
+ # Tip: Remove the next line to always show context.
+ typeset -g POWERLEVEL9K_CONTEXT_{DEFAULT,SUDO}_{CONTENT,VISUAL_IDENTIFIER}_EXPANSION=
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_CONTEXT_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # Custom prefix.
+ # typeset -g POWERLEVEL9K_CONTEXT_PREFIX='%fwith '
+
+ ###[ virtualenv: python virtual environment (https://docs.python.org/3/library/venv.html) ]###
+ # Python virtual environment color.
+ typeset -g POWERLEVEL9K_VIRTUALENV_FOREGROUND=37
+ # Don't show Python version next to the virtual environment name.
+ typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_PYTHON_VERSION=false
+ # If set to "false", won't show virtualenv if pyenv is already shown.
+ # If set to "if-different", won't show virtualenv if it's the same as pyenv.
+ typeset -g POWERLEVEL9K_VIRTUALENV_SHOW_WITH_PYENV=false
+ # Separate environment name from Python version only with a space.
+ typeset -g POWERLEVEL9K_VIRTUALENV_{LEFT,RIGHT}_DELIMITER=
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_VIRTUALENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #####################[ anaconda: conda environment (https://conda.io/) ]######################
+ # Anaconda environment color.
+ typeset -g POWERLEVEL9K_ANACONDA_FOREGROUND=37
+
+ # Anaconda segment format. The following parameters are available within the expansion.
+ #
+ # - CONDA_PREFIX Absolute path to the active Anaconda/Miniconda environment.
+ # - CONDA_DEFAULT_ENV Name of the active Anaconda/Miniconda environment.
+ # - CONDA_PROMPT_MODIFIER Configurable prompt modifier (see below).
+ # - P9K_ANACONDA_PYTHON_VERSION Current python version (python --version).
+ #
+ # CONDA_PROMPT_MODIFIER can be configured with the following command:
+ #
+ # conda config --set env_prompt '({default_env}) '
+ #
+ # The last argument is a Python format string that can use the following variables:
+ #
+ # - prefix The same as CONDA_PREFIX.
+ # - default_env The same as CONDA_DEFAULT_ENV.
+ # - name The last segment of CONDA_PREFIX.
+ # - stacked_env Comma-separated list of names in the environment stack. The first element is
+ # always the same as default_env.
+ #
+ # Note: '({default_env}) ' is the default value of env_prompt.
+ #
+ # The default value of POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION expands to $CONDA_PROMPT_MODIFIER
+ # without the surrounding parentheses, or to the last path component of CONDA_PREFIX if the former
+ # is empty.
+ typeset -g POWERLEVEL9K_ANACONDA_CONTENT_EXPANSION='${${${${CONDA_PROMPT_MODIFIER#\(}% }%\)}:-${CONDA_PREFIX:t}}'
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_ANACONDA_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ################[ pyenv: python environment (https://github.com/pyenv/pyenv) ]################
+ # Pyenv color.
+ typeset -g POWERLEVEL9K_PYENV_FOREGROUND=37
+ # Hide python version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_PYENV_SOURCES=(shell local global)
+ # If set to false, hide python version if it's the same as global:
+ # $(pyenv version-name) == $(pyenv global).
+ typeset -g POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide python version if it's equal to "system".
+ typeset -g POWERLEVEL9K_PYENV_SHOW_SYSTEM=true
+
+ # Pyenv segment format. The following parameters are available within the expansion.
+ #
+ # - P9K_CONTENT Current pyenv environment (pyenv version-name).
+ # - P9K_PYENV_PYTHON_VERSION Current python version (python --version).
+ #
+ # The default format has the following logic:
+ #
+ # 1. Display just "$P9K_CONTENT" if it's equal to "$P9K_PYENV_PYTHON_VERSION" or
+ # starts with "$P9K_PYENV_PYTHON_VERSION/".
+ # 2. Otherwise display "$P9K_CONTENT $P9K_PYENV_PYTHON_VERSION".
+ typeset -g POWERLEVEL9K_PYENV_CONTENT_EXPANSION='${P9K_CONTENT}${${P9K_CONTENT:#$P9K_PYENV_PYTHON_VERSION(|/*)}:+ $P9K_PYENV_PYTHON_VERSION}'
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_PYENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ################[ goenv: go environment (https://github.com/syndbg/goenv) ]################
+ # Goenv color.
+ typeset -g POWERLEVEL9K_GOENV_FOREGROUND=37
+ # Hide go version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_GOENV_SOURCES=(shell local global)
+ # If set to false, hide go version if it's the same as global:
+ # $(goenv version-name) == $(goenv global).
+ typeset -g POWERLEVEL9K_GOENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide go version if it's equal to "system".
+ typeset -g POWERLEVEL9K_GOENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_GOENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##########[ nodenv: node.js version from nodenv (https://github.com/nodenv/nodenv) ]##########
+ # Nodenv color.
+ typeset -g POWERLEVEL9K_NODENV_FOREGROUND=70
+ # Hide node version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_NODENV_SOURCES=(shell local global)
+ # If set to false, hide node version if it's the same as global:
+ # $(nodenv version-name) == $(nodenv global).
+ typeset -g POWERLEVEL9K_NODENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide node version if it's equal to "system".
+ typeset -g POWERLEVEL9K_NODENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_NODENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##############[ nvm: node.js version from nvm (https://github.com/nvm-sh/nvm) ]###############
+ # Nvm color.
+ typeset -g POWERLEVEL9K_NVM_FOREGROUND=70
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_NVM_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ############[ nodeenv: node.js environment (https://github.com/ekalinin/nodeenv) ]############
+ # Nodeenv color.
+ typeset -g POWERLEVEL9K_NODEENV_FOREGROUND=70
+ # Don't show Node version next to the environment name.
+ typeset -g POWERLEVEL9K_NODEENV_SHOW_NODE_VERSION=false
+ # Separate environment name from Node version only with a space.
+ typeset -g POWERLEVEL9K_NODEENV_{LEFT,RIGHT}_DELIMITER=
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_NODEENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##############################[ node_version: node.js version ]###############################
+ # Node version color.
+ typeset -g POWERLEVEL9K_NODE_VERSION_FOREGROUND=70
+ # Show node version only when in a directory tree containing package.json.
+ typeset -g POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_NODE_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #######################[ go_version: go version (https://golang.org) ]########################
+ # Go version color.
+ typeset -g POWERLEVEL9K_GO_VERSION_FOREGROUND=37
+ # Show go version only when in a go project subdirectory.
+ typeset -g POWERLEVEL9K_GO_VERSION_PROJECT_ONLY=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_GO_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #################[ rust_version: rustc version (https://www.rust-lang.org) ]##################
+ # Rust version color.
+ typeset -g POWERLEVEL9K_RUST_VERSION_FOREGROUND=37
+ # Show rust version only when in a rust project subdirectory.
+ typeset -g POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_RUST_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###############[ dotnet_version: .NET version (https://dotnet.microsoft.com) ]################
+ # .NET version color.
+ typeset -g POWERLEVEL9K_DOTNET_VERSION_FOREGROUND=134
+ # Show .NET version only when in a .NET project subdirectory.
+ typeset -g POWERLEVEL9K_DOTNET_VERSION_PROJECT_ONLY=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_DOTNET_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #####################[ php_version: php version (https://www.php.net/) ]######################
+ # PHP version color.
+ typeset -g POWERLEVEL9K_PHP_VERSION_FOREGROUND=99
+ # Show PHP version only when in a PHP project subdirectory.
+ typeset -g POWERLEVEL9K_PHP_VERSION_PROJECT_ONLY=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_PHP_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##########[ laravel_version: laravel php framework version (https://laravel.com/) ]###########
+ # Laravel version color.
+ typeset -g POWERLEVEL9K_LARAVEL_VERSION_FOREGROUND=161
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_LARAVEL_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ####################[ java_version: java version (https://www.java.com/) ]####################
+ # Java version color.
+ typeset -g POWERLEVEL9K_JAVA_VERSION_FOREGROUND=32
+ # Show java version only when in a java project subdirectory.
+ typeset -g POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY=true
+ # Show brief version.
+ typeset -g POWERLEVEL9K_JAVA_VERSION_FULL=false
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_JAVA_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###[ package: name@version from package.json (https://docs.npmjs.com/files/package.json) ]####
+ # Package color.
+ typeset -g POWERLEVEL9K_PACKAGE_FOREGROUND=117
+ # Package format. The following parameters are available within the expansion.
+ #
+ # - P9K_PACKAGE_NAME The value of `name` field in package.json.
+ # - P9K_PACKAGE_VERSION The value of `version` field in package.json.
+ #
+ # typeset -g POWERLEVEL9K_PACKAGE_CONTENT_EXPANSION='${P9K_PACKAGE_NAME//\%/%%}@${P9K_PACKAGE_VERSION//\%/%%}'
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_PACKAGE_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #############[ rbenv: ruby version from rbenv (https://github.com/rbenv/rbenv) ]##############
+ # Rbenv color.
+ typeset -g POWERLEVEL9K_RBENV_FOREGROUND=168
+ # Hide ruby version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_RBENV_SOURCES=(shell local global)
+ # If set to false, hide ruby version if it's the same as global:
+ # $(rbenv version-name) == $(rbenv global).
+ typeset -g POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide ruby version if it's equal to "system".
+ typeset -g POWERLEVEL9K_RBENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_RBENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #######################[ rvm: ruby version from rvm (https://rvm.io) ]########################
+ # Rvm color.
+ typeset -g POWERLEVEL9K_RVM_FOREGROUND=168
+ # Don't show @gemset at the end.
+ typeset -g POWERLEVEL9K_RVM_SHOW_GEMSET=false
+ # Don't show ruby- at the front.
+ typeset -g POWERLEVEL9K_RVM_SHOW_PREFIX=false
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###########[ fvm: flutter version management (https://github.com/leoafarias/fvm) ]############
+ # Fvm color.
+ typeset -g POWERLEVEL9K_FVM_FOREGROUND=38
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]###########
+ # Lua color.
+ typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32
+ # Hide lua version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global)
+ # If set to false, hide lua version if it's the same as global:
+ # $(luaenv version-name) == $(luaenv global).
+ typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide lua version if it's equal to "system".
+ typeset -g POWERLEVEL9K_LUAENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###############[ jenv: java version from jenv (https://github.com/jenv/jenv) ]################
+ # Java color.
+ typeset -g POWERLEVEL9K_JENV_FOREGROUND=32
+ # Hide java version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_JENV_SOURCES=(shell local global)
+ # If set to false, hide java version if it's the same as global:
+ # $(jenv version-name) == $(jenv global).
+ typeset -g POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide java version if it's equal to "system".
+ typeset -g POWERLEVEL9K_JENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_JENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###########[ plenv: perl version from plenv (https://github.com/tokuhirom/plenv) ]############
+ # Perl color.
+ typeset -g POWERLEVEL9K_PLENV_FOREGROUND=67
+ # Hide perl version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_PLENV_SOURCES=(shell local global)
+ # If set to false, hide perl version if it's the same as global:
+ # $(plenv version-name) == $(plenv global).
+ typeset -g POWERLEVEL9K_PLENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide perl version if it's equal to "system".
+ typeset -g POWERLEVEL9K_PLENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ############[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############
+ # PHP color.
+ typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99
+ # Hide php version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global)
+ # If set to false, hide php version if it's the same as global:
+ # $(phpenv version-name) == $(phpenv global).
+ typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide php version if it's equal to "system".
+ typeset -g POWERLEVEL9K_PHPENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #######[ scalaenv: scala version from scalaenv (https://github.com/scalaenv/scalaenv) ]#######
+ # Scala color.
+ typeset -g POWERLEVEL9K_SCALAENV_FOREGROUND=160
+ # Hide scala version if it doesn't come from one of these sources.
+ typeset -g POWERLEVEL9K_SCALAENV_SOURCES=(shell local global)
+ # If set to false, hide scala version if it's the same as global:
+ # $(scalaenv version-name) == $(scalaenv global).
+ typeset -g POWERLEVEL9K_SCALAENV_PROMPT_ALWAYS_SHOW=false
+ # If set to false, hide scala version if it's equal to "system".
+ typeset -g POWERLEVEL9K_SCALAENV_SHOW_SYSTEM=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_SCALAENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
+ # Haskell color.
+ typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172
+ # Hide haskell version if it doesn't come from one of these sources.
+ #
+ # shell: version is set by STACK_YAML
+ # local: version is set by stack.yaml up the directory tree
+ # global: version is set by the implicit global project (~/.stack/global-project/stack.yaml)
+ typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local)
+ # If set to false, hide haskell version if it's the same as in the implicit global project.
+ typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_HASKELL_STACK_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
+ # Show kubecontext only when the the command you are typing invokes one of these tools.
+ # Tip: Remove the next line to always show kubecontext.
+ typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|k9s|helmfile|flux|fluxctl|stern'
+
+ # Kubernetes context classes for the purpose of using different colors, icons and expansions with
+ # different contexts.
+ #
+ # POWERLEVEL9K_KUBECONTEXT_CLASSES is an array with even number of elements. The first element
+ # in each pair defines a pattern against which the current kubernetes context gets matched.
+ # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
+ # that gets matched. If you unset all POWERLEVEL9K_KUBECONTEXT_*CONTENT_EXPANSION parameters,
+ # you'll see this value in your prompt. The second element of each pair in
+ # POWERLEVEL9K_KUBECONTEXT_CLASSES defines the context class. Patterns are tried in order. The
+ # first match wins.
+ #
+ # For example, given these settings:
+ #
+ # typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=(
+ # '*prod*' PROD
+ # '*test*' TEST
+ # '*' DEFAULT)
+ #
+ # If your current kubernetes context is "deathray-testing/default", its class is TEST
+ # because "deathray-testing/default" doesn't match the pattern '*prod*' but does match '*test*'.
+ #
+ # You can define different colors, icons and content expansions for different classes:
+ #
+ # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_FOREGROUND=28
+ # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_KUBECONTEXT_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
+ typeset -g POWERLEVEL9K_KUBECONTEXT_CLASSES=(
+ # '*prod*' PROD # These values are examples that are unlikely
+ # '*test*' TEST # to match your needs. Customize them as needed.
+ '*' DEFAULT)
+ typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND=134
+ # typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ # Use POWERLEVEL9K_KUBECONTEXT_CONTENT_EXPANSION to specify the content displayed by kubecontext
+ # segment. Parameter expansions are very flexible and fast, too. See reference:
+ # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion.
+ #
+ # Within the expansion the following parameters are always available:
+ #
+ # - P9K_CONTENT The content that would've been displayed if there was no content
+ # expansion defined.
+ # - P9K_KUBECONTEXT_NAME The current context's name. Corresponds to column NAME in the
+ # output of `kubectl config get-contexts`.
+ # - P9K_KUBECONTEXT_CLUSTER The current context's cluster. Corresponds to column CLUSTER in the
+ # output of `kubectl config get-contexts`.
+ # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
+ # in the output of `kubectl config get-contexts`. If there is no
+ # namespace, the parameter is set to "default".
+ # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
+ # output of `kubectl config get-contexts`.
+ #
+ # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
+ # the following extra parameters are available:
+ #
+ # - P9K_KUBECONTEXT_CLOUD_NAME Either "gke" or "eks".
+ # - P9K_KUBECONTEXT_CLOUD_ACCOUNT Account/project ID.
+ # - P9K_KUBECONTEXT_CLOUD_ZONE Availability zone.
+ # - P9K_KUBECONTEXT_CLOUD_CLUSTER Cluster.
+ #
+ # P9K_KUBECONTEXT_CLOUD_* parameters are derived from P9K_KUBECONTEXT_CLUSTER. For example,
+ # if P9K_KUBECONTEXT_CLUSTER is "gke_my-account_us-east1-a_my-cluster-01":
+ #
+ # - P9K_KUBECONTEXT_CLOUD_NAME=gke
+ # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=my-account
+ # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east1-a
+ # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01
+ #
+ # If P9K_KUBECONTEXT_CLUSTER is "arn:aws:eks:us-east-1:123456789012:cluster/my-cluster-01":
+ #
+ # - P9K_KUBECONTEXT_CLOUD_NAME=eks
+ # - P9K_KUBECONTEXT_CLOUD_ACCOUNT=123456789012
+ # - P9K_KUBECONTEXT_CLOUD_ZONE=us-east-1
+ # - P9K_KUBECONTEXT_CLOUD_CLUSTER=my-cluster-01
+ typeset -g POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION=
+ # Show P9K_KUBECONTEXT_CLOUD_CLUSTER if it's not empty and fall back to P9K_KUBECONTEXT_NAME.
+ POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${P9K_KUBECONTEXT_CLOUD_CLUSTER:-${P9K_KUBECONTEXT_NAME}}'
+ # Append the current context's namespace if it's not "default".
+ POWERLEVEL9K_KUBECONTEXT_DEFAULT_CONTENT_EXPANSION+='${${:-/$P9K_KUBECONTEXT_NAMESPACE}:#/default}'
+
+ # Custom prefix.
+ # typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat '
+
+ ################[ terraform: terraform workspace (https://www.terraform.io) ]#################
+ # Don't show terraform workspace if it's literally "default".
+ typeset -g POWERLEVEL9K_TERRAFORM_SHOW_DEFAULT=false
+ # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
+ # in each pair defines a pattern against which the current terraform workspace gets matched.
+ # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
+ # that gets matched. If you unset all POWERLEVEL9K_TERRAFORM_*CONTENT_EXPANSION parameters,
+ # you'll see this value in your prompt. The second element of each pair in
+ # POWERLEVEL9K_TERRAFORM_CLASSES defines the workspace class. Patterns are tried in order. The
+ # first match wins.
+ #
+ # For example, given these settings:
+ #
+ # typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
+ # '*prod*' PROD
+ # '*test*' TEST
+ # '*' OTHER)
+ #
+ # If your current terraform workspace is "project_test", its class is TEST because "project_test"
+ # doesn't match the pattern '*prod*' but does match '*test*'.
+ #
+ # You can define different colors, icons and content expansions for different classes:
+ #
+ # typeset -g POWERLEVEL9K_TERRAFORM_TEST_FOREGROUND=28
+ # typeset -g POWERLEVEL9K_TERRAFORM_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_TERRAFORM_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
+ typeset -g POWERLEVEL9K_TERRAFORM_CLASSES=(
+ # '*prod*' PROD # These values are examples that are unlikely
+ # '*test*' TEST # to match your needs. Customize them as needed.
+ '*' OTHER)
+ typeset -g POWERLEVEL9K_TERRAFORM_OTHER_FOREGROUND=38
+ # typeset -g POWERLEVEL9K_TERRAFORM_OTHER_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #############[ terraform_version: terraform version (https://www.terraform.io) ]##############
+ # Terraform version color.
+ typeset -g POWERLEVEL9K_TERRAFORM_VERSION_FOREGROUND=38
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TERRAFORM_VERSION_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #[ aws: aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) ]#
+ # Show aws only when the the command you are typing invokes one of these tools.
+ # Tip: Remove the next line to always show aws.
+ typeset -g POWERLEVEL9K_AWS_SHOW_ON_COMMAND='aws|awless|terraform|pulumi|terragrunt'
+
+ # POWERLEVEL9K_AWS_CLASSES is an array with even number of elements. The first element
+ # in each pair defines a pattern against which the current AWS profile gets matched.
+ # More specifically, it's P9K_CONTENT prior to the application of context expansion (see below)
+ # that gets matched. If you unset all POWERLEVEL9K_AWS_*CONTENT_EXPANSION parameters,
+ # you'll see this value in your prompt. The second element of each pair in
+ # POWERLEVEL9K_AWS_CLASSES defines the profile class. Patterns are tried in order. The
+ # first match wins.
+ #
+ # For example, given these settings:
+ #
+ # typeset -g POWERLEVEL9K_AWS_CLASSES=(
+ # '*prod*' PROD
+ # '*test*' TEST
+ # '*' DEFAULT)
+ #
+ # If your current AWS profile is "company_test", its class is TEST
+ # because "company_test" doesn't match the pattern '*prod*' but does match '*test*'.
+ #
+ # You can define different colors, icons and content expansions for different classes:
+ #
+ # typeset -g POWERLEVEL9K_AWS_TEST_FOREGROUND=28
+ # typeset -g POWERLEVEL9K_AWS_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_AWS_TEST_CONTENT_EXPANSION='> ${P9K_CONTENT} <'
+ typeset -g POWERLEVEL9K_AWS_CLASSES=(
+ # '*prod*' PROD # These values are examples that are unlikely
+ # '*test*' TEST # to match your needs. Customize them as needed.
+ '*' DEFAULT)
+ typeset -g POWERLEVEL9K_AWS_DEFAULT_FOREGROUND=208
+ # typeset -g POWERLEVEL9K_AWS_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ # AWS segment format. The following parameters are available within the expansion.
+ #
+ # - P9K_AWS_PROFILE The name of the current AWS profile.
+ # - P9K_AWS_REGION The region associated with the current AWS profile.
+ typeset -g POWERLEVEL9K_AWS_CONTENT_EXPANSION='${P9K_AWS_PROFILE//\%/%%}${P9K_AWS_REGION:+ ${P9K_AWS_REGION//\%/%%}}'
+
+ #[ aws_eb_env: aws elastic beanstalk environment (https://aws.amazon.com/elasticbeanstalk/) ]#
+ # AWS Elastic Beanstalk environment color.
+ typeset -g POWERLEVEL9K_AWS_EB_ENV_FOREGROUND=70
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_AWS_EB_ENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##########[ azure: azure account name (https://docs.microsoft.com/en-us/cli/azure) ]##########
+ # Show azure only when the the command you are typing invokes one of these tools.
+ # Tip: Remove the next line to always show azure.
+ typeset -g POWERLEVEL9K_AZURE_SHOW_ON_COMMAND='az|terraform|pulumi|terragrunt'
+ # Azure account name color.
+ typeset -g POWERLEVEL9K_AZURE_FOREGROUND=32
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_AZURE_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ##########[ gcloud: google cloud account and project (https://cloud.google.com/) ]###########
+ # Show gcloud only when the the command you are typing invokes one of these tools.
+ # Tip: Remove the next line to always show gcloud.
+ typeset -g POWERLEVEL9K_GCLOUD_SHOW_ON_COMMAND='gcloud|gcs'
+ # Google cloud color.
+ typeset -g POWERLEVEL9K_GCLOUD_FOREGROUND=32
+
+ # Google cloud format. Change the value of POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION and/or
+ # POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION if the default is too verbose or not informative
+ # enough. You can use the following parameters in the expansions. Each of them corresponds to the
+ # output of `gcloud` tool.
+ #
+ # Parameter | Source
+ # -------------------------|--------------------------------------------------------------------
+ # P9K_GCLOUD_CONFIGURATION | gcloud config configurations list --format='value(name)'
+ # P9K_GCLOUD_ACCOUNT | gcloud config get-value account
+ # P9K_GCLOUD_PROJECT_ID | gcloud config get-value project
+ # P9K_GCLOUD_PROJECT_NAME | gcloud projects describe $P9K_GCLOUD_PROJECT_ID --format='value(name)'
+ #
+ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced with '%%'.
+ #
+ # Obtaining project name requires sending a request to Google servers. This can take a long time
+ # and even fail. When project name is unknown, P9K_GCLOUD_PROJECT_NAME is not set and gcloud
+ # prompt segment is in state PARTIAL. When project name gets known, P9K_GCLOUD_PROJECT_NAME gets
+ # set and gcloud prompt segment transitions to state COMPLETE.
+ #
+ # You can customize the format, icon and colors of gcloud segment separately for states PARTIAL
+ # and COMPLETE. You can also hide gcloud in state PARTIAL by setting
+ # POWERLEVEL9K_GCLOUD_PARTIAL_VISUAL_IDENTIFIER_EXPANSION and
+ # POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION to empty.
+ typeset -g POWERLEVEL9K_GCLOUD_PARTIAL_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_ID//\%/%%}'
+ typeset -g POWERLEVEL9K_GCLOUD_COMPLETE_CONTENT_EXPANSION='${P9K_GCLOUD_PROJECT_NAME//\%/%%}'
+
+ # Send a request to Google (by means of `gcloud projects describe ...`) to obtain project name
+ # this often. Negative value disables periodic polling. In this mode project name is retrieved
+ # only when the current configuration, account or project id changes.
+ typeset -g POWERLEVEL9K_GCLOUD_REFRESH_PROJECT_NAME_SECONDS=60
+
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_GCLOUD_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #[ google_app_cred: google application credentials (https://cloud.google.com/docs/authentication/production) ]#
+ # Show google_app_cred only when the the command you are typing invokes one of these tools.
+ # Tip: Remove the next line to always show google_app_cred.
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_SHOW_ON_COMMAND='terraform|pulumi|terragrunt'
+
+ # Google application credentials classes for the purpose of using different colors, icons and
+ # expansions with different credentials.
+ #
+ # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES is an array with even number of elements. The first
+ # element in each pair defines a pattern against which the current kubernetes context gets
+ # matched. More specifically, it's P9K_CONTENT prior to the application of context expansion
+ # (see below) that gets matched. If you unset all POWERLEVEL9K_GOOGLE_APP_CRED_*CONTENT_EXPANSION
+ # parameters, you'll see this value in your prompt. The second element of each pair in
+ # POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES defines the context class. Patterns are tried in order.
+ # The first match wins.
+ #
+ # For example, given these settings:
+ #
+ # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
+ # '*:*prod*:*' PROD
+ # '*:*test*:*' TEST
+ # '*' DEFAULT)
+ #
+ # If your current Google application credentials is "service_account deathray-testing x@y.com",
+ # its class is TEST because it doesn't match the pattern '* *prod* *' but does match '* *test* *'.
+ #
+ # You can define different colors, icons and content expansions for different classes:
+ #
+ # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_FOREGROUND=28
+ # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_TEST_CONTENT_EXPANSION='$P9K_GOOGLE_APP_CRED_PROJECT_ID'
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_CLASSES=(
+ # '*:*prod*:*' PROD # These values are examples that are unlikely
+ # '*:*test*:*' TEST # to match your needs. Customize them as needed.
+ '*' DEFAULT)
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_FOREGROUND=32
+ # typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ # Use POWERLEVEL9K_GOOGLE_APP_CRED_CONTENT_EXPANSION to specify the content displayed by
+ # google_app_cred segment. Parameter expansions are very flexible and fast, too. See reference:
+ # http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion.
+ #
+ # You can use the following parameters in the expansion. Each of them corresponds to one of the
+ # fields in the JSON file pointed to by GOOGLE_APPLICATION_CREDENTIALS.
+ #
+ # Parameter | JSON key file field
+ # ---------------------------------+---------------
+ # P9K_GOOGLE_APP_CRED_TYPE | type
+ # P9K_GOOGLE_APP_CRED_PROJECT_ID | project_id
+ # P9K_GOOGLE_APP_CRED_CLIENT_EMAIL | client_email
+ #
+ # Note: ${VARIABLE//\%/%%} expands to ${VARIABLE} with all occurrences of '%' replaced by '%%'.
+ typeset -g POWERLEVEL9K_GOOGLE_APP_CRED_DEFAULT_CONTENT_EXPANSION='${P9K_GOOGLE_APP_CRED_PROJECT_ID//\%/%%}'
+
+ ##############[ toolbox: toolbox name (https://github.com/containers/toolbox) ]###############
+ # Toolbox color.
+ typeset -g POWERLEVEL9K_TOOLBOX_FOREGROUND=178
+ # Don't display the name of the toolbox if it matches fedora-toolbox-*.
+ typeset -g POWERLEVEL9K_TOOLBOX_CONTENT_EXPANSION='${P9K_TOOLBOX_NAME:#fedora-toolbox-*}'
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TOOLBOX_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # Custom prefix.
+ # typeset -g POWERLEVEL9K_TOOLBOX_PREFIX='%fin '
+
+ ###############################[ public_ip: public IP address ]###############################
+ # Public IP color.
+ typeset -g POWERLEVEL9K_PUBLIC_IP_FOREGROUND=94
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_PUBLIC_IP_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ########################[ vpn_ip: virtual private network indicator ]#########################
+ # VPN IP color.
+ typeset -g POWERLEVEL9K_VPN_IP_FOREGROUND=81
+ # When on VPN, show just an icon without the IP address.
+ # Tip: To display the private IP address when on VPN, remove the next line.
+ typeset -g POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION=
+ # Regular expression for the VPN network interface. Run `ifconfig` or `ip -4 a show` while on VPN
+ # to see the name of the interface.
+ typeset -g POWERLEVEL9K_VPN_IP_INTERFACE='(gpd|wg|(.*tun)|tailscale)[0-9]*'
+ # If set to true, show one segment per matching network interface. If set to false, show only
+ # one segment corresponding to the first matching network interface.
+ # Tip: If you set it to true, you'll probably want to unset POWERLEVEL9K_VPN_IP_CONTENT_EXPANSION.
+ typeset -g POWERLEVEL9K_VPN_IP_SHOW_ALL=false
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_VPN_IP_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ###########[ ip: ip address and bandwidth usage for a specified network interface ]###########
+ # IP color.
+ typeset -g POWERLEVEL9K_IP_FOREGROUND=38
+ # The following parameters are accessible within the expansion:
+ #
+ # Parameter | Meaning
+ # ----------------------+-------------------------------------------
+ # P9K_IP_IP | IP address
+ # P9K_IP_INTERFACE | network interface
+ # P9K_IP_RX_BYTES | total number of bytes received
+ # P9K_IP_TX_BYTES | total number of bytes sent
+ # P9K_IP_RX_BYTES_DELTA | number of bytes received since last prompt
+ # P9K_IP_TX_BYTES_DELTA | number of bytes sent since last prompt
+ # P9K_IP_RX_RATE | receive rate (since last prompt)
+ # P9K_IP_TX_RATE | send rate (since last prompt)
+ typeset -g POWERLEVEL9K_IP_CONTENT_EXPANSION='$P9K_IP_IP${P9K_IP_RX_RATE:+ %70F⇣$P9K_IP_RX_RATE}${P9K_IP_TX_RATE:+ %215F⇡$P9K_IP_TX_RATE}'
+ # Show information for the first network interface whose name matches this regular expression.
+ # Run `ifconfig` or `ip -4 a show` to see the names of all network interfaces.
+ typeset -g POWERLEVEL9K_IP_INTERFACE='[ew].*'
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_IP_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ #########################[ proxy: system-wide http/https/ftp proxy ]##########################
+ # Proxy color.
+ typeset -g POWERLEVEL9K_PROXY_FOREGROUND=68
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_PROXY_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ ################################[ battery: internal battery ]#################################
+ # Show battery in red when it's below this level and not connected to power supply.
+ typeset -g POWERLEVEL9K_BATTERY_LOW_THRESHOLD=20
+ typeset -g POWERLEVEL9K_BATTERY_LOW_FOREGROUND=160
+ # Show battery in green when it's charging or fully charged.
+ typeset -g POWERLEVEL9K_BATTERY_{CHARGING,CHARGED}_FOREGROUND=70
+ # Show battery in yellow when it's discharging.
+ typeset -g POWERLEVEL9K_BATTERY_DISCONNECTED_FOREGROUND=178
+ # Battery pictograms going from low to high level of charge.
+ typeset -g POWERLEVEL9K_BATTERY_STAGES='\uf58d\uf579\uf57a\uf57b\uf57c\uf57d\uf57e\uf57f\uf580\uf581\uf578'
+ # Don't show the remaining time to charge/discharge.
+ typeset -g POWERLEVEL9K_BATTERY_VERBOSE=false
+
+ #####################################[ wifi: wifi speed ]#####################################
+ # WiFi color.
+ typeset -g POWERLEVEL9K_WIFI_FOREGROUND=68
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ # Use different colors and icons depending on signal strength ($P9K_WIFI_BARS).
+ #
+ # # Wifi colors and icons for different signal strength levels (low to high).
+ # typeset -g my_wifi_fg=(68 68 68 68 68) # <-- change these values
+ # typeset -g my_wifi_icon=('WiFi' 'WiFi' 'WiFi' 'WiFi' 'WiFi') # <-- change these values
+ #
+ # typeset -g POWERLEVEL9K_WIFI_CONTENT_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}$P9K_WIFI_LAST_TX_RATE Mbps'
+ # typeset -g POWERLEVEL9K_WIFI_VISUAL_IDENTIFIER_EXPANSION='%F{${my_wifi_fg[P9K_WIFI_BARS+1]}}${my_wifi_icon[P9K_WIFI_BARS+1]}'
+ #
+ # The following parameters are accessible within the expansions:
+ #
+ # Parameter | Meaning
+ # ----------------------+---------------
+ # P9K_WIFI_SSID | service set identifier, a.k.a. network name
+ # P9K_WIFI_LINK_AUTH | authentication protocol such as "wpa2-psk" or "none"; empty if unknown
+ # P9K_WIFI_LAST_TX_RATE | wireless transmit rate in megabits per second
+ # P9K_WIFI_RSSI | signal strength in dBm, from -120 to 0
+ # P9K_WIFI_NOISE | noise in dBm, from -120 to 0
+ # P9K_WIFI_BARS | signal strength in bars, from 0 to 4 (derived from P9K_WIFI_RSSI and P9K_WIFI_NOISE)
+
+ ####################################[ time: current time ]####################################
+ # Current time color.
+ typeset -g POWERLEVEL9K_TIME_FOREGROUND=66
+ # Format for the current time: 09:51:02. See `man 3 strftime`.
+ typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}'
+ # If set to true, time will update when you hit enter. This way prompts for the past
+ # commands will contain the start times of their commands as opposed to the default
+ # behavior where they contain the end times of their preceding commands.
+ typeset -g POWERLEVEL9K_TIME_UPDATE_ON_COMMAND=false
+ # Custom icon.
+ # typeset -g POWERLEVEL9K_TIME_VISUAL_IDENTIFIER_EXPANSION='⭐'
+ # Custom prefix.
+ # typeset -g POWERLEVEL9K_TIME_PREFIX='%fat '
+
+ # Example of a user-defined prompt segment. Function prompt_example will be called on every
+ # prompt if `example` prompt segment is added to POWERLEVEL9K_LEFT_PROMPT_ELEMENTS or
+ # POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS. It displays an icon and orange text greeting the user.
+ #
+ # Type `p10k help segment` for documentation and a more sophisticated example.
+ function prompt_example() {
+ p10k segment -f 208 -i '⭐' -t 'hello, %n'
+ }
+
+ # User-defined prompt segments may optionally provide an instant_prompt_* function. Its job
+ # is to generate the prompt segment for display in instant prompt. See
+ # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.
+ #
+ # Powerlevel10k will call instant_prompt_* at the same time as the regular prompt_* function
+ # and will record all `p10k segment` calls it makes. When displaying instant prompt, Powerlevel10k
+ # will replay these calls without actually calling instant_prompt_*. It is imperative that
+ # instant_prompt_* always makes the same `p10k segment` calls regardless of environment. If this
+ # rule is not observed, the content of instant prompt will be incorrect.
+ #
+ # Usually, you should either not define instant_prompt_* or simply call prompt_* from it. If
+ # instant_prompt_* is not defined for a segment, the segment won't be shown in instant prompt.
+ function instant_prompt_example() {
+ # Since prompt_example always makes the same `p10k segment` calls, we can call it from
+ # instant_prompt_example. This will give us the same `example` prompt segment in the instant
+ # and regular prompts.
+ prompt_example
+ }
+
+ # User-defined prompt segments can be customized the same way as built-in segments.
+ # typeset -g POWERLEVEL9K_EXAMPLE_FOREGROUND=208
+ # typeset -g POWERLEVEL9K_EXAMPLE_VISUAL_IDENTIFIER_EXPANSION='⭐'
+
+ # Transient prompt works similarly to the builtin transient_rprompt option. It trims down prompt
+ # when accepting a command line. Supported values:
+ #
+ # - off: Don't change prompt when accepting a command line.
+ # - always: Trim down prompt when accepting a command line.
+ # - same-dir: Trim down prompt when accepting a command line unless this is the first command
+ # typed after changing current working directory.
+ typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always
+
+ # Instant prompt mode.
+ #
+ # - off: Disable instant prompt. Choose this if you've tried instant prompt and found
+ # it incompatible with your zsh configuration files.
+ # - quiet: Enable instant prompt and don't print warnings when detecting console output
+ # during zsh initialization. Choose this if you've read and understood
+ # https://github.com/romkatv/powerlevel10k/blob/master/README.md#instant-prompt.
+ # - verbose: Enable instant prompt and print a warning when detecting console output during
+ # zsh initialization. Choose this if you've never tried instant prompt, haven't
+ # seen the warning, or if you are unsure what this all means.
+ typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet
+
+ # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
+ # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload
+ # can slow down prompt by 1-2 milliseconds, so it's better to keep it turned off unless you
+ # really need it.
+ typeset -g POWERLEVEL9K_DISABLE_HOT_RELOAD=true
+
+ # If p10k is already loaded, reload configuration.
+ # This works even with POWERLEVEL9K_DISABLE_HOT_RELOAD=true.
+ (( ! $+functions[p10k] )) || p10k reload
+}
+
+# Tell `p10k configure` which file it should overwrite.
+typeset -g POWERLEVEL9K_CONFIG_FILE=${${(%):-%x}:a}
+
+(( ${#p10k_config_opts} )) && setopt ${p10k_config_opts[@]}
+'builtin' 'unset' 'p10k_config_opts'
diff --git a/lib/zsh/additional.zsh b/lib/zsh/additional.zsh
index e2e34589..69fee9b1 100755
--- a/lib/zsh/additional.zsh
+++ b/lib/zsh/additional.zsh
@@ -3,33 +3,33 @@
# FUNCTION: :zi-tmp-subst-source [[[
:zi-tmp-subst-source() {
- local -a ___substs ___ab
- ___substs=( "${(@s.;.)ICE[subst]}" )
- if [[ -n ${(M)___substs:#*\\(#e)} ]] {
- local ___prev
- ___substs=( ${___substs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${___prev:+$___prev\;}}${match[3]}${${___prev::=${match[2]:+${___prev:+$___prev\;}}${match[2]}}:+}} )
+ local -a ___substs ___ab
+ ___substs=( "${(@s.;.)ICE[subst]}" )
+ if [[ -n ${(M)___substs:#*\\(#e)} ]] {
+ local ___prev
+ ___substs=( ${___substs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${___prev:+$___prev\;}}${match[3]}${${___prev::=${match[2]:+${___prev:+$___prev\;}}${match[2]}}:+}} )
+ }
+
+ # Load the plugin
+ if [[ ! -r $1 ]] {
+ +zi-message "{error}source: Couldn't read the script {obj}${1}{error}" \
+ ", cannot substitute {data}${ICE[subst]}{error}.{rst}"
+ }
+
+ local ___data="$(<$1)"
+
+ () {
+ builtin emulate -LR zsh -o extendedglob -o interactivecomments
+ local ___subst ___tabspc=$'\t'
+ for ___subst ( "${___substs[@]}" ) {
+ ___ab=( "${(@)${(@)${(@s:->:)___subst}##[[:space:]]##}%%[[:space:]]##}" )
+ ___ab[2]=${___ab[2]//(#b)\\([[:digit:]])/\${match[${match[1]}]}}
+ builtin eval "___data=\"\${___data//(#b)\${~___ab[1]}/${___ab[2]}}\""
}
+ ___data="() { ${(F)${(@)${(f)___data[@]}:#[$___tabspc]#\#*}} ; } \"\${@[2,-1]}\""
+ }
- # Load the plugin
- if [[ ! -r $1 ]] {
- +zi-message "{error}source: Couldn't read the script {obj}${1}{error}" \
- ", cannot substitute {data}${ICE[subst]}{error}.{rst}"
- }
-
- local ___data="$(<$1)"
-
- () {
- builtin emulate -LR zsh -o extendedglob -o interactivecomments
- local ___subst ___tabspc=$'\t'
- for ___subst ( "${___substs[@]}" ) {
- ___ab=( "${(@)${(@)${(@s:->:)___subst}##[[:space:]]##}%%[[:space:]]##}" )
- ___ab[2]=${___ab[2]//(#b)\\([[:digit:]])/\${match[${match[1]}]}}
- builtin eval "___data=\"\${___data//(#b)\${~___ab[1]}/${___ab[2]}}\""
- }
- ___data="() { ${(F)${(@)${(f)___data[@]}:#[$___tabspc]#\#*}} ; } \"\${@[2,-1]}\""
- }
-
- builtin eval "$___data"
+ builtin eval "$___data"
}
# ]]]
# FUNCTION: .zi-service [[[
@@ -39,64 +39,62 @@
# $2 - mode - for plugin (light or load)
# $3 - id - URL or plugin ID or alias name (from id-as'')
.zi-service() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops
-
- local ___tpe="$1" ___mode="$2" ___id="$3" ___fle="${ZI[SERVICES_DIR]}/${ICE[service]}.lock" ___fd ___cmd ___tmp ___lckd ___strd=0
- { builtin print -n >! "$___fle"; } 2>/dev/null 1>&2
- [[ ! -e ${___fle:r}.fifo ]] && command mkfifo "${___fle:r}.fifo" 2>/dev/null 1>&2
- [[ ! -e ${___fle:r}.fifo2 ]] && command mkfifo "${___fle:r}.fifo2" 2>/dev/null 1>&2
-
- typeset -g ZSRV_WORK_DIR="${ZI[SERVICES_DIR]}" ZSRV_ID="${ICE[service]}" # should be also set by other p-m
-
- while (( 1 )); do
- (
- while (( 1 )); do
- [[ ! -f ${___fle:r}.stop ]] && if (( ___lckd )) || zsystem 2>/dev/null 1>&2 flock -t 1 -f ___fd -e $___fle; then
- ___lckd=1
- if (( ! ___strd )) || [[ $___cmd = RESTART ]]; then
- [[ $___tpe = p ]] && { ___strd=1; .zi-load "$___id" "" "$___mode"; }
- [[ $___tpe = s ]] && { ___strd=1; .zi-load-snippet "$___id" ""; }
- fi
- ___cmd=
- while (( 1 )); do builtin read -t 32767 ___cmd <>"${___fle:r}.fifo" && break; done
- else
- return 0
- fi
-
- [[ $___cmd = (#i)NEXT ]] && { kill -TERM "$ZSRV_PID"; builtin read -t 2 ___tmp <>"${___fle:r}.fifo2"; kill -HUP "$ZSRV_PID"; exec {___fd}>&-; ___lckd=0; ___strd=0; builtin read -t 10 ___tmp <>"${___fle:r}.fifo2"; }
- [[ $___cmd = (#i)STOP ]] && { kill -TERM "$ZSRV_PID"; builtin read -t 2 ___tmp <>"${___fle:r}.fifo2"; kill -HUP "$ZSRV_PID"; ___strd=0; builtin print >! "${___fle:r}.stop"; }
- [[ $___cmd = (#i)QUIT ]] && { kill -HUP ${sysparams[pid]}; return 1; }
- [[ $___cmd != (#i)RESTART ]] && { ___cmd=; builtin read -t 1 ___tmp <>"${___fle:r}.fifo2"; }
- done
- ) || break
- builtin read -t 1 ___tmp <>"${___fle:r}.fifo2"
- done >>! "$ZSRV_WORK_DIR/$ZSRV_ID".log 2>&1
-}
-# ]]]
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops
+
+ local ___tpe="$1" ___mode="$2" ___id="$3" ___fle="${ZI[SERVICES_DIR]}/${ICE[service]}.lock" ___fd ___cmd ___tmp ___lckd ___strd=0
+ { builtin print -n >! "$___fle"; } 2>/dev/null 1>&2
+ [[ ! -e ${___fle:r}.fifo ]] && command mkfifo "${___fle:r}.fifo" 2>/dev/null 1>&2
+ [[ ! -e ${___fle:r}.fifo2 ]] && command mkfifo "${___fle:r}.fifo2" 2>/dev/null 1>&2
+
+ typeset -g ZSRV_WORK_DIR="${ZI[SERVICES_DIR]}" ZSRV_ID="${ICE[service]}" # should be also set by other p-m
+
+ while (( 1 )); do
+ (
+ while (( 1 )); do
+ [[ ! -f ${___fle:r}.stop ]] && if (( ___lckd )) || zsystem 2>/dev/null 1>&2 flock -t 1 -f ___fd -e $___fle; then
+ ___lckd=1
+ if (( ! ___strd )) || [[ $___cmd = RESTART ]]; then
+ [[ $___tpe = p ]] && { ___strd=1; .zi-load "$___id" "" "$___mode"; }
+ [[ $___tpe = s ]] && { ___strd=1; .zi-load-snippet "$___id" ""; }
+ fi
+ ___cmd=
+ while (( 1 )); do builtin read -t 32767 ___cmd <>"${___fle:r}.fifo" && break; done
+ else
+ return 0
+ fi
+
+ [[ $___cmd = (#i)NEXT ]] && { kill -TERM "$ZSRV_PID"; builtin read -t 2 ___tmp <>"${___fle:r}.fifo2"; kill -HUP "$ZSRV_PID"; exec {___fd}>&-; ___lckd=0; ___strd=0; builtin read -t 10 ___tmp <>"${___fle:r}.fifo2"; }
+ [[ $___cmd = (#i)STOP ]] && { kill -TERM "$ZSRV_PID"; builtin read -t 2 ___tmp <>"${___fle:r}.fifo2"; kill -HUP "$ZSRV_PID"; ___strd=0; builtin print >! "${___fle:r}.stop"; }
+ [[ $___cmd = (#i)QUIT ]] && { kill -HUP ${sysparams[pid]}; return 1; }
+ [[ $___cmd != (#i)RESTART ]] && { ___cmd=; builtin read -t 1 ___tmp <>"${___fle:r}.fifo2"; }
+ done
+ ) || break
+ builtin read -t 1 ___tmp <>"${___fle:r}.fifo2"
+ done >>! "$ZSRV_WORK_DIR/$ZSRV_ID".log 2>&1
+} # ]]]
# FUNCTION: .zi-wrap-track-functions [[[
.zi-wrap-track-functions() {
- local user="$1" plugin="$2" id_as="$3" f
- local -a wt
- wt=( ${(@s.;.)ICE[wrap-track]} )
- for f in ${wt[@]}; do
- functions[${f}-zi-bkp]="${functions[$f]}"
- eval "
+ local user="$1" plugin="$2" id_as="$3" f
+ local -a wt
+ wt=( ${(@s.;.)ICE[wrap-track]} )
+ for f in ${wt[@]}; do
+ functions[${f}-zi-bkp]="${functions[$f]}"
+ eval "
function $f {
- ZI[CUR_USR]=\"$user\" ZI[CUR_PLUGIN]=\"$plugin\" ZI[CUR_USPL2]=\"$id_as\"
- .zi-add-report \"\${ZI[CUR_USPL2]}\" \"Note: === Starting to track function: $f ===\"
- .zi-diff \"\${ZI[CUR_USPL2]}\" begin
- .zi-tmp-subst-on load
- functions[${f}]=\${functions[${f}-zi-bkp]}
- ${f} \"\$@\"
- .zi-tmp-subst-off load
- .zi-diff \"\${ZI[CUR_USPL2]}\" end
- .zi-add-report \"\${ZI[CUR_USPL2]}\" \"Note: === Ended tracking function: $f ===\"
- ZI[CUR_USR]= ZI[CUR_PLUGIN]= ZI[CUR_USPL2]=
+ ZI[CUR_USR]=\"$user\" ZI[CUR_PLUGIN]=\"$plugin\" ZI[CUR_USPL2]=\"$id_as\"
+ .zi-add-report \"\${ZI[CUR_USPL2]}\" \"Note: === Starting to track function: $f ===\"
+ .zi-diff \"\${ZI[CUR_USPL2]}\" begin
+ .zi-tmp-subst-on load
+ functions[${f}]=\${functions[${f}-zi-bkp]}
+ ${f} \"\$@\"
+ .zi-tmp-subst-off load
+ .zi-diff \"\${ZI[CUR_USPL2]}\" end
+ .zi-add-report \"\${ZI[CUR_USPL2]}\" \"Note: === Ended tracking function: $f ===\"
+ ZI[CUR_USR]= ZI[CUR_PLUGIN]= ZI[CUR_USPL2]=
}"
- done
-}
-# ]]]
+ done
+} # ]]]
#
# Dtrace
@@ -105,41 +103,39 @@ function $f {
# FUNCTION: .zi-debug-start [[[
# Starts Dtrace, i.e. session tracking for changes in Zsh state.
.zi-debug-start() {
- if [[ ${ZI[DTRACE]} = 1 ]]; then
- +zi-message "{error}Dtrace is already active, stop it first with \`dstop'{rst}"
- return 1
- fi
+ if [[ ${ZI[DTRACE]} = 1 ]]; then
+ +zi-message "{error}Dtrace is already active, stop it first with \`dstop'{rst}"
+ return 1
+ fi
- ZI[DTRACE]=1
+ ZI[DTRACE]=1
- .zi-diff _dtrace/_dtrace begin
+ .zi-diff _dtrace/_dtrace begin
- # Full shadeing on
- .zi-tmp-subst-on dtrace
+ # Full shadeing on
+ .zi-tmp-subst-on dtrace
} # ]]]
# FUNCTION: .zi-debug-stop [[[
# Stops Dtrace, i.e. session tracking for changes in Zsh state.
.zi-debug-stop() {
- ZI[DTRACE]=0
-
- # Shadowing fully off
- .zi-tmp-subst-off dtrace
-
- # Gather end data now, for diffing later
- .zi-diff _dtrace/_dtrace end
+ ZI[DTRACE]=0
+ # Shadowing fully off
+ .zi-tmp-subst-off dtrace
+ # Gather end data now, for diffing later
+ .zi-diff _dtrace/_dtrace end
} # ]]]
# FUNCTION: .zi-clear-debug-report [[[
# Forgets dtrace repport gathered up to this moment.
.zi-clear-debug-report() {
- .zi-clear-report-for _dtrace/_dtrace
+ .zi-clear-report-for _dtrace/_dtrace
} # ]]]
# FUNCTION: .zi-debug-unload [[[
# Reverts changes detected by dtrace run.
.zi-debug-unload() {
- (( ${+functions[.zi-unload]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
- if [[ ${ZI[DTRACE]} = 1 ]]; then
- +zi-message "{error}Dtrace is still active, stop it first with \`dstop'{rst}"
- else
- .zi-unload _dtrace _dtrace
- fi
+ (( ${+functions[.zi-unload]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ if [[ ${ZI[DTRACE]} = 1 ]]; then
+ +zi-message "{error}Dtrace is still active, stop it first with \`dstop'{rst}"
+ else
+ .zi-unload _dtrace _dtrace
+ fi
} # ]]]
diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh
index 6039d44c..ea3fb6ca 100755
--- a/lib/zsh/autoload.zsh
+++ b/lib/zsh/autoload.zsh
@@ -2,7 +2,6 @@
# Copyright (c) 2021 Salvydas Lukosius and Z-Shell ZI contributors.
builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col-error]}ERROR:%f%b Couldn't find ${ZI[col-obj]}/lib/zsh/side.zsh%f%b."; return 1; }
-
ZI[EXTENDED_GLOB]=""
#
@@ -13,15 +12,13 @@ ZI[EXTENDED_GLOB]=""
# Removes the plugin from ZI_REGISTERED_PLUGINS array and from the
# zsh_loaded_plugins array (managed according to the plugin standard)
.zi-unregister-plugin() {
- .zi-any-to-user-plugin "$1" "$2"
- local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" \
- teleid="$3"
-
- # If not found, the index will be length+1
- ZI_REGISTERED_PLUGINS[${ZI_REGISTERED_PLUGINS[(i)$uspl2]}]=()
- # Support Zsh plugin standard
- zsh_loaded_plugins[${zsh_loaded_plugins[(i)$teleid]}]=()
- ZI[STATES__$uspl2]="0"
+ .zi-any-to-user-plugin "$1" "$2"
+ local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" teleid="$3"
+ # If not found, the index will be length+1
+ ZI_REGISTERED_PLUGINS[${ZI_REGISTERED_PLUGINS[(i)$uspl2]}]=()
+ # Support Zsh plugin standard
+ zsh_loaded_plugins[${zsh_loaded_plugins[(i)$teleid]}]=()
+ ZI[STATES__$uspl2]="0"
} # ]]]
# FUNCTION: .zi-diff-functions-compute [[[
# Computes FUNCTIONS that holds new functions added by plugin.
@@ -29,35 +26,28 @@ ZI[EXTENDED_GLOB]=""
#
# $1 - user/plugin
.zi-diff-functions-compute() {
- local uspl2="$1"
-
- # Cannot run diff if *_BEFORE or *_AFTER variable is not set
- # Following is paranoid for *_BEFORE and *_AFTER being only spaces
-
- builtin setopt localoptions extendedglob nokshglob noksharrays
- [[ "${ZI[FUNCTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[FUNCTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
-
- typeset -A func
- local i
-
- # This includes new functions. Quoting is kept (i.e. no i=${(Q)i})
- for i in "${(z)ZI[FUNCTIONS_AFTER__$uspl2]}"; do
- func[$i]=1
- done
-
- # Remove duplicated entries, i.e. existing before. Quoting is kept
- for i in "${(z)ZI[FUNCTIONS_BEFORE__$uspl2]}"; do
- # if would do unset, then: func[opp+a\[]: invalid parameter name
- func[$i]=0
- done
-
- # Store the functions, associating them with plugin ($uspl2)
- ZI[FUNCTIONS__$uspl2]=""
- for i in "${(onk)func[@]}"; do
- [[ "${func[$i]}" = "1" ]] && ZI[FUNCTIONS__$uspl2]+="$i "
- done
-
- return 0
+ local uspl2="$1"
+ # Cannot run diff if *_BEFORE or *_AFTER variable is not set
+ # Following is paranoid for *_BEFORE and *_AFTER being only spaces
+ builtin setopt localoptions extendedglob nokshglob noksharrays
+ [[ "${ZI[FUNCTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[FUNCTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
+ typeset -A func
+ local i
+ # This includes new functions. Quoting is kept (i.e. no i=${(Q)i})
+ for i in "${(z)ZI[FUNCTIONS_AFTER__$uspl2]}"; do
+ func[$i]=1
+ done
+ # Remove duplicated entries, i.e. existing before. Quoting is kept
+ for i in "${(z)ZI[FUNCTIONS_BEFORE__$uspl2]}"; do
+ # if would do unset, then: func[opp+a\[]: invalid parameter name
+ func[$i]=0
+ done
+ # Store the functions, associating them with plugin ($uspl2)
+ ZI[FUNCTIONS__$uspl2]=""
+ for i in "${(onk)func[@]}"; do
+ [[ "${func[$i]}" = "1" ]] && ZI[FUNCTIONS__$uspl2]+="$i "
+ done
+ return 0
} # ]]]
# FUNCTION: .zi-diff-options-compute [[[
# Computes OPTIONS that holds options changed by plugin.
@@ -65,31 +55,27 @@ ZI[EXTENDED_GLOB]=""
#
# $1 - user/plugin
.zi-diff-options-compute() {
- local uspl2="$1"
-
- # Cannot run diff if *_BEFORE or *_AFTER variable is not set
- # Following is paranoid for *_BEFORE and *_AFTER being only spaces
- builtin setopt localoptions extendedglob nokshglob noksharrays
- [[ "${ZI[OPTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[OPTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
-
- typeset -A opts_before opts_after opts
- opts_before=( "${(z)ZI[OPTIONS_BEFORE__$uspl2]}" )
- opts_after=( "${(z)ZI[OPTIONS_AFTER__$uspl2]}" )
- opts=( )
-
- # Iterate through first array (keys the same
- # on both of them though) and test for a change
- local key
- for key in "${(k)opts_before[@]}"; do
- if [[ "${opts_before[$key]}" != "${opts_after[$key]}" ]]; then
- opts[$key]="${opts_before[$key]}"
- fi
- done
-
- # Serialize for reporting
- local IFS=" "
- ZI[OPTIONS__$uspl2]="${(kv)opts[@]}"
- return 0
+ local uspl2="$1"
+ # Cannot run diff if *_BEFORE or *_AFTER variable is not set
+ # Following is paranoid for *_BEFORE and *_AFTER being only spaces
+ builtin setopt localoptions extendedglob nokshglob noksharrays
+ [[ "${ZI[OPTIONS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[OPTIONS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
+ typeset -A opts_before opts_after opts
+ opts_before=( "${(z)ZI[OPTIONS_BEFORE__$uspl2]}" )
+ opts_after=( "${(z)ZI[OPTIONS_AFTER__$uspl2]}" )
+ opts=( )
+ # Iterate through first array (keys the same
+ # on both of them though) and test for a change
+ local key
+ for key in "${(k)opts_before[@]}"; do
+ if [[ "${opts_before[$key]}" != "${opts_after[$key]}" ]]; then
+ opts[$key]="${opts_before[$key]}"
+ fi
+ done
+ # Serialize for reporting
+ local IFS=" "
+ ZI[OPTIONS__$uspl2]="${(kv)opts[@]}"
+ return 0
} # ]]]
# FUNCTION: .zi-diff-env-compute [[[
# Computes ZI_PATH, ZI_FPATH that hold (f)path components
@@ -97,59 +83,48 @@ ZI[EXTENDED_GLOB]=""
#
# $1 - user/plugin
.zi-diff-env-compute() {
- local uspl2="$1"
- typeset -a tmp
-
- # Cannot run diff if *_BEFORE or *_AFTER variable is not set
- # Following is paranoid for *_BEFORE and *_AFTER being only spaces
- builtin setopt localoptions extendedglob nokshglob noksharrays
- [[ "${ZI[PATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[PATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
- [[ "${ZI[FPATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[FPATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
-
- typeset -A path_state fpath_state
- local i
-
- #
- # PATH processing
- #
-
- # This includes new path elements
- for i in "${(z)ZI[PATH_AFTER__$uspl2]}"; do
- path_state[${(Q)i}]=1
- done
-
- # Remove duplicated entries, i.e. existing before
- for i in "${(z)ZI[PATH_BEFORE__$uspl2]}"; do
- unset "path_state[${(Q)i}]"
- done
-
- # Store the path elements, associating them with plugin ($uspl2)
- ZI[PATH__$uspl2]=""
- for i in "${(onk)path_state[@]}"; do
- ZI[PATH__$uspl2]+="${(q)i} "
- done
-
- #
- # FPATH processing
- #
-
- # This includes new path elements
- for i in "${(z)ZI[FPATH_AFTER__$uspl2]}"; do
- fpath_state[${(Q)i}]=1
- done
-
- # Remove duplicated entries, i.e. existing before
- for i in "${(z)ZI[FPATH_BEFORE__$uspl2]}"; do
- unset "fpath_state[${(Q)i}]"
- done
-
- # Store the path elements, associating them with plugin ($uspl2)
- ZI[FPATH__$uspl2]=""
- for i in "${(onk)fpath_state[@]}"; do
- ZI[FPATH__$uspl2]+="${(q)i} "
- done
-
- return 0
+ local uspl2="$1"
+ typeset -a tmp
+ # Cannot run diff if *_BEFORE or *_AFTER variable is not set
+ # Following is paranoid for *_BEFORE and *_AFTER being only spaces
+ builtin setopt localoptions extendedglob nokshglob noksharrays
+ [[ "${ZI[PATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[PATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
+ [[ "${ZI[FPATH_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[FPATH_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
+ typeset -A path_state fpath_state
+ local i
+ #
+ # PATH processing
+ #
+ # This includes new path elements
+ for i in "${(z)ZI[PATH_AFTER__$uspl2]}"; do
+ path_state[${(Q)i}]=1
+ done
+ # Remove duplicated entries, i.e. existing before
+ for i in "${(z)ZI[PATH_BEFORE__$uspl2]}"; do
+ unset "path_state[${(Q)i}]"
+ done
+ # Store the path elements, associating them with plugin ($uspl2)
+ ZI[PATH__$uspl2]=""
+ for i in "${(onk)path_state[@]}"; do
+ ZI[PATH__$uspl2]+="${(q)i} "
+ done
+ #
+ # FPATH processing
+ #
+ # This includes new path elements
+ for i in "${(z)ZI[FPATH_AFTER__$uspl2]}"; do
+ fpath_state[${(Q)i}]=1
+ done
+ # Remove duplicated entries, i.e. existing before
+ for i in "${(z)ZI[FPATH_BEFORE__$uspl2]}"; do
+ unset "fpath_state[${(Q)i}]"
+ done
+ # Store the path elements, associating them with plugin ($uspl2)
+ ZI[FPATH__$uspl2]=""
+ for i in "${(onk)fpath_state[@]}"; do
+ ZI[FPATH__$uspl2]+="${(q)i} "
+ done
+ return 0
} # ]]]
# FUNCTION: .zi-diff-parameter-compute [[[
# Computes ZI_PARAMETERS_PRE, ZI_PARAMETERS_POST that hold
@@ -158,52 +133,44 @@ ZI[EXTENDED_GLOB]=""
#
# $1 - user/plugin
.zi-diff-parameter-compute() {
- local uspl2="$1"
- typeset -a tmp
-
- # Cannot run diff if *_BEFORE or *_AFTER variable is not set
- # Following is paranoid for *_BEFORE and *_AFTER being only spaces
- builtin setopt localoptions extendedglob nokshglob noksharrays
- [[ "${ZI[PARAMETERS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[PARAMETERS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
-
- # Un-concatenated parameters from moment of diff start and of diff end
- typeset -A params_before params_after
- params_before=( "${(z)ZI[PARAMETERS_BEFORE__$uspl2]}" )
- params_after=( "${(z)ZI[PARAMETERS_AFTER__$uspl2]}" )
-
- # The parameters that changed, with save of what
- # parameter was when diff started or when diff ended
- typeset -A params_pre params_post
- params_pre=( )
- params_post=( )
-
- # Iterate through all existing keys, before or after diff,
- # i.e. after all variables that were somehow live across
- # the diffing process
- local key
- typeset -aU keys
- keys=( "${(k)params_after[@]}" );
- keys=( "${keys[@]}" "${(k)params_before[@]}" );
- for key in "${keys[@]}"; do
- key="${(Q)key}"
- [[ "${params_after[$key]}" = *local* ]] && continue
- if [[ "${params_after[$key]}" != "${params_before[$key]}" ]]; then
- # Empty for a new param, a type otherwise
- [[ -z "${params_before[$key]}" ]] && params_before[$key]="\"\""
- params_pre[$key]="${params_before[$key]}"
-
- # Current type, can also be empty, when plugin
- # unsets a parameter
- [[ -z "${params_after[$key]}" ]] && params_after[$key]="\"\""
- params_post[$key]="${params_after[$key]}"
- fi
- done
-
- # Serialize for reporting
- ZI[PARAMETERS_PRE__$uspl2]="${(j: :)${(qkv)params_pre[@]}}"
- ZI[PARAMETERS_POST__$uspl2]="${(j: :)${(qkv)params_post[@]}}"
-
- return 0
+ local uspl2="$1"
+ typeset -a tmp
+ # Cannot run diff if *_BEFORE or *_AFTER variable is not set
+ # Following is paranoid for *_BEFORE and *_AFTER being only spaces
+ builtin setopt localoptions extendedglob nokshglob noksharrays
+ [[ "${ZI[PARAMETERS_BEFORE__$uspl2]}" != *[$'! \t']* || "${ZI[PARAMETERS_AFTER__$uspl2]}" != *[$'! \t']* ]] && return 1
+ # Un-concatenated parameters from moment of diff start and of diff end
+ typeset -A params_before params_after
+ params_before=( "${(z)ZI[PARAMETERS_BEFORE__$uspl2]}" )
+ params_after=( "${(z)ZI[PARAMETERS_AFTER__$uspl2]}" )
+ # The parameters that changed, with save of what
+ # parameter was when diff started or when diff ended
+ typeset -A params_pre params_post
+ params_pre=( )
+ params_post=( )
+ # Iterate through all existing keys, before or after diff,
+ # i.e. after all variables that were somehow live across
+ # the diffing process
+ local key
+ typeset -aU keys
+ keys=( "${(k)params_after[@]}" );
+ keys=( "${keys[@]}" "${(k)params_before[@]}" );
+ for key in "${keys[@]}"; do
+ key="${(Q)key}"
+ [[ "${params_after[$key]}" = *local* ]] && continue
+ if [[ "${params_after[$key]}" != "${params_before[$key]}" ]]; then
+ # Empty for a new param, a type otherwise
+ [[ -z "${params_before[$key]}" ]] && params_before[$key]="\"\""
+ params_pre[$key]="${params_before[$key]}"
+ # Current type, can also be empty, when plugin unsets a parameter
+ [[ -z "${params_after[$key]}" ]] && params_after[$key]="\"\""
+ params_post[$key]="${params_after[$key]}"
+ fi
+ done
+ # Serialize for reporting
+ ZI[PARAMETERS_PRE__$uspl2]="${(j: :)${(qkv)params_pre[@]}}"
+ ZI[PARAMETERS_POST__$uspl2]="${(j: :)${(qkv)params_post[@]}}"
+ return 0
} # ]]]
# FUNCTION: .zi-any-to-uspl2 [[[
# Converts given plugin-spec to format that's used in keys for hash tables.
@@ -212,261 +179,226 @@ ZI[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zi-any-to-uspl2() {
- .zi-any-to-user-plugin "$1" "$2"
- [[ "${reply[-2]}" = "%" ]] && REPLY="${reply[-2]}${reply[-1]}" || REPLY="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]//---//}"
+ .zi-any-to-user-plugin "$1" "$2"
+ [[ "${reply[-2]}" = "%" ]] && REPLY="${reply[-2]}${reply[-1]}" || REPLY="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]//---//}"
} # ]]]
# FUNCTION: .zi-save-set-extendedglob [[[
# Enables extendedglob-option first saving if it was already
# enabled, for restoration of this state later.
.zi-save-set-extendedglob() {
- [[ -o "extendedglob" ]] && ZI[EXTENDED_GLOB]="1" || ZI[EXTENDED_GLOB]="0"
- builtin setopt extendedglob
+ [[ -o "extendedglob" ]] && ZI[EXTENDED_GLOB]="1" || ZI[EXTENDED_GLOB]="0"
+ builtin setopt extendedglob
} # ]]]
# FUNCTION: .zi-restore-extendedglob [[[
# Restores extendedglob-option from state saved earlier.
.zi-restore-extendedglob() {
- [[ "${ZI[EXTENDED_GLOB]}" = "0" ]] && builtin unsetopt extendedglob || builtin setopt extendedglob
+ [[ "${ZI[EXTENDED_GLOB]}" = "0" ]] && builtin unsetopt extendedglob || builtin setopt extendedglob
} # ]]]
# FUNCTION: .zi-prepare-readlink [[[
# Prepares readlink command, used for establishing completion's owner.
#
# $REPLY = ":" or "readlink"
.zi-prepare-readlink() {
- REPLY=":"
- if type readlink 2>/dev/null 1>&2; then
- REPLY="readlink"
- fi
+ REPLY=":"
+ if type readlink 2>/dev/null 1>&2; then
+ REPLY="readlink"
+ fi
} # ]]]
# FUNCTION: .zi-clear-report-for [[[
-# Clears all report data for given user/plugin. This is
-# done by resetting all related global ZI_* hashes.
+# Clears all report data for given user/plugin. This is done by resetting all related global ZI_* hashes.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zi-clear-report-for() {
- .zi-any-to-uspl2 "$1" "$2"
-
- # Shadowing
- ZI_REPORTS[$REPLY]=""
- ZI[BINDKEYS__$REPLY]=""
- ZI[ZSTYLES__$REPLY]=""
- ZI[ALIASES__$REPLY]=""
- ZI[WIDGETS_SAVED__$REPLY]=""
- ZI[WIDGETS_DELETE__$REPLY]=""
-
- # Function diffing
- ZI[FUNCTIONS__$REPLY]=""
- ZI[FUNCTIONS_BEFORE__$REPLY]=""
- ZI[FUNCTIONS_AFTER__$REPLY]=""
-
- # Option diffing
- ZI[OPTIONS__$REPLY]=""
- ZI[OPTIONS_BEFORE__$REPLY]=""
- ZI[OPTIONS_AFTER__$REPLY]=""
-
- # Environment diffing
- ZI[PATH__$REPLY]=""
- ZI[PATH_BEFORE__$REPLY]=""
- ZI[PATH_AFTER__$REPLY]=""
- ZI[FPATH__$REPLY]=""
- ZI[FPATH_BEFORE__$REPLY]=""
- ZI[FPATH_AFTER__$REPLY]=""
-
- # Parameter diffing
- ZI[PARAMETERS_PRE__$REPLY]=""
- ZI[PARAMETERS_POST__$REPLY]=""
- ZI[PARAMETERS_BEFORE__$REPLY]=""
- ZI[PARAMETERS_AFTER__$REPLY]=""
+ .zi-any-to-uspl2 "$1" "$2"
+ # Shadowing
+ ZI_REPORTS[$REPLY]=""
+ ZI[BINDKEYS__$REPLY]=""
+ ZI[ZSTYLES__$REPLY]=""
+ ZI[ALIASES__$REPLY]=""
+ ZI[WIDGETS_SAVED__$REPLY]=""
+ ZI[WIDGETS_DELETE__$REPLY]=""
+ # Function diffing
+ ZI[FUNCTIONS__$REPLY]=""
+ ZI[FUNCTIONS_BEFORE__$REPLY]=""
+ ZI[FUNCTIONS_AFTER__$REPLY]=""
+ # Option diffing
+ ZI[OPTIONS__$REPLY]=""
+ ZI[OPTIONS_BEFORE__$REPLY]=""
+ ZI[OPTIONS_AFTER__$REPLY]=""
+ # Environment diffing
+ ZI[PATH__$REPLY]=""
+ ZI[PATH_BEFORE__$REPLY]=""
+ ZI[PATH_AFTER__$REPLY]=""
+ ZI[FPATH__$REPLY]=""
+ ZI[FPATH_BEFORE__$REPLY]=""
+ ZI[FPATH_AFTER__$REPLY]=""
+ # Parameter diffing
+ ZI[PARAMETERS_PRE__$REPLY]=""
+ ZI[PARAMETERS_POST__$REPLY]=""
+ ZI[PARAMETERS_BEFORE__$REPLY]=""
+ ZI[PARAMETERS_AFTER__$REPLY]=""
} # ]]]
# FUNCTION: .zi-exists-message [[[
-# Checks if plugin is loaded. Testable. Also outputs error
-# message if plugin is not loaded.
+# Checks if plugin is loaded. Testable. Also outputs error message if plugin is not loaded.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zi-exists-message() {
- .zi-any-to-uspl2 "$1" "$2"
- if [[ -z "${ZI_REGISTERED_PLUGINS[(r)$REPLY]}" ]]; then
- .zi-any-colorify-as-uspl2 "$1" "$2"
- builtin print "${ZI[col-error]}No such plugin${ZI[col-rst]} $REPLY"
- return 1
- fi
- return 0
+ .zi-any-to-uspl2 "$1" "$2"
+ if [[ -z "${ZI_REGISTERED_PLUGINS[(r)$REPLY]}" ]]; then
+ .zi-any-colorify-as-uspl2 "$1" "$2"
+ builtin print "${ZI[col-error]}No such plugin${ZI[col-rst]} $REPLY"
+ return 1
+ fi
+ return 0
} # ]]]
# FUNCTION: .zi-at-eval [[[
.zi-at-eval() {
- local atclone="$2" atpull="$1"
- integer retval
- @zi-substitute atclone atpull
- [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
- return $retval
-}
-# ]]]
+ local atclone="$2" atpull="$1"
+ integer retval
+ @zi-substitute atclone atpull
+ [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
+ return $retval
+} # ]]]
#
# Format functions
#
# FUNCTION: .zi-format-functions [[[
-# Creates a one or two columns text with functions created
-# by given plugin.
+# Creates a one or two columns text with functions created by given plugin.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zi-format-functions() {
- local uspl2="$1"
-
- typeset -a func
- func=( "${(z)ZI[FUNCTIONS__$uspl2]}" )
-
- # Get length of longest left-right string pair,
- # and length of longest left string
- integer longest=0 longest_left=0 cur_left_len=0 count=1
- local f
- for f in "${(on)func[@]}"; do
- [[ -z "${#f}" ]] && continue
- f="${(Q)f}"
-
- # Compute for elements in left column,
- # ones that will be paded with spaces
- if (( count ++ % 2 != 0 )); then
- [[ "${#f}" -gt "$longest_left" ]] && longest_left="${#f}"
- cur_left_len="${#f}"
- else
- cur_left_len+="${#f}"
- cur_left_len+=1 # For separating space
- [[ "$cur_left_len" -gt "$longest" ]] && longest="$cur_left_len"
- fi
- done
-
- # Output in one or two columns
- local answer=""
- count=1
- for f in "${(on)func[@]}"; do
- [[ -z "$f" ]] && continue
- f="${(Q)f}"
-
- if (( COLUMNS >= longest )); then
- if (( count ++ % 2 != 0 )); then
- answer+="${(r:longest_left+1:: :)f}"
- else
- answer+="$f"$'\n'
- fi
- else
- answer+="$f"$'\n'
- fi
- done
- REPLY="$answer"
- # == 0 is: next element would have newline (postfix addition in "count ++")
- (( COLUMNS >= longest && count % 2 == 0 )) && REPLY="$REPLY"$'\n'
+ local uspl2="$1"
+ typeset -a func
+ func=( "${(z)ZI[FUNCTIONS__$uspl2]}" )
+ # Get length of longest left-right string pair, and length of longest left string
+ integer longest=0 longest_left=0 cur_left_len=0 count=1
+ local f
+ for f in "${(on)func[@]}"; do
+ [[ -z "${#f}" ]] && continue
+ f="${(Q)f}"
+ # Compute for elements in left column, ones that will be paded with spaces
+ if (( count ++ % 2 != 0 )); then
+ [[ "${#f}" -gt "$longest_left" ]] && longest_left="${#f}"
+ cur_left_len="${#f}"
+ else
+ cur_left_len+="${#f}"
+ cur_left_len+=1 # For separating space
+ [[ "$cur_left_len" -gt "$longest" ]] && longest="$cur_left_len"
+ fi
+ done
+ # Output in one or two columns
+ local answer=""
+ count=1
+ for f in "${(on)func[@]}"; do
+ [[ -z "$f" ]] && continue
+ f="${(Q)f}"
+ if (( COLUMNS >= longest )); then
+ if (( count ++ % 2 != 0 )); then
+ answer+="${(r:longest_left+1:: :)f}"
+ else
+ answer+="$f"$'\n'
+ fi
+ else
+ answer+="$f"$'\n'
+ fi
+ done
+ REPLY="$answer"
+ # == 0 is: next element would have newline (postfix addition in "count ++")
+ (( COLUMNS >= longest && count % 2 == 0 )) && REPLY="$REPLY"$'\n'
} # ]]]
# FUNCTION: .zi-format-options [[[
-# Creates one-column text about options that changed when
-# plugin "$1" was loaded.
+# Creates one-column text about options that changed when plugin "$1" was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zi-format-options() {
- local uspl2="$1"
-
- REPLY=""
-
- # Paranoid, don't want bad key/value pair error
- integer empty=0
- .zi-save-set-extendedglob
- [[ "${ZI[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
- .zi-restore-extendedglob
- (( empty )) && return 0
-
- typeset -A opts
- opts=( "${(z)ZI[OPTIONS__$uspl2]}" )
-
- # Get length of longest option
- integer longest=0
- local k
- for k in "${(kon)opts[@]}"; do
- [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
- done
-
- # Output in one column
- local txt
- for k in "${(kon)opts[@]}"; do
- [[ "${opts[$k]}" = "on" ]] && txt="was unset" || txt="was set"
- REPLY+="${(r:longest+1:: :)k}$txt"$'\n'
- done
+ local uspl2="$1"
+ REPLY=""
+ # Paranoid, don't want bad key/value pair error
+ integer empty=0
+ .zi-save-set-extendedglob
+ [[ "${ZI[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
+ .zi-restore-extendedglob
+ (( empty )) && return 0
+ typeset -A opts
+ opts=( "${(z)ZI[OPTIONS__$uspl2]}" )
+ # Get length of longest option
+ integer longest=0
+ local k
+ for k in "${(kon)opts[@]}"; do
+ [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
+ done
+ # Output in one column
+ local txt
+ for k in "${(kon)opts[@]}"; do
+ [[ "${opts[$k]}" = "on" ]] && txt="was unset" || txt="was set"
+ REPLY+="${(r:longest+1:: :)k}$txt"$'\n'
+ done
} # ]]]
# FUNCTION: .zi-format-env [[[
-# Creates one-column text about FPATH or PATH elements
-# added when given plugin was loaded.
+# Creates one-column text about FPATH or PATH elements added when given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
# $2 - if 1, then examine PATH, if 2, then examine FPATH
.zi-format-env() {
- local uspl2="$1" which="$2"
-
- # Format PATH?
- if [[ "$which" = "1" ]]; then
- typeset -a elem
- elem=( "${(z@)ZI[PATH__$uspl2]}" )
- elif [[ "$which" = "2" ]]; then
- typeset -a elem
- elem=( "${(z@)ZI[FPATH__$uspl2]}" )
- fi
-
- # Enumerate elements added
- local answer="" e
- for e in "${elem[@]}"; do
- [[ -z "$e" ]] && continue
- e="${(Q)e}"
- answer+="$e"$'\n'
- done
-
- [[ -n "$answer" ]] && REPLY="$answer"
+ local uspl2="$1" which="$2"
+ # Format PATH?
+ if [[ "$which" = "1" ]]; then
+ typeset -a elem
+ elem=( "${(z@)ZI[PATH__$uspl2]}" )
+ elif [[ "$which" = "2" ]]; then
+ typeset -a elem
+ elem=( "${(z@)ZI[FPATH__$uspl2]}" )
+ fi
+ # Enumerate elements added
+ local answer="" e
+ for e in "${elem[@]}"; do
+ [[ -z "$e" ]] && continue
+ e="${(Q)e}"
+ answer+="$e"$'\n'
+ done
+ [[ -n "$answer" ]] && REPLY="$answer"
} # ]]]
# FUNCTION: .zi-format-parameter [[[
-# Creates one column text that lists global parameters that
-# changed when the given plugin was loaded.
+# Creates one column text that lists global parameters that changed when the given plugin was loaded.
#
# $1 - user/plugin (i.e. uspl2 format of plugin-spec)
.zi-format-parameter() {
- local uspl2="$1" infoc="${ZI[col-info]}" k
-
- builtin setopt localoptions extendedglob nokshglob noksharrays
- REPLY=""
- [[ "${ZI[PARAMETERS_PRE__$uspl2]}" != *[$'! \t']* || "${ZI[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && return 0
-
- typeset -A elem_pre elem_post
- elem_pre=( "${(z)ZI[PARAMETERS_PRE__$uspl2]}" )
- elem_post=( "${(z)ZI[PARAMETERS_POST__$uspl2]}" )
-
- # Find longest key and longest value
- integer longest=0 vlongest1=0 vlongest2=0
- local v1 v2
- for k in "${(k)elem_post[@]}"; do
- k="${(Q)k}"
- [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
-
- v1="${(Q)elem_pre[$k]}"
- v2="${(Q)elem_post[$k]}"
- [[ "${#v1}" -gt "$vlongest1" ]] && vlongest1="${#v1}"
- [[ "${#v2}" -gt "$vlongest2" ]] && vlongest2="${#v2}"
- done
-
- # Enumerate parameters that changed. A key
- # always exists in both of the arrays
- local answer="" k
- for k in "${(k)elem_post[@]}"; do
- v1="${(Q)elem_pre[$k]}"
- v2="${(Q)elem_post[$k]}"
- k="${(Q)k}"
-
- k="${(r:longest+1:: :)k}"
- v1="${(l:vlongest1+1:: :)v1}"
- v2="${(r:vlongest2+1:: :)v2}"
- answer+="$k ${infoc}[$v1 -> $v2]${ZI[col-rst]}"$'\n'
- done
-
- [[ -n "$answer" ]] && REPLY="$answer"
-
- return 0
+ local uspl2="$1" infoc="${ZI[col-info]}" k
+ builtin setopt localoptions extendedglob nokshglob noksharrays
+ REPLY=""
+ [[ "${ZI[PARAMETERS_PRE__$uspl2]}" != *[$'! \t']* || "${ZI[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && return 0
+ typeset -A elem_pre elem_post
+ elem_pre=( "${(z)ZI[PARAMETERS_PRE__$uspl2]}" )
+ elem_post=( "${(z)ZI[PARAMETERS_POST__$uspl2]}" )
+ # Find longest key and longest value
+ integer longest=0 vlongest1=0 vlongest2=0
+ local v1 v2
+ for k in "${(k)elem_post[@]}"; do
+ k="${(Q)k}"
+ [[ "${#k}" -gt "$longest" ]] && longest="${#k}"
+ v1="${(Q)elem_pre[$k]}"
+ v2="${(Q)elem_post[$k]}"
+ [[ "${#v1}" -gt "$vlongest1" ]] && vlongest1="${#v1}"
+ [[ "${#v2}" -gt "$vlongest2" ]] && vlongest2="${#v2}"
+ done
+ # Enumerate parameters that changed. A key
+ # always exists in both of the arrays
+ local answer="" k
+ for k in "${(k)elem_post[@]}"; do
+ v1="${(Q)elem_pre[$k]}"
+ v2="${(Q)elem_post[$k]}"
+ k="${(Q)k}"
+ k="${(r:longest+1:: :)k}"
+ v1="${(l:vlongest1+1:: :)v1}"
+ v2="${(r:vlongest2+1:: :)v2}"
+ answer+="$k ${infoc}[$v1 -> $v2]${ZI[col-rst]}"$'\n'
+ done
+ [[ -n "$answer" ]] && REPLY="$answer"
+ return 0
} # ]]]
#
@@ -474,49 +406,41 @@ ZI[EXTENDED_GLOB]=""
#
# FUNCTION: .zi-get-completion-owner [[[
-# Returns "user---plugin" string (uspl1 format) of plugin that
-# owns given completion.
+# Returns "user---plugin" string (uspl1 format) of plugin that owns given completion.
#
-# Both :A and readlink will be used, then readlink's output if
-# results differ. Readlink might not be available.
+# Both :A and readlink will be used, then readlink's output if results differ. Readlink might not be available.
#
# :A will read the link "twice" and give the final repository
-# directory, possibly without username in the uspl format;
-# readlink will read the link "once"
+# directory, possibly without username in the uspl format; readlink will read the link "once"
#
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zi-get-completion-owner() {
- setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
- local cpath="$1"
- local readlink_cmd="$2"
- local in_plugin_path tmp
-
- # Try to go not too deep into resolving the symlink,
- # to have the name as it is in .zi/plugins
- # :A goes deep, descends fully to origin directory
- # Readlink just reads what symlink points to
- in_plugin_path="${cpath:A}"
- tmp=$( "$readlink_cmd" "$cpath" )
- # This in effect works as: "if different, then readlink"
- [[ -n "$tmp" ]] && in_plugin_path="$tmp"
-
- if [[ "$in_plugin_path" != "$cpath" ]]; then
- # Get the user---plugin part of path
- while [[ "$in_plugin_path" != ${ZI[PLUGINS_DIR]}/[^/]## && "$in_plugin_path" != "/" ]]; do
- in_plugin_path="${in_plugin_path:h}"
- done
- in_plugin_path="${in_plugin_path:t}"
-
- if [[ -z "$in_plugin_path" ]]; then
- in_plugin_path="${tmp:h}"
- fi
- else
- # readlink and :A have nothing
- in_plugin_path="[unknown]"
+ setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
+ local cpath="$1"
+ local readlink_cmd="$2"
+ local in_plugin_path tmp
+ # Try to go not too deep into resolving the symlink, to have the name as it is in .zi/plugins
+ # :A goes deep, descends fully to origin directory
+ # Readlink just reads what symlink points to
+ in_plugin_path="${cpath:A}"
+ tmp=$( "$readlink_cmd" "$cpath" )
+ # This in effect works as: "if different, then readlink"
+ [[ -n "$tmp" ]] && in_plugin_path="$tmp"
+ if [[ "$in_plugin_path" != "$cpath" ]]; then
+ # Get the user---plugin part of path
+ while [[ "$in_plugin_path" != ${ZI[PLUGINS_DIR]}/[^/]## && "$in_plugin_path" != "/" ]]; do
+ in_plugin_path="${in_plugin_path:h}"
+ done
+ in_plugin_path="${in_plugin_path:t}"
+ if [[ -z "$in_plugin_path" ]]; then
+ in_plugin_path="${tmp:h}"
fi
-
- REPLY="$in_plugin_path"
+ else
+ # readlink and :A have nothing
+ in_plugin_path="[unknown]"
+ fi
+ REPLY="$in_plugin_path"
} # ]]]
# FUNCTION: .zi-get-completion-owner-uspl2col [[[
# For shortening of code - returns colorized plugin name
@@ -525,9 +449,9 @@ ZI[EXTENDED_GLOB]=""
# $1 - absolute path to completion file (in COMPLETIONS_DIR)
# $2 - readlink command (":" or "readlink")
.zi-get-completion-owner-uspl2col() {
- # "cpath" "readline_cmd"
- .zi-get-completion-owner "$1" "$2"
- .zi-any-colorify-as-uspl2 "$REPLY"
+ # "cpath" "readline_cmd"
+ .zi-get-completion-owner "$1" "$2"
+ .zi-any-colorify-as-uspl2 "$REPLY"
} # ]]]
# FUNCTION: .zi-find-completions-of-plugin [[[
# Searches for completions owned by given plugin.
@@ -536,84 +460,74 @@ ZI[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-find-completions-of-plugin() {
- builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}" uspl
- [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}"
-
- reply=( "${ZI[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
+ builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}" uspl
+ [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}"
+ reply=( "${ZI[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
} # ]]]
# FUNCTION: .zi-check-comp-consistency [[[
-# ZI creates symlink for each installed completion.
+# ❮ ZI ❯ creates symlink for each installed completion.
# This function checks whether given completion (i.e.
# file like "_mkdir") is indeed a symlink. Backup file
-# is a completion that is disabled - has the leading "_"
-# removed.
+# is a completion that is disabled - has the leading "_" removed.
#
# $1 - path to completion within plugin's directory
# $2 - path to backup file within plugin's directory
.zi-check-comp-consistency() {
- local cfile="$1" bkpfile="$2"
- integer error="$3"
-
- # bkpfile must be a symlink
- if [[ -e "$bkpfile" && ! -L "$bkpfile" ]]; then
- builtin print "${ZI[col-error]}Warning: completion's backup file \`${bkpfile:t}' isn't a symlink${ZI[col-rst]}"
- error=1
- fi
-
- # cfile must be a symlink
- if [[ -e "$cfile" && ! -L "$cfile" ]]; then
- builtin print "${ZI[col-error]}Warning: completion file \`${cfile:t}' isn't a symlink${ZI[col-rst]}"
- error=1
- fi
-
- # Tell user that he can manually modify but should do it right
- (( error )) && builtin print "${ZI[col-error]}Manual edit of ${ZI[COMPLETIONS_DIR]} occured?${ZI[col-rst]}"
+ local cfile="$1" bkpfile="$2"
+ integer error="$3"
+ # bkpfile must be a symlink
+ if [[ -e "$bkpfile" && ! -L "$bkpfile" ]]; then
+ builtin print "${ZI[col-error]}Warning: completion's backup file \`${bkpfile:t}' isn't a symlink${ZI[col-rst]}"
+ error=1
+ fi
+ # cfile must be a symlink
+ if [[ -e "$cfile" && ! -L "$cfile" ]]; then
+ builtin print "${ZI[col-error]}Warning: completion file \`${cfile:t}' isn't a symlink${ZI[col-rst]}"
+ error=1
+ fi
+ # Tell user that he can manually modify but should do it right
+ (( error )) && builtin print "${ZI[col-error]}Manual edit of ${ZI[COMPLETIONS_DIR]} occured?${ZI[col-rst]}"
} # ]]]
# FUNCTION: .zi-check-which-completions-are-installed [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
-# is installed - returns 0 or 1 on corresponding positions
-# in reply.
+# is installed - returns 0 or 1 on corresponding positions in reply.
#
# $1, ... - path to completion within plugin's directory
.zi-check-which-completions-are-installed() {
- local i cfile bkpfile
- reply=( )
- for i in "$@"; do
- cfile="${i:t}"
- bkpfile="${cfile#_}"
-
- if [[ -e "${ZI[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZI[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
- reply+=( "1" )
- else
- reply+=( "0" )
- fi
- done
+ local i cfile bkpfile
+ reply=( )
+ for i in "$@"; do
+ cfile="${i:t}"
+ bkpfile="${cfile#_}"
+ if [[ -e "${ZI[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZI[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
+ reply+=( "1" )
+ else
+ reply+=( "0" )
+ fi
+ done
} # ]]]
# FUNCTION: .zi-check-which-completions-are-enabled [[[
# For each argument that each should be a path to completion
# within a plugin's dir, it checks whether that completion
-# is disabled - returns 0 or 1 on corresponding positions
-# in reply.
+# is disabled - returns 0 or 1 on corresponding positions in reply.
#
-# Uninstalled completions will be reported as "0"
-# - i.e. disabled
+# Uninstalled completions will be reported as "0" - i.e. disabled
#
# $1, ... - path to completion within plugin's directory
.zi-check-which-completions-are-enabled() {
- local i cfile
- reply=( )
- for i in "$@"; do
- cfile="${i:t}"
-
- if [[ -e "${ZI[COMPLETIONS_DIR]}"/"$cfile" ]]; then
- reply+=( "1" )
- else
- reply+=( "0" )
- fi
- done
+ local i cfile
+ reply=( )
+ for i in "$@"; do
+ cfile="${i:t}"
+ if [[ -e "${ZI[COMPLETIONS_DIR]}"/"$cfile" ]]; then
+ reply+=( "1" )
+ else
+ reply+=( "0" )
+ fi
+ done
} # ]]]
# FUNCTION: .zi-uninstall-completions [[[
# Removes all completions of given plugin from Zshell (i.e. from FPATH).
@@ -622,60 +536,49 @@ ZI[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-uninstall-completions() {
- builtin emulate -LR zsh
- builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
-
- typeset -a completions symlinked backup_comps
- local c cfile bkpfile
- integer action global_action=0
-
- .zi-get-path "$1" "$2"
- [[ -e $REPLY ]] && {
- completions=( $REPLY/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
- } || {
- builtin print "No completions found for \`$1${${1:#(%|/)*}:+${2:+/}}$2'"
- return 1
- }
-
- symlinked=( ${ZI[COMPLETIONS_DIR]}/_[^_.]*~*.zwc )
- backup_comps=( ${ZI[COMPLETIONS_DIR]}/[^_.]*~*.zwc )
-
- (( ${+functions[.zi-forget-completion]} )) || builtin source ${ZI[BIN_DIR]}"/lib/zsh/install.zsh"
-
- # Delete completions if they are really there, either
- # as completions (_fname) or backups (fname)
- for c in ${completions[@]}; do
- action=0
- cfile=${c:t}
- bkpfile=${cfile#_}
-
- # Remove symlink to completion
- if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
- command rm -f ${ZI[COMPLETIONS_DIR]}/$cfile
- action=1
- fi
-
- # Remove backup symlink (created by cdisable)
- if [[ -n ${backup_comps[(r)*/$bkpfile]} ]]; then
- command rm -f ${ZI[COMPLETIONS_DIR]}/$bkpfile
- action=1
- fi
-
- if (( action )); then
- +zi-message "{info}Uninstalling completion \`{file}$cfile{info}'{…}{rst}"
- # Make compinit notice the change
- .zi-forget-completion "$cfile"
- (( global_action ++ ))
- else
- +zi-message "{info}Completion \`{file}$cfile{info}' not installed.{rst}"
- fi
- done
-
- if (( global_action > 0 )); then
- +zi-message "{info}Uninstalled {num}$global_action{info} completions.{rst}"
+ builtin emulate -LR zsh
+ builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
+ typeset -a completions symlinked backup_comps
+ local c cfile bkpfile
+ integer action global_action=0
+ .zi-get-path "$1" "$2"
+ [[ -e $REPLY ]] && {
+ completions=( $REPLY/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
+ } || {
+ builtin print "No completions found for \`$1${${1:#(%|/)*}:+${2:+/}}$2'"
+ return 1
+ }
+ symlinked=( ${ZI[COMPLETIONS_DIR]}/_[^_.]*~*.zwc )
+ backup_comps=( ${ZI[COMPLETIONS_DIR]}/[^_.]*~*.zwc )
+ (( ${+functions[.zi-forget-completion]} )) || builtin source ${ZI[BIN_DIR]}"/lib/zsh/install.zsh"
+ # Delete completions if they are really there, either as completions (_fname) or backups (fname)
+ for c in ${completions[@]}; do
+ action=0
+ cfile=${c:t}
+ bkpfile=${cfile#_}
+ # Remove symlink to completion
+ if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
+ command rm -f ${ZI[COMPLETIONS_DIR]}/$cfile
+ action=1
fi
-
- .zi-compinit >/dev/null
+ # Remove backup symlink (created by cdisable)
+ if [[ -n ${backup_comps[(r)*/$bkpfile]} ]]; then
+ command rm -f ${ZI[COMPLETIONS_DIR]}/$bkpfile
+ action=1
+ fi
+ if (( action )); then
+ +zi-message "{info}Uninstalling completion \`{file}$cfile{info}'{…}{rst}"
+ # Make compinit notice the change
+ .zi-forget-completion "$cfile"
+ (( global_action ++ ))
+ else
+ +zi-message "{info}Completion \`{file}$cfile{info}' not installed.{rst}"
+ fi
+ done
+ if (( global_action > 0 )); then
+ +zi-message "{info}Uninstalled {num}$global_action{info} completions.{rst}"
+ fi
+ .zi-compinit >/dev/null
} # ]]]
#
@@ -685,112 +588,104 @@ ZI[EXTENDED_GLOB]=""
# FUNCTION: .zi-pager [[[
# BusyBox less lacks the -X and -i options, so it can use more
.zi-pager() {
- setopt LOCAL_OPTIONS EQUALS
- # Quiet mode ? → no pager.
- if (( OPTS[opt_-n,--no-pager] )) {
- cat
- return 0
- }
- if [[ ${${:-=less}:A:t} = busybox* ]] {
- more 2>/dev/null
- (( ${+commands[more]} ))
- } else {
- less -FRXi 2>/dev/null
- (( ${+commands[less]} ))
- }
- (( $? )) && cat
+ setopt LOCAL_OPTIONS EQUALS
+ # Quiet mode ? → no pager.
+ if (( OPTS[opt_-n,--no-pager] )) {
+ cat
return 0
+ }
+ if [[ ${${:-=less}:A:t} = busybox* ]] {
+ more 2>/dev/null
+ (( ${+commands[more]} ))
+ } else {
+ less -FRXi 2>/dev/null
+ (( ${+commands[less]} ))
+ }
+ (( $? )) && cat
+ return 0
}
# ]]]
-
# FUNCTION: .zi-self-update [[[
-# Updates ZI code (does a git pull).
+# Updates ❮ ZI ❯ code (does a git pull).
#
# User-action entry point.
.zi-self-update() {
- emulate -LR zsh
- setopt extendedglob typesetsilent warncreateglobal
-
- [[ $1 = -q ]] && +zi-message "{info2}Updating ZI{…}{rst}"
-
- local nl=$'\n' escape=$'\x1b['
- local -a lines
- ( builtin cd -q "$ZI[BIN_DIR]" && \
- command git checkout main &>/dev/null && \
- command git checkout master &>/dev/null && \
- command git fetch --quiet && \
- lines=( ${(f)"$(command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s %Cred%d%Creset || %b' ..FETCH_HEAD)"} )
- if (( ${#lines} > 0 )); then
- # Remove the (origin/master ...) segments, to expect only tags to appear
- lines=( "${(S)lines[@]//\(([,[:blank:]]#(origin|HEAD|master|main)[^a-zA-Z]##(HEAD|origin|master|main)[,[:blank:]]#)#\)/}" )
- # Remove " ||" if it ends the line (i.e. no additional text from the body)
- lines=( "${lines[@]/ \|\|[[:blank:]]#(#e)/}" )
- # If there's no ref-name, 2 consecutive spaces occur - fix this
- lines=( "${lines[@]/(#b)[[:space:]]#\|\|[[:space:]]#(*)(#e)/|| ${match[1]}}" )
- lines=( "${lines[@]/(#b)$escape([0-9]##)m[[:space:]]##${escape}m/$escape${match[1]}m${escape}m}" )
- # Replace what follows "|| ..." with the same thing but with no newlines,
- # and also only first 10 words (the (w)-flag enables word-indexing)
- lines=( "${lines[@]/(#b)[[:blank:]]#\|\|(*)(#e)/| ${${match[1]//$nl/ }[(w)1,(w)10]}}" )
- builtin print -rl -- "${lines[@]}" | .zi-pager
- builtin print
- fi
- if [[ $1 != -q ]] {
- command git pull --no-stat --ff-only origin main
- } else {
- command git pull --no-stat --quiet --ff-only origin main
- }
- )
- if [[ $1 != -q ]] {
- +zi-message "Compiling ZI (zcompile){…}"
- }
- command rm -f $ZI[BIN_DIR]/*.zwc(DN)
- command rm -f $ZI[BIN_DIR]/lib/zsh/*.zwc(DN)
- zcompile -U $ZI[BIN_DIR]/zi.zsh
- zcompile -U $ZI[BIN_DIR]/lib/zsh/side.zsh
- zcompile -U $ZI[BIN_DIR]/lib/zsh/install.zsh
- zcompile -U $ZI[BIN_DIR]/lib/zsh/autoload.zsh
- zcompile -U $ZI[BIN_DIR]/lib/zsh/additional.zsh
- zcompile -U $ZI[BIN_DIR]/lib/zsh/git-process-output.zsh
- # Load for the current session
- [[ $1 != -q ]] && +zi-message "Reloading ZI for the current session{…}"
- source $ZI[BIN_DIR]/zi.zsh
- source $ZI[BIN_DIR]/lib/zsh/side.zsh
- source $ZI[BIN_DIR]/lib/zsh/install.zsh
- source $ZI[BIN_DIR]/lib/zsh/autoload.zsh
- # Read and remember the new modification timestamps
- local file
- for file ( "" side install autoload ) {
- .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/$file.zsh" "ZI[mtime$file]"
- }
+ emulate -LR zsh
+ setopt extendedglob typesetsilent warncreateglobal
+ [[ $1 = -q ]] && +zi-message "{info2}Updating »»» ❮ ZI ❯ {…}{rst}"
+ local nl=$'\n' escape=$'\x1b['
+ local -a lines
+ ( builtin cd -q "$ZI[BIN_DIR]" && command git checkout main &>/dev/null && \
+ command git checkout master &>/dev/null && command git fetch --quiet && \
+ lines=( ${(f)"$(command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s %Cred%d%Creset || %b' ..FETCH_HEAD)"} )
+ if (( ${#lines} > 0 )); then
+ # Remove the (origin/master ...) segments, to expect only tags to appear
+ lines=( "${(S)lines[@]//\(([,[:blank:]]#(origin|HEAD|master|main)[^a-zA-Z]##(HEAD|origin|master|main)[,[:blank:]]#)#\)/}" )
+ # Remove " ||" if it ends the line (i.e. no additional text from the body)
+ lines=( "${lines[@]/ \|\|[[:blank:]]#(#e)/}" )
+ # If there's no ref-name, 2 consecutive spaces occur - fix this
+ lines=( "${lines[@]/(#b)[[:space:]]#\|\|[[:space:]]#(*)(#e)/|| ${match[1]}}" )
+ lines=( "${lines[@]/(#b)$escape([0-9]##)m[[:space:]]##${escape}m/$escape${match[1]}m${escape}m}" )
+ # Replace what follows "|| ..." with the same thing but with no newlines,
+ # and also only first 10 words (the (w)-flag enables word-indexing)
+ lines=( "${lines[@]/(#b)[[:blank:]]#\|\|(*)(#e)/| ${${match[1]//$nl/ }[(w)1,(w)10]}}" )
+ builtin print -rl -- "${lines[@]}" | .zi-pager
+ builtin print
+ fi
+ if [[ $1 != -q ]] {
+ command git pull --no-stat --ff-only origin main
+ } else {
+ command git pull --no-stat --quiet --ff-only origin main
+ }
+ )
+ if [[ $1 != -q ]] {
+ +zi-message "Compiling »»» ❮ ZI ❯ {…}"
+ }
+ command rm -f $ZI[BIN_DIR]/*.zwc(DN)
+ command rm -f $ZI[BIN_DIR]/lib/zsh/*.zwc(DN)
+ zcompile -U $ZI[BIN_DIR]/zi.zsh
+ zcompile -U $ZI[BIN_DIR]/lib/zsh/side.zsh
+ zcompile -U $ZI[BIN_DIR]/lib/zsh/install.zsh
+ zcompile -U $ZI[BIN_DIR]/lib/zsh/autoload.zsh
+ zcompile -U $ZI[BIN_DIR]/lib/zsh/additional.zsh
+ zcompile -U $ZI[BIN_DIR]/lib/zsh/git-process-output.zsh
+ # Load for the current session
+ [[ $1 != -q ]] && +zi-message "Reloading »»» ❮ ZI ❯ for the current session{…}"
+ source $ZI[BIN_DIR]/zi.zsh
+ source $ZI[BIN_DIR]/lib/zsh/side.zsh
+ source $ZI[BIN_DIR]/lib/zsh/install.zsh
+ source $ZI[BIN_DIR]/lib/zsh/autoload.zsh
+ # Read and remember the new modification timestamps
+ local file
+ for file ( "" side install autoload ) {
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/$file.zsh" "ZI[mtime$file]"
+ }
} # ]]]
# FUNCTION: .zi-show-registered-plugins [[[
# Lists loaded plugins (subcommands list, loaded).
#
# User-action entry point.
.zi-show-registered-plugins() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops
-
- typeset -a filtered
- local keyword="$1"
-
- keyword="${keyword## ##}"
- keyword="${keyword%% ##}"
- if [[ -n "$keyword" ]]; then
- builtin print "Installed plugins matching ${ZI[col-info]}$keyword${ZI[col-rst]}:"
- filtered=( "${(M)ZI_REGISTERED_PLUGINS[@]:#*$keyword*}" )
- else
- filtered=( "${ZI_REGISTERED_PLUGINS[@]}" )
- fi
-
- local i
- for i in "${filtered[@]}"; do
- [[ "$i" = "_local/zi" ]] && continue
- .zi-any-colorify-as-uspl2 "$i"
- # Mark light loads
- [[ "${ZI[STATES__$i]}" = "1" ]] && REPLY="$REPLY ${ZI[col-info]}*${ZI[col-rst]}"
- builtin print -r -- "$REPLY"
- done
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops
+ typeset -a filtered
+ local keyword="$1"
+ keyword="${keyword## ##}"
+ keyword="${keyword%% ##}"
+ if [[ -n "$keyword" ]]; then
+ builtin print "Installed plugins matching ${ZI[col-info]}$keyword${ZI[col-rst]}:"
+ filtered=( "${(M)ZI_REGISTERED_PLUGINS[@]:#*$keyword*}" )
+ else
+ filtered=( "${ZI_REGISTERED_PLUGINS[@]}" )
+ fi
+ local i
+ for i in "${filtered[@]}"; do
+ [[ "$i" = "_local/zi" ]] && continue
+ .zi-any-colorify-as-uspl2 "$i"
+ # Mark light loads
+ [[ "${ZI[STATES__$i]}" = "1" ]] && REPLY="$REPLY ${ZI[col-info]}*${ZI[col-rst]}"
+ builtin print -r -- "$REPLY"
+ done
} # ]]]
# FUNCTION: .zi-unload [[[
# 0. Call the Zsh Plugin's Standard *_plugin_unload function
@@ -810,493 +705,466 @@ ZI[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-unload() {
- .zi-any-to-user-plugin "$1" "$2"
- local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" user="${reply[-2]}" plugin="${reply[-1]}" quiet="${${3:+1}:-0}"
- local k
-
- .zi-any-colorify-as-uspl2 "$uspl2"
- (( quiet )) || builtin print -r -- "${ZI[col-bar]}---${ZI[col-rst]} Unloading plugin: $REPLY ${ZI[col-bar]}---${ZI[col-rst]}"
-
- local ___dir
- [[ "$user" = "%" ]] && ___dir="$plugin" || ___dir="${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}"
-
- # KSH_ARRAYS immunity
- integer correct=0
- [[ -o "KSH_ARRAYS" ]] && correct=1
-
- # Allow unload for debug user
- if [[ "$uspl2" != "_dtrace/_dtrace" ]]; then
- .zi-exists-message "$1" "$2" || return 1
- fi
-
- .zi-any-colorify-as-uspl2 "$1" "$2"
- local uspl2col="$REPLY"
-
- # Store report of the plugin in variable LASTREPORT
- typeset -g LASTREPORT
- LASTREPORT=`.zi-show-report "$1" "$2"`
-
- #
- # Call the Zsh Plugin's Standard *_plugin_unload function
- #
-
- (( ${+functions[${plugin}_plugin_unload]} )) && ${plugin}_plugin_unload
-
- #
- # Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update
- #
-
- local -a tmp
- local -A sice
- tmp=( "${(z@)ZI_SICE[$uspl2]}" )
- (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=()
-
- if [[ -n ${sice[ps-on-unload]} ]]; then
- (( quiet )) || builtin print -r "Running plugin's provided unload code: ${ZI[col-info]}${sice[ps-on-unload][1,50]}${sice[ps-on-unload][51]:+…}${ZI[col-rst]}"
- local ___oldcd="$PWD"
- () { setopt localoptions noautopushd; builtin cd -q "$___dir"; }
- eval "${sice[ps-on-unload]}"
- () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }
+ .zi-any-to-user-plugin "$1" "$2"
+ local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" user="${reply[-2]}" plugin="${reply[-1]}" quiet="${${3:+1}:-0}"
+ local k
+ .zi-any-colorify-as-uspl2 "$uspl2"
+ (( quiet )) || builtin print -r -- "${ZI[col-bar]}---${ZI[col-rst]} Unloading plugin: $REPLY ${ZI[col-bar]}---${ZI[col-rst]}"
+ local ___dir
+ [[ "$user" = "%" ]] && ___dir="$plugin" || ___dir="${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}"
+ # KSH_ARRAYS immunity
+ integer correct=0
+ [[ -o "KSH_ARRAYS" ]] && correct=1
+ # Allow unload for debug user
+ if [[ "$uspl2" != "_dtrace/_dtrace" ]]; then
+ .zi-exists-message "$1" "$2" || return 1
+ fi
+ .zi-any-colorify-as-uspl2 "$1" "$2"
+ local uspl2col="$REPLY"
+ # Store report of the plugin in variable LASTREPORT
+ typeset -g LASTREPORT
+ LASTREPORT=`.zi-show-report "$1" "$2"`
+
+ #
+ # Call the Zsh Plugin's Standard *_plugin_unload function
+ #
+
+ (( ${+functions[${plugin}_plugin_unload]} )) && ${plugin}_plugin_unload
+
+ #
+ # Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update
+ #
+
+ local -a tmp
+ local -A sice
+ tmp=( "${(z@)ZI_SICE[$uspl2]}" )
+ (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=()
+ if [[ -n ${sice[ps-on-unload]} ]]; then
+ (( quiet )) || builtin print -r "Running plugin's provided unload code: ${ZI[col-info]}${sice[ps-on-unload][1,50]}${sice[ps-on-unload][51]:+…}${ZI[col-rst]}"
+ local ___oldcd="$PWD"
+ () { setopt localoptions noautopushd; builtin cd -q "$___dir"; }
+ eval "${sice[ps-on-unload]}"
+ () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }
+ fi
+
+ #
+ # 1. Delete done bindkeys
+ #
+
+ typeset -a string_widget
+ string_widget=( "${(z)ZI[BINDKEYS__$uspl2]}" )
+ local sw
+ for sw in "${(Oa)string_widget[@]}"; do
+ [[ -z "$sw" ]] && continue
+ # Remove one level of quoting to split using (z)
+ sw="${(Q)sw}"
+ typeset -a sw_arr
+ sw_arr=( "${(z)sw}" )
+ # Remove one level of quoting to pass to bindkey
+ local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys
+ local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget
+ local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional previous-bound widget
+ local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional -M or -A or -N
+ local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional map name
+ local sw_arr6="${(Q)sw_arr[6-correct]}" # Optional -R (not with -A, -N)
+ if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then
+ if [[ -n "$sw_arr3" ]]; then
+ () {
+ emulate -LR zsh -o extendedglob
+ (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
+ }
+ bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3"
+ else
+ (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
+ bindkey -M "$sw_arr5" -r "$sw_arr1"
+ fi
+ elif [[ "$sw_arr4" = "-M" && "$sw_arr6" = "-R" ]]; then
+ if [[ -n "$sw_arr3" ]]; then
+ (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
+ bindkey -RM "$sw_arr5" "$sw_arr1" "$sw_arr3"
+ else
+ (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
+ bindkey -M "$sw_arr5" -Rr "$sw_arr1"
+ fi
+ elif [[ "$sw_arr4" != "-M" && "$sw_arr6" = "-R" ]]; then
+ if [[ -n "$sw_arr3" ]]; then
+ (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3"
+ bindkey -R "$sw_arr1" "$sw_arr3"
+ else
+ (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2"
+ bindkey -Rr "$sw_arr1"
+ fi
+ elif [[ "$sw_arr4" = "-A" ]]; then
+ (( quiet )) || builtin print -r "Linking backup-\`main' keymap \`$sw_arr5' back to \`main'"
+ bindkey -A "$sw_arr5" "main"
+ elif [[ "$sw_arr4" = "-N" ]]; then
+ (( quiet )) || builtin print -r "Deleting keymap \`$sw_arr5'"
+ bindkey -D "$sw_arr5"
+ else
+ if [[ -n "$sw_arr3" ]]; then
+ () {
+ emulate -LR zsh -o extendedglob
+ (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3"
+ }
+ bindkey "$sw_arr1" "$sw_arr3"
+ else
+ (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2"
+ bindkey -r "$sw_arr1"
+ fi
fi
-
- #
- # 1. Delete done bindkeys
- #
-
- typeset -a string_widget
- string_widget=( "${(z)ZI[BINDKEYS__$uspl2]}" )
- local sw
- for sw in "${(Oa)string_widget[@]}"; do
- [[ -z "$sw" ]] && continue
- # Remove one level of quoting to split using (z)
- sw="${(Q)sw}"
- typeset -a sw_arr
- sw_arr=( "${(z)sw}" )
-
- # Remove one level of quoting to pass to bindkey
- local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys
- local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget
- local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional previous-bound widget
- local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional -M or -A or -N
- local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional map name
- local sw_arr6="${(Q)sw_arr[6-correct]}" # Optional -R (not with -A, -N)
-
- if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then
- if [[ -n "$sw_arr3" ]]; then
- () {
- emulate -LR zsh -o extendedglob
- (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
- }
- bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3"
- else
- (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
- bindkey -M "$sw_arr5" -r "$sw_arr1"
- fi
- elif [[ "$sw_arr4" = "-M" && "$sw_arr6" = "-R" ]]; then
- if [[ -n "$sw_arr3" ]]; then
- (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
- bindkey -RM "$sw_arr5" "$sw_arr1" "$sw_arr3"
- else
- (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5"
- bindkey -M "$sw_arr5" -Rr "$sw_arr1"
- fi
- elif [[ "$sw_arr4" != "-M" && "$sw_arr6" = "-R" ]]; then
- if [[ -n "$sw_arr3" ]]; then
- (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3"
- bindkey -R "$sw_arr1" "$sw_arr3"
- else
- (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2"
- bindkey -Rr "$sw_arr1"
- fi
- elif [[ "$sw_arr4" = "-A" ]]; then
- (( quiet )) || builtin print -r "Linking backup-\`main' keymap \`$sw_arr5' back to \`main'"
- bindkey -A "$sw_arr5" "main"
- elif [[ "$sw_arr4" = "-N" ]]; then
- (( quiet )) || builtin print -r "Deleting keymap \`$sw_arr5'"
- bindkey -D "$sw_arr5"
- else
- if [[ -n "$sw_arr3" ]]; then
- () {
- emulate -LR zsh -o extendedglob
- (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3"
- }
- bindkey "$sw_arr1" "$sw_arr3"
- else
- (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2"
- bindkey -r "$sw_arr1"
- fi
- fi
- done
-
- #
- # 2. Delete created Zstyles
- #
-
- typeset -a pattern_style
- pattern_style=( "${(z)ZI[ZSTYLES__$uspl2]}" )
- local ps
- for ps in "${(Oa)pattern_style[@]}"; do
- [[ -z "$ps" ]] && continue
- # Remove one level of quoting to split using (z)
- ps="${(Q)ps}"
- typeset -a ps_arr
- ps_arr=( "${(z)ps}" )
-
- # Remove one level of quoting to pass to zstyle
- local ps_arr1="${(Q)ps_arr[1-correct]}"
- local ps_arr2="${(Q)ps_arr[2-correct]}"
-
- (( quiet )) || builtin print "Deleting zstyle $ps_arr1 $ps_arr2"
-
- zstyle -d "$ps_arr1" "$ps_arr2"
+ done
+
+ #
+ # 2. Delete created Zstyles
+ #
+
+ typeset -a pattern_style
+ pattern_style=( "${(z)ZI[ZSTYLES__$uspl2]}" )
+ local ps
+ for ps in "${(Oa)pattern_style[@]}"; do
+ [[ -z "$ps" ]] && continue
+ # Remove one level of quoting to split using (z)
+ ps="${(Q)ps}"
+ typeset -a ps_arr
+ ps_arr=( "${(z)ps}" )
+ # Remove one level of quoting to pass to zstyle
+ local ps_arr1="${(Q)ps_arr[1-correct]}"
+ local ps_arr2="${(Q)ps_arr[2-correct]}"
+ (( quiet )) || builtin print "Deleting zstyle $ps_arr1 $ps_arr2"
+ zstyle -d "$ps_arr1" "$ps_arr2"
+ done
+
+ #
+ # 3. Restore changed options
+ #
+
+ # Paranoid, don't want bad key/value pair error
+ .zi-diff-options-compute "$uspl2"
+ integer empty=0
+ .zi-save-set-extendedglob
+ [[ "${ZI[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
+ .zi-restore-extendedglob
+ if (( empty != 1 )); then
+ typeset -A opts
+ opts=( "${(z)ZI[OPTIONS__$uspl2]}" )
+ for k in "${(kon)opts[@]}"; do
+ # Internal options
+ [[ "$k" = "physical" ]] && continue
+ if [[ "${opts[$k]}" = "on" ]]; then
+ (( quiet )) || builtin print "Setting option $k"
+ builtin setopt "$k"
+ else
+ (( quiet )) || builtin print "Unsetting option $k"
+ builtin unsetopt "$k"
+ fi
done
-
- #
- # 3. Restore changed options
- #
-
- # Paranoid, don't want bad key/value pair error
- .zi-diff-options-compute "$uspl2"
- integer empty=0
- .zi-save-set-extendedglob
- [[ "${ZI[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1
- .zi-restore-extendedglob
-
- if (( empty != 1 )); then
- typeset -A opts
- opts=( "${(z)ZI[OPTIONS__$uspl2]}" )
- for k in "${(kon)opts[@]}"; do
- # Internal options
- [[ "$k" = "physical" ]] && continue
-
- if [[ "${opts[$k]}" = "on" ]]; then
- (( quiet )) || builtin print "Setting option $k"
- builtin setopt "$k"
- else
- (( quiet )) || builtin print "Unsetting option $k"
- builtin unsetopt "$k"
- fi
- done
+ fi
+
+ #
+ # 4. Delete aliases
+ #
+
+ typeset -a aname_avalue
+ aname_avalue=( "${(z)ZI[ALIASES__$uspl2]}" )
+ local nv
+ for nv in "${(Oa)aname_avalue[@]}"; do
+ [[ -z "$nv" ]] && continue
+ # Remove one level of quoting to split using (z)
+ nv="${(Q)nv}"
+ typeset -a nv_arr
+ nv_arr=( "${(z)nv}" )
+ # Remove one level of quoting to pass to unalias
+ local nv_arr1="${(Q)nv_arr[1-correct]}"
+ local nv_arr2="${(Q)nv_arr[2-correct]}"
+ local nv_arr3="${(Q)nv_arr[3-correct]}"
+ if [[ "$nv_arr3" = "-s" ]]; then
+ if [[ -n "$nv_arr2" ]]; then
+ (( quiet )) || builtin print "Restoring ${ZI[col-info]}suffix${ZI[col-rst]} alias ${nv_arr1}=${nv_arr2}"
+ alias "$nv_arr1" &> /dev/null && unalias -s -- "$nv_arr1"
+ alias -s -- "${nv_arr1}=${nv_arr2}"
+ else
+ (( quiet )) || alias "$nv_arr1" &> /dev/null && {
+ builtin print "Removing ${ZI[col-info]}suffix${ZI[col-rst]} alias ${nv_arr1}"
+ unalias -s -- "$nv_arr1"
+ }
+ fi
+ elif [[ "$nv_arr3" = "-g" ]]; then
+ if [[ -n "$nv_arr2" ]]; then
+ (( quiet )) || builtin print "Restoring ${ZI[col-info]}global${ZI[col-rst]} alias ${nv_arr1}=${nv_arr2}"
+ alias "$nv_arr1" &> /dev/null && unalias -g -- "$nv_arr1"
+ alias -g -- "${nv_arr1}=${nv_arr2}"
+ else
+ (( quiet )) || alias "$nv_arr1" &> /dev/null && {
+ builtin print "Removing ${ZI[col-info]}global${ZI[col-rst]} alias ${nv_arr1}"
+ unalias -- "${(q)nv_arr1}"
+ }
+ fi
+ else
+ if [[ -n "$nv_arr2" ]]; then
+ (( quiet )) || builtin print "Restoring alias ${nv_arr1}=${nv_arr2}"
+ alias "$nv_arr1" &> /dev/null && unalias -- "$nv_arr1"
+ alias -- "${nv_arr1}=${nv_arr2}"
+ else
+ (( quiet )) || alias "$nv_arr1" &> /dev/null && {
+ builtin print "Removing alias ${nv_arr1}"
+ unalias -- "$nv_arr1"
+ }
+ fi
fi
-
- #
- # 4. Delete aliases
- #
-
- typeset -a aname_avalue
- aname_avalue=( "${(z)ZI[ALIASES__$uspl2]}" )
- local nv
- for nv in "${(Oa)aname_avalue[@]}"; do
- [[ -z "$nv" ]] && continue
- # Remove one level of quoting to split using (z)
- nv="${(Q)nv}"
- typeset -a nv_arr
- nv_arr=( "${(z)nv}" )
-
- # Remove one level of quoting to pass to unalias
- local nv_arr1="${(Q)nv_arr[1-correct]}"
- local nv_arr2="${(Q)nv_arr[2-correct]}"
- local nv_arr3="${(Q)nv_arr[3-correct]}"
-
- if [[ "$nv_arr3" = "-s" ]]; then
- if [[ -n "$nv_arr2" ]]; then
- (( quiet )) || builtin print "Restoring ${ZI[col-info]}suffix${ZI[col-rst]} alias ${nv_arr1}=${nv_arr2}"
- alias "$nv_arr1" &> /dev/null && unalias -s -- "$nv_arr1"
- alias -s -- "${nv_arr1}=${nv_arr2}"
- else
- (( quiet )) || alias "$nv_arr1" &> /dev/null && {
- builtin print "Removing ${ZI[col-info]}suffix${ZI[col-rst]} alias ${nv_arr1}"
- unalias -s -- "$nv_arr1"
- }
- fi
- elif [[ "$nv_arr3" = "-g" ]]; then
- if [[ -n "$nv_arr2" ]]; then
- (( quiet )) || builtin print "Restoring ${ZI[col-info]}global${ZI[col-rst]} alias ${nv_arr1}=${nv_arr2}"
- alias "$nv_arr1" &> /dev/null && unalias -g -- "$nv_arr1"
- alias -g -- "${nv_arr1}=${nv_arr2}"
- else
- (( quiet )) || alias "$nv_arr1" &> /dev/null && {
- builtin print "Removing ${ZI[col-info]}global${ZI[col-rst]} alias ${nv_arr1}"
- unalias -- "${(q)nv_arr1}"
- }
- fi
- else
- if [[ -n "$nv_arr2" ]]; then
- (( quiet )) || builtin print "Restoring alias ${nv_arr1}=${nv_arr2}"
- alias "$nv_arr1" &> /dev/null && unalias -- "$nv_arr1"
- alias -- "${nv_arr1}=${nv_arr2}"
- else
- (( quiet )) || alias "$nv_arr1" &> /dev/null && {
- builtin print "Removing alias ${nv_arr1}"
- unalias -- "$nv_arr1"
- }
- fi
- fi
- done
-
- #
- # 5. Restore Zle state
- #
-
- local -a keys
- keys=( "${(@on)ZI[(I)TIME_<->_*]}" )
- integer keys_size=${#keys}
- () {
- setopt localoptions extendedglob noksharrays typesetsilent
- typeset -a restore_widgets skip_delete
- local wid
- restore_widgets=( "${(z)ZI[WIDGETS_SAVED__$uspl2]}" )
- for wid in "${(Oa)restore_widgets[@]}"; do
- [[ -z "$wid" ]] && continue
- wid="${(Q)wid}"
- typeset -a orig_saved
- orig_saved=( "${(z)wid}" )
-
- local tpe="${orig_saved[1]}"
- local orig_saved1="${(Q)orig_saved[2]}" # Original widget
- local comp_wid="${(Q)orig_saved[3]}"
- local orig_saved2="${(Q)orig_saved[4]}" # Saved target function
- local orig_saved3="${(Q)orig_saved[5]}" # Saved previous $widget's contents
-
- local found_time_key="${keys[(r)TIME_<->_${uspl2//\//---}]}" to_process_plugin
- integer found_time_idx=0 idx=0
- to_process_plugin=""
- [[ "$found_time_key" = (#b)TIME_(<->)_* ]] && found_time_idx="${match[1]}"
- if (( found_time_idx )); then # Must be true
- for (( idx = found_time_idx + 1; idx <= keys_size; ++ idx )); do
- found_time_key="${keys[(r)TIME_${idx}_*]}"
- local oth_uspl2=""
- [[ "$found_time_key" = (#b)TIME_${idx}_(*) ]] && oth_uspl2="${match[1]//---//}"
- local -a entry_splitted
- entry_splitted=( "${(z@)ZI[WIDGETS_SAVED__$oth_uspl2]}" )
- integer found_idx="${entry_splitted[(I)(-N|-C)\ $orig_saved1\\\ *]}"
- local -a entry_splitted2
- entry_splitted2=( "${(z@)ZI[BINDKEYS__$oth_uspl2]}" )
- integer found_idx2="${entry_splitted2[(I)*\ $orig_saved1\ *]}"
- if (( found_idx || found_idx2 ))
- then
- # Skip multiple loads of the same plugin
- # TODO: Fully handle multiple plugin loads
- if [[ "$oth_uspl2" != "$uspl2" ]]; then
- to_process_plugin="$oth_uspl2"
- break # Only the first one is needed
- fi
- fi
- done
- if [[ -n "$to_process_plugin" ]]; then
- if (( !found_idx && !found_idx2 )); then
- (( quiet )) || builtin print "Problem (1) during handling of widget \`$orig_saved1' (contents: $orig_saved2)"
- continue
- fi
- (( quiet )) || builtin print "Chaining widget \`$orig_saved1' to plugin $oth_uspl2"
- local -a oth_orig_saved
- if (( found_idx )) {
- oth_orig_saved=( "${(z)${(Q)entry_splitted[found_idx]}}" )
- local oth_fun="${oth_orig_saved[4]}"
- # oth_orig_saved[2]="${(q)orig_saved2}" # not do this, because
- # we don't want to call other
- # plugin's function at any moment
- oth_orig_saved[5]="${(q)orig_saved3}" # chain up the widget
- entry_splitted[found_idx]="${(q)${(j: :)oth_orig_saved}}"
- ZI[WIDGETS_SAVED__$oth_uspl2]="${(j: :)entry_splitted}"
- } else {
- oth_orig_saved=( "${(z)${(Q)entry_splitted2[found_idx2]}}" )
- local oth_fun="${widgets[${oth_orig_saved[3]}]#*:}"
- }
- integer idx="${functions[$orig_saved2][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}"
- if (( idx <= ${#functions[$orig_saved2]} ))
- then
- local prefix_X="${match[1]#\{}"
- [[ $prefix_X != \$* ]] && prefix_X="${prefix_X%\}}"
- idx="${functions[$oth_fun][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}"
- if (( idx <= ${#functions[$oth_fun]} )); then
- match[1]="${match[1]#\{}"
- [[ ${match[1]} != \$* ]] && match[1]="${match[1]%\}}"
- eval "local oth_prefix_uspl2_X=\"${match[1]}\""
- if [[ "${widgets[$prefix_X]}" = builtin ]]; then
- (( quiet )) || builtin print "Builtin-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)"
- zle -A ".${prefix_X#.}" "$oth_prefix_uspl2_X"
- elif [[ "${widgets[$prefix_X]}" = completion:* ]]; then
- (( quiet )) || builtin print "Chain*-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)"
- zle -C "$oth_prefix_uspl2_X" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}"
- else
- (( quiet )) || builtin print "Chain-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)"
- zle -N "$oth_prefix_uspl2_X" "${widgets[$prefix_X]#user:}"
- fi
- fi
-
- # The alternate method
- #skip_delete+=( "${match[1]}" )
- #functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}"
- fi
- else
- (( quiet )) || builtin print "Restoring Zle widget $orig_saved1"
- if [[ "$orig_saved3" = builtin ]]; then
- zle -A ".$orig_saved1" "$orig_saved1"
- elif [[ "$orig_saved3" = completion:* ]]; then
- zle -C "$orig_saved1" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}"
- else
- zle -N "$orig_saved1" "${orig_saved3#user:}"
- fi
- fi
- else
- (( quiet )) || builtin print "Problem (2) during handling of widget \`$orig_saved1' (contents: $orig_saved2)"
+ done
+
+ #
+ # 5. Restore Zle state
+ #
+
+ local -a keys
+ keys=( "${(@on)ZI[(I)TIME_<->_*]}" )
+ integer keys_size=${#keys}
+ () {
+ setopt localoptions extendedglob noksharrays typesetsilent
+ typeset -a restore_widgets skip_delete
+ local wid
+ restore_widgets=( "${(z)ZI[WIDGETS_SAVED__$uspl2]}" )
+ for wid in "${(Oa)restore_widgets[@]}"; do
+ [[ -z "$wid" ]] && continue
+ wid="${(Q)wid}"
+ typeset -a orig_saved
+ orig_saved=( "${(z)wid}" )
+ local tpe="${orig_saved[1]}"
+ local orig_saved1="${(Q)orig_saved[2]}" # Original widget
+ local comp_wid="${(Q)orig_saved[3]}"
+ local orig_saved2="${(Q)orig_saved[4]}" # Saved target function
+ local orig_saved3="${(Q)orig_saved[5]}" # Saved previous $widget's contents
+ local found_time_key="${keys[(r)TIME_<->_${uspl2//\//---}]}" to_process_plugin
+ integer found_time_idx=0 idx=0
+ to_process_plugin=""
+ [[ "$found_time_key" = (#b)TIME_(<->)_* ]] && found_time_idx="${match[1]}"
+ if (( found_time_idx )); then # Must be true
+ for (( idx = found_time_idx + 1; idx <= keys_size; ++ idx )); do
+ found_time_key="${keys[(r)TIME_${idx}_*]}"
+ local oth_uspl2=""
+ [[ "$found_time_key" = (#b)TIME_${idx}_(*) ]] && oth_uspl2="${match[1]//---//}"
+ local -a entry_splitted
+ entry_splitted=( "${(z@)ZI[WIDGETS_SAVED__$oth_uspl2]}" )
+ integer found_idx="${entry_splitted[(I)(-N|-C)\ $orig_saved1\\\ *]}"
+ local -a entry_splitted2
+ entry_splitted2=( "${(z@)ZI[BINDKEYS__$oth_uspl2]}" )
+ integer found_idx2="${entry_splitted2[(I)*\ $orig_saved1\ *]}"
+ if (( found_idx || found_idx2 ))
+ then
+ # Skip multiple loads of the same plugin
+ # TODO: Fully handle multiple plugin loads
+ if [[ "$oth_uspl2" != "$uspl2" ]]; then
+ to_process_plugin="$oth_uspl2"
+ break # Only the first one is needed
fi
+ fi
done
- }
-
- typeset -a delete_widgets
- delete_widgets=( "${(z)ZI[WIDGETS_DELETE__$uspl2]}" )
- local wid
- for wid in "${(Oa)delete_widgets[@]}"; do
- [[ -z "$wid" ]] && continue
- wid="${(Q)wid}"
- if [[ -n "${skip_delete[(r)$wid]}" ]]; then
- builtin print "Would delete $wid"
+ if [[ -n "$to_process_plugin" ]]; then
+ if (( !found_idx && !found_idx2 )); then
+ (( quiet )) || builtin print "Problem (1) during handling of widget \`$orig_saved1' (contents: $orig_saved2)"
continue
- fi
- if [[ "${ZI_ZLE_HOOKS_LIST[$wid]}" = "1" ]]; then
- (( quiet )) || builtin print "Removing Zle hook \`$wid'"
+ fi
+ (( quiet )) || builtin print "Chaining widget \`$orig_saved1' to plugin $oth_uspl2"
+ local -a oth_orig_saved
+ if (( found_idx )) {
+ oth_orig_saved=( "${(z)${(Q)entry_splitted[found_idx]}}" )
+ local oth_fun="${oth_orig_saved[4]}"
+ # oth_orig_saved[2]="${(q)orig_saved2}" # not do this, because
+ # we don't want to call other plugin's function at any moment
+ oth_orig_saved[5]="${(q)orig_saved3}" # chain up the widget
+ entry_splitted[found_idx]="${(q)${(j: :)oth_orig_saved}}"
+ ZI[WIDGETS_SAVED__$oth_uspl2]="${(j: :)entry_splitted}"
+ } else {
+ oth_orig_saved=( "${(z)${(Q)entry_splitted2[found_idx2]}}" )
+ local oth_fun="${widgets[${oth_orig_saved[3]}]#*:}"
+ }
+ integer idx="${functions[$orig_saved2][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}"
+ if (( idx <= ${#functions[$orig_saved2]} ))
+ then
+ local prefix_X="${match[1]#\{}"
+ [[ $prefix_X != \$* ]] && prefix_X="${prefix_X%\}}"
+ idx="${functions[$oth_fun][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}"
+ if (( idx <= ${#functions[$oth_fun]} )); then
+ match[1]="${match[1]#\{}"
+ [[ ${match[1]} != \$* ]] && match[1]="${match[1]%\}}"
+ eval "local oth_prefix_uspl2_X=\"${match[1]}\""
+ if [[ "${widgets[$prefix_X]}" = builtin ]]; then
+ (( quiet )) || builtin print "Builtin-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)"
+ zle -A ".${prefix_X#.}" "$oth_prefix_uspl2_X"
+ elif [[ "${widgets[$prefix_X]}" = completion:* ]]; then
+ (( quiet )) || builtin print "Chain*-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)"
+ zle -C "$oth_prefix_uspl2_X" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}"
+ else
+ (( quiet )) || builtin print "Chain-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)"
+ zle -N "$oth_prefix_uspl2_X" "${widgets[$prefix_X]#user:}"
+ fi
+ fi
+ # The alternate method
+ # skip_delete+=( "${match[1]}" )
+ # functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}"
+ fi
else
- (( quiet )) || builtin print "Removing Zle widget \`$wid'"
+ (( quiet )) || builtin print "Restoring Zle widget $orig_saved1"
+ if [[ "$orig_saved3" = builtin ]]; then
+ zle -A ".$orig_saved1" "$orig_saved1"
+ elif [[ "$orig_saved3" = completion:* ]]; then
+ zle -C "$orig_saved1" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}"
+ else
+ zle -N "$orig_saved1" "${orig_saved3#user:}"
+ fi
fi
- zle -D "$wid"
- done
-
- #
- # 6. Unfunction
- #
-
- .zi-diff-functions-compute "$uspl2"
- typeset -a func
- func=( "${(z)ZI[FUNCTIONS__$uspl2]}" )
- local f
- for f in "${(on)func[@]}"; do
- [[ -z "$f" ]] && continue
- f="${(Q)f}"
- (( quiet )) || builtin print "Deleting function $f"
- (( ${+functions[$f]} )) && unfunction -- "$f"
- (( ${+precmd_functions} )) && precmd_functions=( ${precmd_functions[@]:#$f} )
- (( ${+preexec_functions} )) && preexec_functions=( ${preexec_functions[@]:#$f} )
- (( ${+chpwd_functions} )) && chpwd_functions=( ${chpwd_functions[@]:#$f} )
- (( ${+periodic_functions} )) && periodic_functions=( ${periodic_functions[@]:#$f} )
- (( ${+zshaddhistory_functions} )) && zshaddhistory_functions=( ${zshaddhistory_functions[@]:#$f} )
- (( ${+zshexit_functions} )) && zshexit_functions=( ${zshexit_functions[@]:#$f} )
- done
-
- #
- # 7. Clean up FPATH and PATH
- #
-
- .zi-diff-env-compute "$uspl2"
-
- # Have to iterate over $path elements and
- # skip those that were added by the plugin
- typeset -a new elem p
- elem=( "${(z)ZI[PATH__$uspl2]}" )
- for p in "${path[@]}"; do
- if [[ -z "${elem[(r)${(q)p}]}" ]] {
- new+=( "$p" )
- } else {
- (( quiet )) || builtin print "Removing PATH element ${ZI[col-info]}$p${ZI[col-rst]}"
- [[ -d "$p" ]] || (( quiet )) || builtin print "${ZI[col-error]}Warning:${ZI[col-rst]} it didn't exist on disk"
- }
+ else
+ (( quiet )) || builtin print "Problem (2) during handling of widget \`$orig_saved1' (contents: $orig_saved2)"
+ fi
done
- path=( "${new[@]}" )
-
- # The same for $fpath
- elem=( "${(z)ZI[FPATH__$uspl2]}" )
- new=( )
- for p ( "${fpath[@]}" ) {
- if [[ -z "${elem[(r)${(q)p}]}" ]] {
- new+=( "$p" )
- } else {
- (( quiet )) || builtin print "Removing FPATH element ${ZI[col-info]}$p${ZI[col-rst]}"
- [[ -d "$p" ]] || (( quiet )) || builtin print "${ZI[col-error]}Warning:${ZI[col-rst]} it didn't exist on disk"
- }
- }
- fpath=( "${new[@]}" )
-
- #
- # 8. Delete created variables
- #
-
- .zi-diff-parameter-compute "$uspl2"
- empty=0
- .zi-save-set-extendedglob
- [[ "${ZI[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && empty=1
- .zi-restore-extendedglob
-
- if (( empty != 1 )); then
- typeset -A elem_pre elem_post
- elem_pre=( "${(z)ZI[PARAMETERS_PRE__$uspl2]}" )
- elem_post=( "${(z)ZI[PARAMETERS_POST__$uspl2]}" )
-
- # Find variables created or modified
- local wl found
- local -a whitelist
- whitelist=( "${(@Q)${(z@)ZI[ENV-WHITELIST]}}" )
- for k in "${(k)elem_post[@]}"; do
- k="${(Q)k}"
- local v1="${(Q)elem_pre[$k]}"
- local v2="${(Q)elem_post[$k]}"
-
- # "" means a variable was deleted, not created/changed
- if [[ $v2 != '""' ]]; then
- # Don't unset readonly variables
- [[ ${(tP)k} == *-readonly(|-*) ]] && continue
-
- # Don't unset arrays managed by add-zsh-hook,
- # also ignore a few special parameters
- # TODO: remember and remove hooks
- case "$k" in
- (chpwd_functions|precmd_functions|preexec_functions|periodic_functions|zshaddhistory_functions|zshexit_functions|zsh_directory_name_functions)
- continue
- (path|PATH|fpath|FPATH)
- continue;
- ;;
- esac
-
- # Don't unset redefined variables, only newly defined
- # "" means variable didn't exist before plugin load
- # (didn't have a type).
- # Do an exception for the prompt variables.
- if [[ $v1 = '""' || ( $k = (RPROMPT|RPS1|RPS2|PROMPT|PS1|PS2|PS3|PS4) && $v1 != $v2 ) ]]; then
- found=0
- for wl in "${whitelist[@]}"; do
- if [[ "$k" = ${~wl} ]]; then
- found=1
- break
- fi
- done
- if (( !found )); then
- (( quiet )) || builtin print "Unsetting variable $k"
- # Checked that 4.3.17 does support "--"
- # There cannot be parameter starting with
- # "-" but let's defensively use "--" here
- unset -- "$k"
- else
- builtin print "Skipping unset of variable $k (whitelist)"
- fi
- fi
- fi
- done
+ }
+ typeset -a delete_widgets
+ delete_widgets=( "${(z)ZI[WIDGETS_DELETE__$uspl2]}" )
+ local wid
+ for wid in "${(Oa)delete_widgets[@]}"; do
+ [[ -z "$wid" ]] && continue
+ wid="${(Q)wid}"
+ if [[ -n "${skip_delete[(r)$wid]}" ]]; then
+ builtin print "Would delete $wid"
+ continue
fi
-
- #
- # 9. Forget the plugin
- #
-
- if [[ "$uspl2" = "_dtrace/_dtrace" ]]; then
- .zi-clear-debug-report
- (( quiet )) || builtin print "dtrace report saved to \$LASTREPORT"
+ if [[ "${ZI_ZLE_HOOKS_LIST[$wid]}" = "1" ]]; then
+ (( quiet )) || builtin print "Removing Zle hook \`$wid'"
else
- (( quiet )) || builtin print "Unregistering plugin $uspl2col"
- .zi-unregister-plugin "$user" "$plugin" "${sice[teleid]}"
- zsh_loaded_plugins[${zsh_loaded_plugins[(i)$user${${user:#(%|/)*}:+/}$plugin]}]=() # Support Zsh plugin standard
- .zi-clear-report-for "$user" "$plugin"
- (( quiet )) || builtin print "Plugin's report saved to \$LASTREPORT"
+ (( quiet )) || builtin print "Removing Zle widget \`$wid'"
fi
+ zle -D "$wid"
+ done
+
+ #
+ # 6. Unfunction
+ #
+
+ .zi-diff-functions-compute "$uspl2"
+ typeset -a func
+ func=( "${(z)ZI[FUNCTIONS__$uspl2]}" )
+ local f
+ for f in "${(on)func[@]}"; do
+ [[ -z "$f" ]] && continue
+ f="${(Q)f}"
+ (( quiet )) || builtin print "Deleting function $f"
+ (( ${+functions[$f]} )) && unfunction -- "$f"
+ (( ${+precmd_functions} )) && precmd_functions=( ${precmd_functions[@]:#$f} )
+ (( ${+preexec_functions} )) && preexec_functions=( ${preexec_functions[@]:#$f} )
+ (( ${+chpwd_functions} )) && chpwd_functions=( ${chpwd_functions[@]:#$f} )
+ (( ${+periodic_functions} )) && periodic_functions=( ${periodic_functions[@]:#$f} )
+ (( ${+zshaddhistory_functions} )) && zshaddhistory_functions=( ${zshaddhistory_functions[@]:#$f} )
+ (( ${+zshexit_functions} )) && zshexit_functions=( ${zshexit_functions[@]:#$f} )
+ done
+
+ #
+ # 7. Clean up FPATH and PATH
+ #
+
+ .zi-diff-env-compute "$uspl2"
+
+ # Have to iterate over $path elements and
+ # skip those that were added by the plugin
+ typeset -a new elem p
+ elem=( "${(z)ZI[PATH__$uspl2]}" )
+ for p in "${path[@]}"; do
+ if [[ -z "${elem[(r)${(q)p}]}" ]] {
+ new+=( "$p" )
+ } else {
+ (( quiet )) || builtin print "Removing PATH element ${ZI[col-info]}$p${ZI[col-rst]}"
+ [[ -d "$p" ]] || (( quiet )) || builtin print "${ZI[col-error]}Warning:${ZI[col-rst]} it didn't exist on disk"
+ }
+ done
+ path=( "${new[@]}" )
+ # The same for $fpath
+ elem=( "${(z)ZI[FPATH__$uspl2]}" )
+ new=( )
+ for p ( "${fpath[@]}" ) {
+ if [[ -z "${elem[(r)${(q)p}]}" ]] {
+ new+=( "$p" )
+ } else {
+ (( quiet )) || builtin print "Removing FPATH element ${ZI[col-info]}$p${ZI[col-rst]}"
+ [[ -d "$p" ]] || (( quiet )) || builtin print "${ZI[col-error]}Warning:${ZI[col-rst]} it didn't exist on disk"
+ }
+ }
+ fpath=( "${new[@]}" )
+
+ #
+ # 8. Delete created variables
+ #
+
+ .zi-diff-parameter-compute "$uspl2"
+ empty=0
+ .zi-save-set-extendedglob
+ [[ "${ZI[PARAMETERS_POST__$uspl2]}" != *[$'! \t']* ]] && empty=1
+ .zi-restore-extendedglob
+ if (( empty != 1 )); then
+ typeset -A elem_pre elem_post
+ elem_pre=( "${(z)ZI[PARAMETERS_PRE__$uspl2]}" )
+ elem_post=( "${(z)ZI[PARAMETERS_POST__$uspl2]}" )
+ # Find variables created or modified
+ local wl found
+ local -a whitelist
+ whitelist=( "${(@Q)${(z@)ZI[ENV-WHITELIST]}}" )
+ for k in "${(k)elem_post[@]}"; do
+ k="${(Q)k}"
+ local v1="${(Q)elem_pre[$k]}"
+ local v2="${(Q)elem_post[$k]}"
+ # "" means a variable was deleted, not created/changed
+ if [[ $v2 != '""' ]]; then
+ # Don't unset readonly variables
+ [[ ${(tP)k} == *-readonly(|-*) ]] && continue
+ # Don't unset arrays managed by add-zsh-hook,
+ # also ignore a few special parameters
+ # TODO: remember and remove hooks
+ case "$k" in
+ (chpwd_functions|precmd_functions|preexec_functions|periodic_functions|zshaddhistory_functions|zshexit_functions|zsh_directory_name_functions)
+ continue
+ (path|PATH|fpath|FPATH)
+ continue;
+ ;;
+ esac
+ # Don't unset redefined variables, only newly defined
+ # "" means variable didn't exist before plugin load
+ # (didn't have a type).
+ # Do an exception for the prompt variables.
+ if [[ $v1 = '""' || ( $k = (RPROMPT|RPS1|RPS2|PROMPT|PS1|PS2|PS3|PS4) && $v1 != $v2 ) ]]; then
+ found=0
+ for wl in "${whitelist[@]}"; do
+ if [[ "$k" = ${~wl} ]]; then
+ found=1
+ break
+ fi
+ done
+ if (( !found )); then
+ (( quiet )) || builtin print "Unsetting variable $k"
+ # Checked that 4.3.17 does support "--"
+ # There cannot be parameter starting with
+ # "-" but let's defensively use "--" here
+ unset -- "$k"
+ else
+ builtin print "Skipping unset of variable $k (whitelist)"
+ fi
+ fi
+ fi
+ done
+ fi
+
+ #
+ # 9. Forget the plugin
+ #
+
+ if [[ "$uspl2" = "_dtrace/_dtrace" ]]; then
+ .zi-clear-debug-report
+ (( quiet )) || builtin print "dtrace report saved to \$LASTREPORT"
+ else
+ (( quiet )) || builtin print "Unregistering plugin $uspl2col"
+ .zi-unregister-plugin "$user" "$plugin" "${sice[teleid]}"
+ zsh_loaded_plugins[${zsh_loaded_plugins[(i)$user${${user:#(%|/)*}:+/}$plugin]}]=() # Support Zsh plugin standard
+ .zi-clear-report-for "$user" "$plugin"
+ (( quiet )) || builtin print "Plugin's report saved to \$LASTREPORT"
+ fi
} # ]]]
# FUNCTION: .zi-show-report [[[
@@ -1307,112 +1175,99 @@ ZI[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-show-report() {
- setopt localoptions extendedglob warncreateglobal typesetsilent noksharrays
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}" uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}"
-
- # Allow debug report
- if [[ "$user/$plugin" != "_dtrace/_dtrace" ]]; then
- .zi-exists-message "$user" "$plugin" || return 1
- fi
-
- # Print title
- builtin printf "${ZI[col-title]}Report for${ZI[col-rst]} %s%s plugin\n"\
- "${user:+${ZI[col-uname]}$user${ZI[col-rst]}}${${user:#(%|/)*}:+/}"\
- "${ZI[col-pname]}$plugin${ZI[col-rst]}"
-
- # Print "----------"
- local msg="Report for $user${${user:#(%|/)*}:+/}$plugin plugin"
- builtin print -- "${ZI[col-bar]}${(r:${#msg}::-:)tmp__}${ZI[col-rst]}"
-
- local -A map
- map=(
- Error: "${ZI[col-error]}"
- Warning: "${ZI[col-error]}"
- Note: "${ZI[col-note]}"
- )
- # Print report gathered via shadowing
- () {
- setopt localoptions extendedglob
- builtin print -rl -- "${(@)${(f@)ZI_REPORTS[$uspl2]}/(#b)(#s)([^[:space:]]##)([[:space:]]##)/${map[${match[1]}]:-${ZI[col-keyword]}}${match[1]}${ZI[col-rst]}${match[2]}}"
- }
-
- # Print report gathered via $functions-diffing
- REPLY=""
- .zi-diff-functions-compute "$uspl2"
- .zi-format-functions "$uspl2"
- [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}Functions created:${ZI[col-rst]}"$'\n'"$REPLY"
-
- # Print report gathered via $options-diffing
- REPLY=""
- .zi-diff-options-compute "$uspl2"
- .zi-format-options "$uspl2"
- [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}Options changed:${ZI[col-rst]}"$'\n'"$REPLY"
-
- # Print report gathered via environment diffing
- REPLY=""
- .zi-diff-env-compute "$uspl2"
- .zi-format-env "$uspl2" "1"
- [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}PATH elements added:${ZI[col-rst]}"$'\n'"$REPLY"
-
- REPLY=""
- .zi-format-env "$uspl2" "2"
- [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}FPATH elements added:${ZI[col-rst]}"$'\n'"$REPLY"
-
- # Print report gathered via parameter diffing
- .zi-diff-parameter-compute "$uspl2"
- .zi-format-parameter "$uspl2"
- [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}Variables added or redefined:${ZI[col-rst]}"$'\n'"$REPLY"
-
- # Print what completions plugin has
- .zi-find-completions-of-plugin "$user" "$plugin"
- typeset -a completions
- completions=( "${reply[@]}" )
-
- if [[ "${#completions[@]}" -ge "1" ]]; then
- builtin print "${ZI[col-p]}Completions:${ZI[col-rst]}"
- .zi-check-which-completions-are-installed "${completions[@]}"
- typeset -a installed
- installed=( "${reply[@]}" )
-
- .zi-check-which-completions-are-enabled "${completions[@]}"
- typeset -a enabled
- enabled=( "${reply[@]}" )
-
- integer count="${#completions[@]}" idx
- for (( idx=1; idx <= count; idx ++ )); do
- builtin print -n "${completions[idx]:t}"
- if [[ "${installed[idx]}" != "1" ]]; then
- builtin print -n " ${ZI[col-uninst]}[not installed]${ZI[col-rst]}"
- else
- if [[ "${enabled[idx]}" = "1" ]]; then
- builtin print -n " ${ZI[col-info]}[enabled]${ZI[col-rst]}"
- else
- builtin print -n " ${ZI[col-error]}[disabled]${ZI[col-rst]}"
- fi
- fi
- builtin print
- done
- builtin print
- fi
+ setopt localoptions extendedglob warncreateglobal typesetsilent noksharrays
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}" uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}"
+ # Allow debug report
+ if [[ "$user/$plugin" != "_dtrace/_dtrace" ]]; then
+ .zi-exists-message "$user" "$plugin" || return 1
+ fi
+ # Print title
+ builtin printf "${ZI[col-title]}Report for${ZI[col-rst]} %s%s plugin\n"\
+ "${user:+${ZI[col-uname]}$user${ZI[col-rst]}}${${user:#(%|/)*}:+/}"\
+ "${ZI[col-pname]}$plugin${ZI[col-rst]}"
+ # Print "----------"
+ local msg="Report for $user${${user:#(%|/)*}:+/}$plugin plugin"
+ builtin print -- "${ZI[col-bar]}${(r:${#msg}::-:)tmp__}${ZI[col-rst]}"
+ local -A map
+ map=(
+ Error: "${ZI[col-error]}"
+ Warning: "${ZI[col-error]}"
+ Note: "${ZI[col-note]}"
+ )
+ # Print report gathered via shadowing
+ () {
+ setopt localoptions extendedglob
+ builtin print -rl -- "${(@)${(f@)ZI_REPORTS[$uspl2]}/(#b)(#s)([^[:space:]]##)([[:space:]]##)/${map[${match[1]}]:-${ZI[col-keyword]}}${match[1]}${ZI[col-rst]}${match[2]}}"
+ }
+ # Print report gathered via $functions-diffing
+ REPLY=""
+ .zi-diff-functions-compute "$uspl2"
+ .zi-format-functions "$uspl2"
+ [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}Functions created:${ZI[col-rst]}"$'\n'"$REPLY"
+ # Print report gathered via $options-diffing
+ REPLY=""
+ .zi-diff-options-compute "$uspl2"
+ .zi-format-options "$uspl2"
+ [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}Options changed:${ZI[col-rst]}"$'\n'"$REPLY"
+ # Print report gathered via environment diffing
+ REPLY=""
+ .zi-diff-env-compute "$uspl2"
+ .zi-format-env "$uspl2" "1"
+ [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}PATH elements added:${ZI[col-rst]}"$'\n'"$REPLY"
+ REPLY=""
+ .zi-format-env "$uspl2" "2"
+ [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}FPATH elements added:${ZI[col-rst]}"$'\n'"$REPLY"
+ # Print report gathered via parameter diffing
+ .zi-diff-parameter-compute "$uspl2"
+ .zi-format-parameter "$uspl2"
+ [[ -n "$REPLY" ]] && builtin print "${ZI[col-p]}Variables added or redefined:${ZI[col-rst]}"$'\n'"$REPLY"
+ # Print what completions plugin has
+ .zi-find-completions-of-plugin "$user" "$plugin"
+ typeset -a completions
+ completions=( "${reply[@]}" )
+ if [[ "${#completions[@]}" -ge "1" ]]; then
+ builtin print "${ZI[col-p]}Completions:${ZI[col-rst]}"
+ .zi-check-which-completions-are-installed "${completions[@]}"
+ typeset -a installed
+ installed=( "${reply[@]}" )
+ .zi-check-which-completions-are-enabled "${completions[@]}"
+ typeset -a enabled
+ enabled=( "${reply[@]}" )
+ integer count="${#completions[@]}" idx
+ for (( idx=1; idx <= count; idx ++ )); do
+ builtin print -n "${completions[idx]:t}"
+ if [[ "${installed[idx]}" != "1" ]]; then
+ builtin print -n " ${ZI[col-uninst]}[not installed]${ZI[col-rst]}"
+ else
+ if [[ "${enabled[idx]}" = "1" ]]; then
+ builtin print -n " ${ZI[col-info]}[enabled]${ZI[col-rst]}"
+ else
+ builtin print -n " ${ZI[col-error]}[disabled]${ZI[col-rst]}"
+ fi
+ fi
+ builtin print
+ done
+ builtin print
+ fi
} # ]]]
# FUNCTION: .zi-show-all-reports [[[
# Displays reports of all loaded plugins.
#
# User-action entry point.
.zi-show-all-reports() {
- local i
- for i in "${ZI_REGISTERED_PLUGINS[@]}"; do
- [[ "$i" = "_local/zi" ]] && continue
- .zi-show-report "$i"
- done
+ local i
+ for i in "${ZI_REGISTERED_PLUGINS[@]}"; do
+ [[ "$i" = "_local/zi" ]] && continue
+ .zi-show-report "$i"
+ done
} # ]]]
# FUNCTION: .zi-show-debug-report [[[
# Displays dtrace report (data recorded in interactive session).
#
# User-action entry point.
.zi-show-debug-report() {
- .zi-show-report "_dtrace/_dtrace"
+ .zi-show-report "_dtrace/_dtrace"
} # ]]]
# FUNCTION: .zi-update-or-status [[[
# Updates (git pull) or does `git status' for given plugin.
@@ -1423,335 +1278,322 @@ ZI[EXTENDED_GLOB]=""
# $2 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin)
# $3 - plugin (only when $1 - i.e. user - given)
.zi-update-or-status() {
- # Set the localtraps option.
- emulate -LR zsh
- setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops
-
- local -a arr
- ZI[first-plugin-mark]=${${ZI[first-plugin-mark]:#init}:-1}
- ZI[-r/--reset-opt-hook-has-been-run]=0
-
- # Deliver and withdraw the `m` function when finished.
- .zi-set-m-func set
- trap ".zi-set-m-func unset" EXIT
-
- integer retval was_snippet
- .zi-two-paths "$2${${2:#(%|/)*}:+${3:+/}}$3"
- if [[ -d ${reply[-4]} || -d ${reply[-2]} ]]; then
- .zi-update-or-status-snippet "$1" "$2${${2:#(%|/)*}:+${3:+/}}$3"
- retval=$?
- was_snippet=1
+ # Set the localtraps option.
+ emulate -LR zsh
+ setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops
+ local -a arr
+ ZI[first-plugin-mark]=${${ZI[first-plugin-mark]:#init}:-1}
+ ZI[-r/--reset-opt-hook-has-been-run]=0
+ # Deliver and withdraw the `m` function when finished.
+ .zi-set-m-func set
+ trap ".zi-set-m-func unset" EXIT
+ integer retval hook_rc was_snippet
+ .zi-two-paths "$2${${2:#(%|/)*}:+${3:+/}}$3"
+ if [[ -d ${reply[-4]} || -d ${reply[-2]} ]]; then
+ .zi-update-or-status-snippet "$1" "$2${${2:#(%|/)*}:+${3:+/}}$3"
+ retval=$?
+ was_snippet=1
+ fi
+ .zi-any-to-user-plugin "$2" "$3"
+ local user=${reply[-2]} plugin=${reply[-1]} st=$1 \
+ local_dir filename is_snippet key \
+ id_as="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}"
+ local -A ice
+ if (( was_snippet )) {
+ .zi-exists-physically "$user" "$plugin" || return $retval
+ .zi-any-colorify-as-uspl2 "$2" "$3"
+ (( !OPTS[opt_-q,--quiet] )) && \
+ +zi-message "{msg2}Updating also \`$REPLY{rst}{msg2}'" \
+ "plugin (already updated a snippet of the same name){…}{rst}"
+ } else {
+ .zi-exists-physically-message "$user" "$plugin" || return 1
+ }
+ if [[ $st = status ]]; then
+ ( builtin cd -q ${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}; command git status; )
+ return $retval
+ fi
+ command rm -f ${TMPDIR:-${TMPDIR:-/tmp}}/zi-execs.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zi.installed_comps.$$.lst \
+ ${TMPDIR:-${TMPDIR:-/tmp}}/zi.skipped_comps.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zi.compiled.$$.lst
+ # A flag for the annexes. 0 – no new commits, 1 - run-atpull mode,
+ # 2 – full update/there are new commits to download, 3 - full but
+ # a forced download (i.e.: the medium doesn't allow to peek update)
+ ZI[annex-multi-flag:pull-active]=0
+ (( ${#ICE[@]} > 0 )) && { ZI_SICE[$user${${user:#(%|/)*}:+/}$plugin]=""; local nf="-nftid"; }
+ .zi-compute-ice "$user${${user:#(%|/)*}:+/}$plugin" "pack$nf" \
+ ice local_dir filename is_snippet || return 1
+ .zi-any-to-user-plugin ${ice[teleid]:-$id_as}
+ user=${reply[1]} plugin=${reply[2]}
+ local repo="${${${(M)id_as#%}:+${id_as#%}}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}"
+ # Run annexes' preinit hooks
+ local -a arr
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" ${${key##(zi|z-annex) hook:}%% <->} update || \
+ return $(( 10 - $? ))
+ done
+ # Check if repository has a remote set, if it is _local
+ if [[ -f $local_dir/.git/config ]]; then
+ local -a config
+ config=( ${(f)"$(<$local_dir/.git/config)"} )
+ if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then
+ (( !OPTS[opt_-q,--quiet] )) && {
+ .zi-any-colorify-as-uspl2 "$id_as"
+ [[ $id_as = _local/* ]] && builtin print -r -- "Skipping local plugin $REPLY" || \
+ builtin print -r -- "$REPLY doesn't have a remote set, will not fetch"
+ }
+ return 1
fi
-
- .zi-any-to-user-plugin "$2" "$3"
- local user=${reply[-2]} plugin=${reply[-1]} st=$1 \
- local_dir filename is_snippet key \
- id_as="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}"
- local -A ice
-
- if (( was_snippet )) {
- .zi-exists-physically "$user" "$plugin" || return $retval
- .zi-any-colorify-as-uspl2 "$2" "$3"
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message "{msg2}Updating also \`$REPLY{rst}{msg2}'" \
- "plugin (already updated a snippet of the same name){…}{rst}"
+ fi
+ command rm -f $local_dir/.zi_lastupd
+ if (( 1 )); then
+ if [[ -z ${ice[is_release]} && ${ice[from]} = (gh-r|github-rel|cygwin) ]] {
+ ice[is_release]=true
+ }
+ integer count is_release=0
+ for (( count = 1; count <= 5; ++ count )) {
+ if (( ${+ice[is_release${count:#1}]} )) {
+ is_release=1
+ }
+ }
+ (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source ${ZI[BIN_DIR]}"/lib/zsh/install.zsh"
+ if [[ $ice[from] == (gh-r|github-rel) ]] {
+ {
+ ICE=( "${(kv)ice[@]}" )
+ .zi-get-latest-gh-r-url-part "$user" "$plugin" || return $?
+ } always {
+ ICE=()
+ }
} else {
- .zi-exists-physically-message "$user" "$plugin" || return 1
+ REPLY=""
}
-
- if [[ $st = status ]]; then
- ( builtin cd -q ${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}; command git status; )
- return $retval
- fi
-
- command rm -f ${TMPDIR:-${TMPDIR:-/tmp}}/zi-execs.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zi.installed_comps.$$.lst \
- ${TMPDIR:-${TMPDIR:-/tmp}}/zi.skipped_comps.$$.lst ${TMPDIR:-${TMPDIR:-/tmp}}/zi.compiled.$$.lst
-
- # A flag for the annexes. 0 – no new commits, 1 - run-atpull mode,
- # 2 – full update/there are new commits to download, 3 - full but
- # a forced download (i.e.: the medium doesn't allow to peek update)
- ZI[annex-multi-flag:pull-active]=0
-
- (( ${#ICE[@]} > 0 )) && { ZI_SICE[$user${${user:#(%|/)*}:+/}$plugin]=""; local nf="-nftid"; }
-
- .zi-compute-ice "$user${${user:#(%|/)*}:+/}$plugin" "pack$nf" \
- ice local_dir filename is_snippet || return 1
-
- .zi-any-to-user-plugin ${ice[teleid]:-$id_as}
- user=${reply[1]} plugin=${reply[2]}
-
- local repo="${${${(M)id_as#%}:+${id_as#%}}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}"
-
- # Run annexes' preinit hooks
- local -a arr
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" ${${key##(zi|z-annex) hook:}%% <->} update || \
- return $(( 10 - $? ))
- done
-
- # Check if repository has a remote set, if it is _local
- if [[ -f $local_dir/.git/config ]]; then
- local -a config
- config=( ${(f)"$(<$local_dir/.git/config)"} )
- if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then
- (( !OPTS[opt_-q,--quiet] )) && {
- .zi-any-colorify-as-uspl2 "$id_as"
- [[ $id_as = _local/* ]] && builtin print -r -- "Skipping local plugin $REPLY" || \
- builtin print -r -- "$REPLY doesn't have a remote set, will not fetch"
- }
- return 1
- fi
- fi
-
- command rm -f $local_dir/.zi_lastupd
-
- if (( 1 )); then
- if [[ -z ${ice[is_release]} && ${ice[from]} = (gh-r|github-rel|cygwin) ]] {
- ice[is_release]=true
- }
-
- integer count is_release=0
- for (( count = 1; count <= 5; ++ count )) {
- if (( ${+ice[is_release${count:#1}]} )) {
- is_release=1
- }
- }
-
- (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source ${ZI[BIN_DIR]}"/lib/zsh/install.zsh"
- if [[ $ice[from] == (gh-r|github-rel) ]] {
- {
- ICE=( "${(kv)ice[@]}" )
- .zi-get-latest-gh-r-url-part "$user" "$plugin" || return $?
- } always {
- ICE=()
- }
+ if (( is_release )) {
+ count=0
+ for REPLY ( $reply ) {
+ count+=1
+ local version=${REPLY/(#b)(\/[^\/]##)(#c4,4)\/([^\/]##)*/${match[2]}}
+ if [[ ${ice[is_release${count:#1}]} = $REPLY ]] {
+ (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )) && \
+ ZI[annex-multi-flag:pull-active]=1 || \
+ ZI[annex-multi-flag:pull-active]=0
} else {
- REPLY=""
+ ZI[annex-multi-flag:pull-active]=2
+ break
}
-
- if (( is_release )) {
- count=0
- for REPLY ( $reply ) {
- count+=1
- local version=${REPLY/(#b)(\/[^\/]##)(#c4,4)\/([^\/]##)*/${match[2]}}
- if [[ ${ice[is_release${count:#1}]} = $REPLY ]] {
- (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )) && \
- ZI[annex-multi-flag:pull-active]=1 || \
- ZI[annex-multi-flag:pull-active]=0
- } else {
- ZI[annex-multi-flag:pull-active]=2
- break
- }
- }
- if (( ZI[annex-multi-flag:pull-active] <= 1 && !OPTS[opt_-q,--quiet] )) {
- builtin print -- "\rBinary release already up to date (version: $version)"
- }
+ }
+ if (( ZI[annex-multi-flag:pull-active] <= 1 && !OPTS[opt_-q,--quiet] )) {
+ builtin print -- "\rBinary release already up to date (version: $version)"
+ }
+ }
+ if (( 1 )) {
+ if (( ZI[annex-multi-flag:pull-active] >= 1 )) {
+ if (( OPTS[opt_-q,--quiet] && !PUPDATE )) {
+ .zi-any-colorify-as-uspl2 "$id_as"
+ (( ZI[first-plugin-mark] )) && {
+ ZI[first-plugin-mark]=0
+ } || builtin print
+ builtin print "\rUpdating $REPLY"
}
-
- if (( 1 )) {
- if (( ZI[annex-multi-flag:pull-active] >= 1 )) {
- if (( OPTS[opt_-q,--quiet] && !PUPDATE )) {
- .zi-any-colorify-as-uspl2 "$id_as"
- (( ZI[first-plugin-mark] )) && {
- ZI[first-plugin-mark]=0
- } || builtin print
- builtin print "\rUpdating $REPLY"
- }
-
- ICE=( "${(kv)ice[@]}" )
- # Run annexes' atpull hooks (the before atpull-ice ones).
- # The gh-r / GitHub releases block.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
- ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update:bin
- done
-
- if (( ZI[annex-multi-flag:pull-active] >= 2 )) {
- if ! .zi-setup-plugin-dir "$user" "$plugin" "$id_as" release -u $version; then
- ZI[annex-multi-flag:pull-active]=0
- fi
- if (( OPTS[opt_-q,--quiet] != 1 )) {
- builtin print
- }
- }
- ICE=()
+ ICE=( "${(kv)ice[@]}" )
+ # Run annexes' atpull hooks (the before atpull-ice ones).
+ # The gh-r / GitHub releases block.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
+ ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update:bin
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
+ if (( ZI[annex-multi-flag:pull-active] >= 2 )) {
+ if ! .zi-setup-plugin-dir "$user" "$plugin" "$id_as" release -u $version; then
+ ZI[annex-multi-flag:pull-active]=0
+ fi
+ if (( OPTS[opt_-q,--quiet] != 1 )) {
+ builtin print
+ }
+ }
+ ICE=()
+ }
+ }
+ if [[ -d $local_dir/.git ]] && ( builtin cd -q $local_dir ; git show-ref --verify --quiet refs/heads/main ); then
+ local main_branch=main
+ else
+ local main_branch=master
+ fi
+ if (( ! is_release )) {
+ ( builtin cd -q "$local_dir" || return 1
+ integer had_output=0
+ local IFS=$'\n'
+ command git fetch --quiet && \
+ command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s%n' ..FETCH_HEAD | \
+ while read line; do
+ [[ -n ${line%%[[:space:]]##} ]] && {
+ [[ $had_output -eq 0 ]] && {
+ had_output=1
+ if (( OPTS[opt_-q,--quiet] && !PUPDATE )) {
+ .zi-any-colorify-as-uspl2 "$id_as"
+ (( ZI[first-plugin-mark] )) && {
+ ZI[first-plugin-mark]=0
+ } || builtin print
+ builtin print "Updating $REPLY"
}
+ }
+ builtin print $line
}
-
- if [[ -d $local_dir/.git ]] && ( builtin cd -q $local_dir ; git show-ref --verify --quiet refs/heads/main ); then
- local main_branch=main
- else
- local main_branch=master
- fi
-
- if (( ! is_release )) {
- ( builtin cd -q "$local_dir" || return 1
- integer had_output=0
- local IFS=$'\n'
- command git fetch --quiet && \
- command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s%n' ..FETCH_HEAD | \
- while read line; do
- [[ -n ${line%%[[:space:]]##} ]] && {
- [[ $had_output -eq 0 ]] && {
- had_output=1
- if (( OPTS[opt_-q,--quiet] && !PUPDATE )) {
- .zi-any-colorify-as-uspl2 "$id_as"
- (( ZI[first-plugin-mark] )) && {
- ZI[first-plugin-mark]=0
- } || builtin print
- builtin print "Updating $REPLY"
- }
- }
- builtin print $line
- }
- done | \
- command tee .zi_lastupd | \
- .zi-pager &
-
- integer pager_pid=$!
- { sleep 20 && kill -9 $pager_pid 2>/dev/null 1>&2; } &!
- { wait $pager_pid; } > /dev/null 2>&1
-
- local -a log
- { log=( ${(@f)"$(<$local_dir/.zi_lastupd)"} ); } 2>/dev/null
- command rm -f $local_dir/.zi_lastupd
-
- if [[ ${#log} -gt 0 ]] {
- ZI[annex-multi-flag:pull-active]=2
- } else {
- if (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )) {
- ZI[annex-multi-flag:pull-active]=1
-
- # Handle the snippet/plugin boundary in the messages
- if (( OPTS[opt_-q,--quiet] && !PUPDATE )) {
- .zi-any-colorify-as-uspl2 "$id_as"
- (( ZI[first-plugin-mark] )) && {
- ZI[first-plugin-mark]=0
- } || builtin print
- builtin print "\rUpdating $REPLY"
- }
- } else {
- ZI[annex-multi-flag:pull-active]=0
- }
- }
-
- if (( ZI[annex-multi-flag:pull-active] >= 1 )) {
- ICE=( "${(kv)ice[@]}" )
- # Run annexes' atpull hooks (the before atpull-ice ones).
- # The regular Git-plugins block.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
- ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update:git
- done
- ICE=()
- (( ZI[annex-multi-flag:pull-active] >= 2 )) && command git pull --no-stat ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command egrep -v '(FETCH_HEAD|up.to.date\.|From.*://)'
- }
- return ${ZI[annex-multi-flag:pull-active]}
- )
- ZI[annex-multi-flag:pull-active]=$?
+ done | \
+ command tee .zi_lastupd | \
+ .zi-pager &
+ integer pager_pid=$!
+ { sleep 20 && kill -9 $pager_pid 2>/dev/null 1>&2; } &!
+ { wait $pager_pid; } > /dev/null 2>&1
+ local -a log
+ { log=( ${(@f)"$(<$local_dir/.zi_lastupd)"} ); } 2>/dev/null
+ command rm -f $local_dir/.zi_lastupd
+ if [[ ${#log} -gt 0 ]] {
+ ZI[annex-multi-flag:pull-active]=2
+ } else {
+ if (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )) {
+ ZI[annex-multi-flag:pull-active]=1
+ # Handle the snippet/plugin boundary in the messages
+ if (( OPTS[opt_-q,--quiet] && !PUPDATE )) {
+ .zi-any-colorify-as-uspl2 "$id_as"
+ (( ZI[first-plugin-mark] )) && {
+ ZI[first-plugin-mark]=0
+ } || builtin print
+ builtin print "\rUpdating $REPLY"
+ }
+ } else {
+ ZI[annex-multi-flag:pull-active]=0
}
-
- if [[ -d $local_dir/.git ]]; then
- (
- builtin cd -q "$local_dir" # || return 1 - don't return, maybe it's some hook's logic
- if (( OPTS[opt_-q,--quiet] )) {
- command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} &> /dev/null
- } else {
- command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command egrep -v '(FETCH_HEAD|up.to.date\.|From.*://)'
- }
- )
- fi
- if [[ -n ${(v)ice[(I)(mv|cp|atpull|ps-on-update|cargo)]} || $+ice[sbin]$+ice[make]$+ice[extract] -ne 0 ]] {
- if (( !OPTS[opt_-q,--quiet] && ZI[annex-multi-flag:pull-active] == 1 )) {
- +zi-message -n "{pre}[update]{msg3} Continuing with the update because "
- (( ${+ice[run-atpull]} )) && \
- +zi-message "{ice}run-atpull{apo}''{msg3} ice given.{rst}" || \
- +zi-message "{opt}-u{msg3}/{opt}--urge{msg3} given.{rst}"
+ }
+ if (( ZI[annex-multi-flag:pull-active] >= 1 )) {
+ ICE=( "${(kv)ice[@]}" )
+ # Run annexes' atpull hooks (the before atpull-ice ones).
+ # The regular Git-plugins block.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
+ ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update:git
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
}
+ done
+ ICE=()
+ (( ZI[annex-multi-flag:pull-active] >= 2 )) && command git pull --no-stat ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command egrep -v '(FETCH_HEAD|up.to.date\.|From.*://)'
+ }
+ return ${ZI[annex-multi-flag:pull-active]}
+ )
+ ZI[annex-multi-flag:pull-active]=$?
+ }
+ if [[ -d $local_dir/.git ]]; then
+ (
+ builtin cd -q "$local_dir" # || return 1 - don't return, maybe it's some hook's logic
+ if (( OPTS[opt_-q,--quiet] )) {
+ command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} &> /dev/null
+ } else {
+ command git pull --recurse-submodules ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command egrep -v '(FETCH_HEAD|up.to.date\.|From.*://)'
}
-
- # Any new commits?
- if (( ZI[annex-multi-flag:pull-active] >= 1 )) {
- ICE=( "${(kv)ice[@]}" )
- # Run annexes' atpull hooks (the before atpull[^!]…-ice ones).
- # Block common for Git and gh-r plugins.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-pre <->]}
- ${${ICE[atpull]:#\!*}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
- ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update
- done
-
- # Run annexes' atpull hooks (the after atpull-ice ones).
- # Block common for Git and gh-r plugins.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:atpull-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:atpull-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update
- done
- ICE=()
- }
-
- # Store ices to disk at update of plugin
- .zi-store-ices "$local_dir/._zi" ice "" "" "" ""
+ )
fi
-
- # Run annexes' atpull hooks (the `always' after atpull-ice ones)
- # Block common for Git and gh-r plugins.
- ICE=( "${(kv)ice[@]}" )
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:%atpull-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:%atpull-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:%atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update:$ZI[annex-multi-flag:pull-active]
- done
- ICE=()
-
- typeset -ga INSTALLED_EXECS
- { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi-execs.$$.lst)}" ) } 2>/dev/null
-
- if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zi.skipped_comps.$$.lst || -e ${TMPDIR:-${TMPDIR:-/tmp}}/zi.installed_comps.$$.lst ]] {
- typeset -ga INSTALLED_COMPS SKIPPED_COMPS
- { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi.installed_comps.$$.lst)}" ) } 2>/dev/null
- { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi.skipped_comps.$$.lst)}" ) } 2>/dev/null
+ if [[ -n ${(v)ice[(I)(mv|cp|atpull|ps-on-update|cargo)]} || $+ice[sbin]$+ice[make]$+ice[extract] -ne 0 ]] {
+ if (( !OPTS[opt_-q,--quiet] && ZI[annex-multi-flag:pull-active] == 1 )) {
+ +zi-message -n "{pre}[update]{msg3} Continuing with the update because "
+ (( ${+ice[run-atpull]} )) && \
+ +zi-message "{ice}run-atpull{apo}''{msg3} ice given.{rst}" || \
+ +zi-message "{opt}-u{msg3}/{opt}--urge{msg3} given.{rst}"
+ }
}
-
- if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zi.compiled.$$.lst ]] {
- typeset -ga ADD_COMPILED
- { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi.compiled.$$.lst)}" ) } 2>/dev/null
+ # Any new commits?
+ if (( ZI[annex-multi-flag:pull-active] >= 1 )) {
+ ICE=( "${(kv)ice[@]}" )
+ # Run annexes' atpull hooks (the before atpull[^!]…-ice ones).
+ # Block common for Git and gh-r plugins.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-pre <->]}
+ ${${ICE[atpull]:#\!*}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
+ ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update
+ hook_rc="$?"
+ [[ "$hook_rc" -ne 0 ]] && {
+ # note: this will effectively return the last != 0 rc
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
+ # Run annexes' atpull hooks (the after atpull-ice ones).
+ # Block common for Git and gh-r plugins.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:atpull-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:atpull-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update
+ hook_rc="$?"
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
+ ICE=()
}
-
- if (( PUPDATE && ZI[annex-multi-flag:pull-active] > 0 )) {
- builtin print ${ZI[annex-multi-flag:pull-active]} >! $PUFILE.ind
+ # Store ices to disk at update of plugin
+ .zi-store-ices "$local_dir/._zi" ice "" "" "" ""
+ fi
+ # Run annexes' atpull hooks (the `always' after atpull-ice ones)
+ # Block common for Git and gh-r plugins.
+ ICE=( "${(kv)ice[@]}" )
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:%atpull-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:%atpull-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:%atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_dir" "${${key##(zi|z-annex) hook:}%% <->}" update:$ZI[annex-multi-flag:pull-active]
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
}
-
- return $retval
+ done
+ ICE=()
+ typeset -ga INSTALLED_EXECS
+ { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi-execs.$$.lst)}" ) } 2>/dev/null
+ if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zi.skipped_comps.$$.lst || -e ${TMPDIR:-${TMPDIR:-/tmp}}/zi.installed_comps.$$.lst ]] {
+ typeset -ga INSTALLED_COMPS SKIPPED_COMPS
+ { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi.installed_comps.$$.lst)}" ) } 2>/dev/null
+ { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi.skipped_comps.$$.lst)}" ) } 2>/dev/null
+ }
+ if [[ -e ${TMPDIR:-${TMPDIR:-/tmp}}/zi.compiled.$$.lst ]] {
+ typeset -ga ADD_COMPILED
+ { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-${TMPDIR:-/tmp}}/zi.compiled.$$.lst)}" ) } 2>/dev/null
+ }
+ if (( PUPDATE && ZI[annex-multi-flag:pull-active] > 0 )) {
+ builtin print ${ZI[annex-multi-flag:pull-active]} >! $PUFILE.ind
+ }
+ return $retval
} # ]]]
# FUNCTION: .zi-update-or-status-snippet [[[
#
@@ -1760,40 +1602,35 @@ ZI[EXTENDED_GLOB]=""
# $1 - "status" or "update"
# $2 - snippet URL
.zi-update-or-status-snippet() {
- local st="$1" URL="${2%/}" local_dir filename is_snippet
- (( ${#ICE[@]} > 0 )) && { ZI_SICE[$URL]=""; local nf="-nftid"; }
- local -A ICE2
- .zi-compute-ice "$URL" "pack$nf" \
- ICE2 local_dir filename is_snippet || return 1
-
- integer retval
-
- if [[ "$st" = "status" ]]; then
- if (( ${+ICE2[svn]} )); then
- builtin print -r -- "${ZI[col-info]}Status for ${${${local_dir:h}:t}##*--}/${local_dir:t}${ZI[col-rst]}"
- ( builtin cd -q "$local_dir"; command svn status -vu )
- retval=$?
- builtin print
- else
- builtin print -r -- "${ZI[col-info]}Status for ${${local_dir:h}##*--}/$filename${ZI[col-rst]}"
- ( builtin cd -q "$local_dir"; command ls -lth $filename )
- retval=$?
- builtin print
- fi
+ local st="$1" URL="${2%/}" local_dir filename is_snippet
+ (( ${#ICE[@]} > 0 )) && { ZI_SICE[$URL]=""; local nf="-nftid"; }
+ local -A ICE2
+ .zi-compute-ice "$URL" "pack$nf" \
+ ICE2 local_dir filename is_snippet || return 1
+ integer retval
+ if [[ "$st" = "status" ]]; then
+ if (( ${+ICE2[svn]} )); then
+ builtin print -r -- "${ZI[col-info]}Status for ${${${local_dir:h}:t}##*--}/${local_dir:t}${ZI[col-rst]}"
+ ( builtin cd -q "$local_dir"; command svn status -vu )
+ retval=$?
+ builtin print
else
- (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source ${ZI[BIN_DIR]}"/lib/zsh/install.zsh"
- ICE=( "${(kv)ICE2[@]}" )
- .zi-update-snippet "${ICE2[teleid]:-$URL}"
- retval=$?
+ builtin print -r -- "${ZI[col-info]}Status for ${${local_dir:h}##*--}/$filename${ZI[col-rst]}"
+ ( builtin cd -q "$local_dir"; command ls -lth $filename )
+ retval=$?
+ builtin print
fi
-
- ICE=()
-
- if (( PUPDATE && ZI[annex-multi-flag:pull-active] > 0 )) {
- builtin print ${ZI[annex-multi-flag:pull-active]} >! $PUFILE.ind
- }
-
- return $retval
+ else
+ (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source ${ZI[BIN_DIR]}"/lib/zsh/install.zsh"
+ ICE=( "${(kv)ICE2[@]}" )
+ .zi-update-snippet "${ICE2[teleid]:-$URL}"
+ retval=$?
+ fi
+ ICE=()
+ if (( PUPDATE && ZI[annex-multi-flag:pull-active] > 0 )) {
+ builtin print ${ZI[annex-multi-flag:pull-active]} >! $PUFILE.ind
+ }
+ return $retval
}
# ]]]
# FUNCTION: .zi-update-or-status-all [[[
@@ -1803,451 +1640,395 @@ ZI[EXTENDED_GLOB]=""
#
# User-action entry point.
.zi-update-or-status-all() {
- emulate -LR zsh
- setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops
-
- local -F2 SECONDS=0
-
- .zi-self-update -q
-
- [[ $2 = restart ]] && \
- +zi-message "{msg2}Restarting the update with the new codebase loaded.{rst}"$'\n'
-
- local file
- integer sum el
+ emulate -LR zsh
+ setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops
+ local -F2 SECONDS=0
+ .zi-self-update -q
+ [[ $2 = restart ]] && \
+ +zi-message "{msg2}Restarting the update with the new codebase loaded.{rst}"$'\n'
+ local file
+ integer sum el update_rc
+ for file ( "" side install autoload ) {
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/$file.zsh" el; sum+=el
+ }
+ # Reload ZI?
+ if [[ $2 != restart ]] && (( ZI[mtime] + ZI[mtime-side] +
+ ZI[mtime-install] + ZI[mtime-autoload] != sum
+ )) {
+ +zi-message "{msg2}Detected ❮ ZI ❯ update in another session -" \
+ "{pre}reloading ZI{msg2}{…}{rst}"
+ source $ZI[BIN_DIR]/zi.zsh
+ source $ZI[BIN_DIR]/lib/zsh/side.zsh
+ source $ZI[BIN_DIR]/lib/zsh/install.zsh
+ source $ZI[BIN_DIR]/lib/zsh/autoload.zsh
for file ( "" side install autoload ) {
- .zi-get-mtime-into "${ZI[BIN_DIR]}/$file.zsh" el; sum+=el
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/$file.zsh" "ZI[mtime$file]"
}
-
- # Reload ZI?
- if [[ $2 != restart ]] && (( ZI[mtime] + ZI[mtime-side] +
- ZI[mtime-install] + ZI[mtime-autoload] != sum
- )) {
- +zi-message "{msg2}Detected ZI update in another session -" \
- "{pre}reloading ZI{msg2}{…}{rst}"
- source $ZI[BIN_DIR]/zi.zsh
- source $ZI[BIN_DIR]/lib/zsh/side.zsh
- source $ZI[BIN_DIR]/lib/zsh/install.zsh
- source $ZI[BIN_DIR]/lib/zsh/autoload.zsh
- for file ( "" side install autoload ) {
- .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/$file.zsh" "ZI[mtime$file]"
- }
- +zi-message "%B{pname}Done.{rst}"$'\n'
- .zi-update-or-status-all "$1" restart
- return $?
- }
-
- if (( OPTS[opt_-p,--parallel] )) && [[ $1 = update ]] {
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message '{info2}Parallel Update Starts Now{…}{rst}'
- .zi-update-all-parallel
- integer retval=$?
- .zi-compinit 1 1 &>/dev/null
- rehash
- if (( !OPTS[opt_-q,--quiet] )) {
- +zi-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}"
- }
- return $retval
+ +zi-message "%B{pname}Done.{rst}"$'\n'
+ .zi-update-or-status-all "$1" restart
+ return $?
+ }
+ if (( OPTS[opt_-p,--parallel] )) && [[ $1 = update ]] {
+ (( !OPTS[opt_-q,--quiet] )) && \
+ +zi-message '{info2}Parallel Update Starts Now{…}{rst}'
+ .zi-update-all-parallel
+ integer retval=$?
+ .zi-compinit 1 1 &>/dev/null
+ rehash
+ if (( !OPTS[opt_-q,--quiet] )) {
+ +zi-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}"
}
-
- local st=$1 id_as repo snip pd user plugin
+ return $retval
+ }
+ local st=$1 id_as repo snip pd user plugin
integer PUPDATE=0
-
- local -A ICE
-
-
- if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) {
- local -a snipps
- snipps=( ${ZI[SNIPPETS_DIR]}/**/(._zi|._zi|._zplugin)(ND) )
-
- [[ $st != status && ${OPTS[opt_-q,--quiet]} != 1 && -n $snipps ]] && \
- +zi-message "{info}Note:{rst} updating also unloaded snippets"
-
- for snip ( ${ZI[SNIPPETS_DIR]}/**/(._zi|._zi|._zplugin)/mode(D) ) {
- [[ ! -f ${snip:h}/url ]] && continue
- [[ -f ${snip:h}/id-as ]] && \
- id_as="$(<${snip:h}/id-as)" || \
- id_as=
- .zi-update-or-status-snippet "$st" "${id_as:-$(<${snip:h}/url)}"
- ICE=()
- }
- [[ -n $snipps ]] && builtin print
+ local -A ICE
+ if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) {
+ local -a snipps
+ snipps=( ${ZI[SNIPPETS_DIR]}/**/(._zi|._zi|._zplugin)(ND) )
+ [[ $st != status && ${OPTS[opt_-q,--quiet]} != 1 && -n $snipps ]] && \
+ +zi-message "{info}Note:{rst} updating also unloaded snippets"
+ for snip ( ${ZI[SNIPPETS_DIR]}/**/(._zi|._zi|._zplugin)/mode(D) ) {
+ [[ ! -f ${snip:h}/url ]] && continue
+ [[ -f ${snip:h}/id-as ]] && \
+ id_as="$(<${snip:h}/id-as)" || \
+ id_as=
+ .zi-update-or-status-snippet "$st" "${id_as:-$(<${snip:h}/url)}"
+ ICE=()
}
-
- ICE=()
-
- if (( OPTS[opt_-s,--snippets] && !OPTS[opt_-l,--plugins] )) {
- return
- }
-
+ [[ -n $snipps ]] && builtin print
+ }
+ ICE=()
+ if (( OPTS[opt_-s,--snippets] && !OPTS[opt_-l,--plugins] )) {
+ return
+ }
+ if [[ $st = status ]]; then
+ (( !OPTS[opt_-q,--quiet] )) && \
+ +zi-message "{info}Note:{rst} status done also for unloaded plugins"
+ else
+ (( !OPTS[opt_-q,--quiet] )) && \
+ +zi-message "{info}Note:{rst} updating also unloaded plugins"
+ fi
+ ZI[first-plugin-mark]=init
+ for repo in ${ZI[PLUGINS_DIR]}/*; do
+ pd=${repo:t}
+ # Two special cases
+ [[ $pd = custom || $pd = _local---zi ]] && continue
+ .zi-any-colorify-as-uspl2 "$pd"
+ # Check if repository has a remote set
+ if [[ -f $repo/.git/config ]]; then
+ local -a config
+ config=( ${(f)"$(<$repo/.git/config)"} )
+ if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then
+ if (( !OPTS[opt_-q,--quiet] )) {
+ [[ $pd = _local---* ]] && \
+ builtin print -- "\nSkipping local plugin $REPLY" || \
+ builtin print "\n$REPLY doesn't have a remote set, will not fetch"
+ }
+ continue
+ fi
+ fi
+ .zi-any-to-user-plugin "$pd"
+ local user=${reply[-2]} plugin=${reply[-1]}
+ # Must be a git repository or a binary release
+ if [[ ! -d $repo/.git && ! -f $repo/._zi/is_release ]]; then
+ (( !OPTS[opt_-q,--quiet] )) && \
+ builtin print "$REPLY: not a git repository"
+ continue
+ fi
if [[ $st = status ]]; then
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message "{info}Note:{rst} status done also for unloaded plugins"
+ builtin print "\nStatus for plugin $REPLY"
+ ( builtin cd -q "$repo"; command git status )
else
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message "{info}Note:{rst} updating also unloaded plugins"
+ (( !OPTS[opt_-q,--quiet] )) && builtin print "Updating $REPLY" || builtin print -n .
+ .zi-update-or-status update "$user" "$plugin"
+ update_rc=$?
+ # TODO: remember
+ [[ $update_rc -ne 0 ]] && {
+ +zi-message "{warn}Warning: {pid}${user}/${plugin} {warn}update returned {obj}$update_rc"
+ retval=$?
+ }
fi
-
- ZI[first-plugin-mark]=init
-
- for repo in ${ZI[PLUGINS_DIR]}/*; do
- pd=${repo:t}
-
- # Two special cases
- [[ $pd = custom || $pd = _local---zi ]] && continue
-
- .zi-any-colorify-as-uspl2 "$pd"
-
- # Check if repository has a remote set
- if [[ -f $repo/.git/config ]]; then
- local -a config
- config=( ${(f)"$(<$repo/.git/config)"} )
- if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then
- if (( !OPTS[opt_-q,--quiet] )) {
- [[ $pd = _local---* ]] && \
- builtin print -- "\nSkipping local plugin $REPLY" || \
- builtin print "\n$REPLY doesn't have a remote set, will not fetch"
- }
- continue
- fi
- fi
-
- .zi-any-to-user-plugin "$pd"
- local user=${reply[-2]} plugin=${reply[-1]}
-
- # Must be a git repository or a binary release
- if [[ ! -d $repo/.git && ! -f $repo/._zi/is_release ]]; then
- (( !OPTS[opt_-q,--quiet] )) && \
- builtin print "$REPLY: not a git repository"
- continue
- fi
-
- if [[ $st = status ]]; then
- builtin print "\nStatus for plugin $REPLY"
- ( builtin cd -q "$repo"; command git status )
- else
- (( !OPTS[opt_-q,--quiet] )) && builtin print "Updating $REPLY" || builtin print -n .
- .zi-update-or-status update "$user" "$plugin"
- fi
- done
-
- .zi-compinit 1 1 &>/dev/null
- if (( !OPTS[opt_-q,--quiet] )) {
- +zi-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}"
- }
+ done
+ .zi-compinit 1 1 &>/dev/null
+ if (( !OPTS[opt_-q,--quiet] )) {
+ +zi-message "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}"
+ }
+ return "$retval"
} # ]]]
# FUNCTION: .zi-update-in-parallel [[[
.zi-update-all-parallel() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent \
- noshortloops nomonitor nonotify
-
- local id_as repo snip uspl user plugin PUDIR="$(mktemp -d)"
-
- local -A PUAssocArray map
- map=( / -- "=" -EQ- "?" -QM- "&" -AMP- : - )
- local -a files
- integer main_counter counter PUPDATE=1
-
- files=( ${ZI[SNIPPETS_DIR]}/**/(._zi|._zi|._zplugin)/mode(ND) )
- main_counter=${#files}
- if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) {
- for snip ( "${files[@]}" ) {
- main_counter=main_counter-1
- # The continue may cause the tail of processes to
- # fall-through to the following plugins-specific `wait'
- # Should happen only in a very special conditions
- # TODO handle this
- [[ ! -f ${snip:h}/url ]] && continue
- [[ -f ${snip:h}/id-as ]] && \
- id_as="$(<${snip:h}/id-as)" || \
- id_as=
-
- counter+=1
- local ef_id="${id_as:-$(<${snip:h}/url)}"
- local PUFILEMAIN=${${ef_id#/}//(#m)[\/=\?\&:]/${map[$MATCH]}}
- local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out
-
- .zi-update-or-status-snippet "$st" "$ef_id" &>! $PUFILE &
-
- PUAssocArray[$!]=$PUFILE
-
- .zi-wait-for-update-jobs snippets
- }
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent \
+ noshortloops nomonitor nonotify
+
+ local id_as repo snip uspl user plugin PUDIR="$(mktemp -d)"
+
+ local -A PUAssocArray map
+ map=( / -- "=" -EQ- "?" -QM- "&" -AMP- : - )
+ local -a files
+ integer main_counter counter PUPDATE=1
+
+ files=( ${ZI[SNIPPETS_DIR]}/**/(._zi|._zinit|._zplugin)/mode(ND) )
+ main_counter=${#files}
+ if (( OPTS[opt_-s,--snippets] || !OPTS[opt_-l,--plugins] )) {
+ for snip ( "${files[@]}" ) {
+ main_counter=main_counter-1
+ # The continue may cause the tail of processes to
+ # fall-through to the following plugins-specific `wait'
+ # Should happen only in a very special conditions
+ # TODO handle this
+ [[ ! -f ${snip:h}/url ]] && continue
+ [[ -f ${snip:h}/id-as ]] && \
+ id_as="$(<${snip:h}/id-as)" || \
+ id_as=
+ counter+=1
+ local ef_id="${id_as:-$(<${snip:h}/url)}"
+ local PUFILEMAIN=${${ef_id#/}//(#m)[\/=\?\&:]/${map[$MATCH]}}
+ local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out
+
+ .zi-update-or-status-snippet "$st" "$ef_id" &>! $PUFILE &
+
+ PUAssocArray[$!]=$PUFILE
+
+ .zi-wait-for-update-jobs snippets
}
-
- counter=0
- PUAssocArray=()
-
- if (( OPTS[opt_-l,--plugins] || !OPTS[opt_-s,--snippets] )) {
- local -a files2
- files=( ${ZI[PLUGINS_DIR]}/*(ND/) )
-
- # Pre-process plugins
- for repo ( $files ) {
- uspl=${repo:t}
- # Two special cases
- [[ $uspl = custom || $uspl = _local---zi ]] && continue
-
- # Check if repository has a remote set
- if [[ -f $repo/.git/config ]] {
- local -a config
- config=( ${(f)"$(<$repo/.git/config)"} )
- if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]] {
- continue
- }
- }
-
- .zi-any-to-user-plugin "$uspl"
- local user=${reply[-2]} plugin=${reply[-1]}
-
- # Must be a git repository or a binary release
- if [[ ! -d $repo/.git && ! -f $repo/._zi/is_release ]] {
- continue
- }
- files2+=( $repo )
- }
-
- main_counter=${#files2}
- for repo ( "${files2[@]}" ) {
- main_counter=main_counter-1
-
- uspl=${repo:t}
- id_as=${uspl//---//}
-
- counter+=1
- local PUFILEMAIN=${${id_as#/}//(#m)[\/=\?\&:]/${map[$MATCH]}}
- local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out
-
- .zi-any-colorify-as-uspl2 "$uspl"
- +zi-message "Updating $REPLY{…}" >! $PUFILE
-
- .zi-any-to-user-plugin "$uspl"
- local user=${reply[-2]} plugin=${reply[-1]}
-
- .zi-update-or-status update "$user" "$plugin" &>>! $PUFILE &
-
- PUAssocArray[$!]=$PUFILE
-
- .zi-wait-for-update-jobs plugins
-
+ }
+
+ counter=0
+ PUAssocArray=()
+
+ if (( OPTS[opt_-l,--plugins] || !OPTS[opt_-s,--snippets] )) {
+ local -a files2
+ files=( ${ZI[PLUGINS_DIR]}/*(ND/) )
+ # Pre-process plugins
+ for repo ( $files ) {
+ uspl=${repo:t}
+ # Two special cases
+ [[ $uspl = custom || $uspl = _local---zi ]] && continue
+ # Check if repository has a remote set
+ if [[ -f $repo/.git/config ]] {
+ local -a config
+ config=( ${(f)"$(<$repo/.git/config)"} )
+ if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]] {
+ continue
}
+ }
+ .zi-any-to-user-plugin "$uspl"
+ local user=${reply[-2]} plugin=${reply[-1]}
+ # Must be a git repository or a binary release
+ if [[ ! -d $repo/.git && ! -f $repo/._zi/is_release ]] {
+ continue
+ }
+ files2+=( $repo )
}
- # Shouldn't happen
- # (( ${#PUAssocArray} > 0 )) && wait ${(k)PUAssocArray}
+ main_counter=${#files2}
+ for repo ( "${files2[@]}" ) {
+ main_counter=main_counter-1
+ uspl=${repo:t}
+ id_as=${uspl//---//}
+ counter+=1
+ local PUFILEMAIN=${${id_as#/}//(#m)[\/=\?\&:]/${map[$MATCH]}}
+ local PUFILE=$PUDIR/${counter}_$PUFILEMAIN.out
+ .zi-any-colorify-as-uspl2 "$uspl"
+ +zi-message "Updating $REPLY{…}" >! $PUFILE
+ .zi-any-to-user-plugin "$uspl"
+ local user=${reply[-2]} plugin=${reply[-1]}
+ .zi-update-or-status update "$user" "$plugin" &>>! $PUFILE &
+
+ PUAssocArray[$!]=$PUFILE
+
+ .zi-wait-for-update-jobs plugins
+ }
+ }
+ # Shouldn't happen
+ # (( ${#PUAssocArray} > 0 )) && wait ${(k)PUAssocArray}
}
# ]]]
# FUNCTION: .zi-wait-for-update-jobs [[[
.zi-wait-for-update-jobs() {
- local tpe=$1
- if (( counter > OPTS[value] || main_counter == 0 )) {
- wait ${(k)PUAssocArray}
- local ind_file
- for ind_file ( ${^${(von)PUAssocArray}}.ind(DN.) ) {
- command cat ${ind_file:r}
- (( !OPTS[opt_-d,--debug] && !ZI[DEBUG_MODE] )) && \
- command rm -f $ind_file
- }
- (( !OPTS[opt_-d,--debug] && !ZI[DEBUG_MODE] )) && \
- command rm -f ${(v)PUAssocArray}
- counter=0
- PUAssocArray=()
- } elif (( counter == 1 && !OPTS[opt_-q,--quiet] )) {
- +zi-message "{obj}Spawning the next{num}" \
- "${OPTS[value]}{obj} concurrent update jobs" \
- "({msg2}${tpe}{obj}){…}{rst}"
+ local tpe=$1
+ if (( counter > OPTS[value] || main_counter == 0 )) {
+ wait ${(k)PUAssocArray}
+ local ind_file
+ for ind_file ( ${^${(von)PUAssocArray}}.ind(DN.) ) {
+ command cat ${ind_file:r}
+ (( !OPTS[opt_-d,--debug] && !ZI[DEBUG_MODE] )) && \
+ command rm -f $ind_file
}
+ (( !OPTS[opt_-d,--debug] && !ZI[DEBUG_MODE] )) && \
+ command rm -f ${(v)PUAssocArray}
+ counter=0
+ PUAssocArray=()
+ } elif (( counter == 1 && !OPTS[opt_-q,--quiet] )) {
+ +zi-message "{obj}Spawning the next{num}" \
+ "${OPTS[value]}{obj} concurrent update jobs" \
+ "({msg2}${tpe}{obj}){…}{rst}"
+ }
}
# ]]]
# FUNCTION: .zi-show-zstatus [[[
-# Shows ZI status, i.e. number of loaded plugins,
+# Shows ❮ ZI ❯ status, i.e. number of loaded plugins,
# of available completions, etc.
#
# User-action entry point.
.zi-show-zstatus() {
- builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
-
- local infoc="${ZI[col-info2]}"
-
- +zi-message "ZI's main directory: {file}${ZI[HOME_DIR]}{rst}"
- +zi-message "ZI's binary directory: {file}${ZI[BIN_DIR]}{rst}"
- +zi-message "Plugin directory: {file}${ZI[PLUGINS_DIR]}{rst}"
- +zi-message "Completions directory: {file}${ZI[COMPLETIONS_DIR]}{rst}"
-
- # Without _zlocal/zi
- +zi-message "Loaded plugins: {num}$(( ${#ZI_REGISTERED_PLUGINS[@]} - 1 )){rst}"
-
- # Count light-loaded plugins
- integer light=0
- local s
- for s in "${(@v)ZI[(I)STATES__*]}"; do
- [[ "$s" = 1 ]] && (( light ++ ))
- done
- # Without _zlocal/zi
- +zi-message "Light loaded: {num}$(( light - 1 )){rst}"
-
- # Downloaded plugins, without _zlocal/zi, custom
- typeset -a plugins
- plugins=( "${ZI[PLUGINS_DIR]}"/*(DN) )
- +zi-message "Downloaded plugins: {num}$(( ${#plugins} - 1 )){rst}"
-
- # Number of enabled completions, with _zlocal/zi
- typeset -a completions
- completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) )
- +zi-message "Enabled completions: {num}${#completions[@]}{rst}"
-
- # Number of disabled completions, with _zlocal/zi
- completions=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) )
- +zi-message "Disabled completions: {num}${#completions[@]}{rst}"
-
- # Number of completions existing in all plugins
- completions=( "${ZI[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
- +zi-message "Completions available overall: {num}${#completions[@]}{rst}"
-
- # Enumerate snippets loaded
- # }, ${infoc}{rst}", j:, :, {msg}"$'\e[0m, +zi-message h
- +zi-message -n "Snippets loaded: "
- local sni
- for sni in ${(onv)ZI_SNIPPETS[@]}; do
- +zi-message -n "{url}${sni% <[^>]#>}{rst} ${(M)sni%<[^>]##>}, "
- done
- [[ -z $sni ]] && builtin print -n " "
- builtin print '\b\b '
-
- # Number of compiled plugins
- typeset -a matches m
- integer count=0
- matches=( ${ZI[PLUGINS_DIR]}/*/*.zwc(DN) )
-
- local cur_plugin="" uspl1
- for m in "${matches[@]}"; do
- uspl1="${${m:h}:t}"
-
- if [[ "$cur_plugin" != "$uspl1" ]]; then
- (( count ++ ))
- cur_plugin="$uspl1"
- fi
- done
-
- +zi-message "Compiled plugins: {num}$count{rst}"
+ builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
+
+ local infoc="${ZI[col-info2]}"
+
+ +zi-message "❮ ZI ❯ Home directory: {file}${ZI[HOME_DIR]}{rst}"
+ +zi-message "❮ ZI ❯ Binary directory: {file}${ZI[BIN_DIR]}{rst}"
+ +zi-message "❮ ZI ❯ Plugin directory: {file}${ZI[PLUGINS_DIR]}{rst}"
+ +zi-message "❮ ZI ❯ Completions directory: {file}${ZI[COMPLETIONS_DIR]}{rst}"
+ # Without _zlocal/zi
+ +zi-message "Loaded plugins: {num}$(( ${#ZI_REGISTERED_PLUGINS[@]} - 1 )){rst}"
+ # Count light-loaded plugins
+ integer light=0
+ local s
+ for s in "${(@v)ZI[(I)STATES__*]}"; do
+ [[ "$s" = 1 ]] && (( light ++ ))
+ done
+ # Without _zlocal/zi
+ +zi-message "Light loaded: {num}$(( light - 1 )){rst}"
+ # Downloaded plugins, without _zlocal/zi, custom
+ typeset -a plugins
+ plugins=( "${ZI[PLUGINS_DIR]}"/*(DN) )
+ +zi-message "Downloaded plugins: {num}$(( ${#plugins} - 1 )){rst}"
+ # Number of enabled completions, with _zlocal/zi
+ typeset -a completions
+ completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) )
+ +zi-message "Enabled completions: {num}${#completions[@]}{rst}"
+ # Number of disabled completions, with _zlocal/zi
+ completions=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) )
+ +zi-message "Disabled completions: {num}${#completions[@]}{rst}"
+ # Number of completions existing in all plugins
+ completions=( "${ZI[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) )
+ +zi-message "Completions available overall: {num}${#completions[@]}{rst}"
+ # Enumerate snippets loaded
+ # }, ${infoc}{rst}", j:, :, {msg}"$'\e[0m, +zi-message h
+ +zi-message -n "Snippets loaded: "
+ local sni
+ for sni in ${(onv)ZI_SNIPPETS[@]}; do
+ +zi-message -n "{url}${sni% <[^>]#>}{rst} ${(M)sni%<[^>]##>}, "
+ done
+ [[ -z $sni ]] && builtin print -n " "
+ builtin print '\b\b '
+ # Number of compiled plugins
+ typeset -a matches m
+ integer count=0
+ matches=( ${ZI[PLUGINS_DIR]}/*/*.zwc(DN) )
+ local cur_plugin="" uspl1
+ for m in "${matches[@]}"; do
+ uspl1="${${m:h}:t}"
+ if [[ "$cur_plugin" != "$uspl1" ]]; then
+ (( count ++ ))
+ cur_plugin="$uspl1"
+ fi
+ done
+ +zi-message "Compiled plugins: {num}$count{rst}"
} # ]]]
# FUNCTION: .zi-show-times [[[
# Shows loading times of all loaded plugins.
#
# User-action entry point.
.zi-show-times() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal noshortloops
-
- local opt="$1 $2 $3" entry entry2 entry3 user plugin
- float -F 3 sum=0.0
- local -A sice
- local -a tmp
-
- [[ "$opt" = *-[a-z]#m[a-z]#* ]] && \
- { builtin print "Plugin loading moments (relative to the first prompt):"; ((1)); } || \
- builtin print "Plugin loading times:"
-
- for entry in "${(@on)ZI[(I)TIME_[0-9]##_*]}"; do
- entry2="${entry#TIME_[0-9]##_}"
- entry3="AT_$entry"
- if [[ "$entry2" = (http|https|ftp|ftps|scp|${(~j.|.)${${(k)ZI_1MAP}%::}}):* ]]; then
- REPLY="${ZI[col-pname]}$entry2${ZI[col-rst]}"
-
- tmp=( "${(z@)ZI_SICE[${entry2%/}]}" )
- (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=()
- else
- user="${entry2%%---*}"
- plugin="${entry2#*---}"
- [[ "$user" = \% ]] && plugin="/${plugin//---/\/}"
- [[ "$user" = "$plugin" && "$user/$plugin" != "$entry2" ]] && user=""
- .zi-any-colorify-as-uspl2 "$user" "$plugin"
-
- tmp=( "${(z@)ZI_SICE[$user/$plugin]}" )
- (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=()
- fi
-
- local attime=$(( ZI[$entry3] - ZI[START_TIME] ))
- if [[ "$opt" = *-[a-z]#s[a-z]#* ]]; then
- local time="$ZI[$entry] sec"
- attime="${(M)attime#*.???} sec"
- else
- local time="${(l:5:: :)$(( ZI[$entry] * 1000 ))%%[,.]*} ms"
- attime="${(l:5:: :)$(( attime * 1000 ))%%[,.]*} ms"
- fi
- [[ -z $EPOCHREALTIME ]] && attime=""
-
- if [[ "$opt" = *-[a-z]#m[a-z]#* ]]; then
- time="$attime"
- fi
-
- if [[ ${sice[as]} == "command" ]]; then
- builtin print "$time" - "$REPLY (command)"
- elif [[ -n ${sice[sbin]+abc} ]]; then
- builtin print "$time" - "$REPLY (sbin command)"
- elif [[ -n ${sice[fbin]+abc} ]]; then
- builtin print "$time" - "$REPLY (fbin command)"
- elif [[ ( ${sice[pick]} = /dev/null || ${sice[as]} = null ) && ${+sice[make]} = 1 ]]; then
- builtin print "$time" - "$REPLY (/dev/null make plugin)"
- else
- builtin print "$time" - "$REPLY"
- fi
-
- (( sum += ZI[$entry] ))
- done
- builtin print "Total: $sum sec"
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal noshortloops
+ local opt="$1 $2 $3" entry entry2 entry3 user plugin
+ float -F 3 sum=0.0
+ local -A sice
+ local -a tmp
+ [[ "$opt" = *-[a-z]#m[a-z]#* ]] && \
+ { builtin print "Plugin loading moments (relative to the first prompt):"; ((1)); } || \
+ builtin print "Plugin loading times:"
+ for entry in "${(@on)ZI[(I)TIME_[0-9]##_*]}"; do
+ entry2="${entry#TIME_[0-9]##_}"
+ entry3="AT_$entry"
+ if [[ "$entry2" = (http|https|ftp|ftps|scp|${(~j.|.)${${(k)ZI_1MAP}%::}}):* ]]; then
+ REPLY="${ZI[col-pname]}$entry2${ZI[col-rst]}"
+ tmp=( "${(z@)ZI_SICE[${entry2%/}]}" )
+ (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=()
+ else
+ user="${entry2%%---*}"
+ plugin="${entry2#*---}"
+ [[ "$user" = \% ]] && plugin="/${plugin//---/\/}"
+ [[ "$user" = "$plugin" && "$user/$plugin" != "$entry2" ]] && user=""
+ .zi-any-colorify-as-uspl2 "$user" "$plugin"
+ tmp=( "${(z@)ZI_SICE[$user/$plugin]}" )
+ (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=()
+ fi
+ local attime=$(( ZI[$entry3] - ZI[START_TIME] ))
+ if [[ "$opt" = *-[a-z]#s[a-z]#* ]]; then
+ local time="$ZI[$entry] sec"
+ attime="${(M)attime#*.???} sec"
+ else
+ local time="${(l:5:: :)$(( ZI[$entry] * 1000 ))%%[,.]*} ms"
+ attime="${(l:5:: :)$(( attime * 1000 ))%%[,.]*} ms"
+ fi
+ [[ -z $EPOCHREALTIME ]] && attime=""
+ if [[ "$opt" = *-[a-z]#m[a-z]#* ]]; then
+ time="$attime"
+ fi
+ if [[ ${sice[as]} == "command" ]]; then
+ builtin print "$time" - "$REPLY (command)"
+ elif [[ -n ${sice[sbin]+abc} ]]; then
+ builtin print "$time" - "$REPLY (sbin command)"
+ elif [[ -n ${sice[fbin]+abc} ]]; then
+ builtin print "$time" - "$REPLY (fbin command)"
+ elif [[ ( ${sice[pick]} = /dev/null || ${sice[as]} = null ) && ${+sice[make]} = 1 ]]; then
+ builtin print "$time" - "$REPLY (/dev/null make plugin)"
+ else
+ builtin print "$time" - "$REPLY"
+ fi
+ (( sum += ZI[$entry] ))
+ done
+ builtin print "Total: $sum sec"
} # ]]]
# FUNCTION: .zi-list-bindkeys [[[
.zi-list-bindkeys() {
- local uspl2 uspl2col sw first=1
- local -a string_widget
-
- # KSH_ARRAYS immunity
- integer correct=0
- [[ -o "KSH_ARRAYS" ]] && correct=1
-
- for uspl2 in "${(@ko)ZI[(I)BINDKEYS__*]}"; do
- [[ -z "${ZI[$uspl2]}" ]] && continue
-
- (( !first )) && builtin print
- first=0
-
- uspl2="${uspl2#BINDKEYS__}"
-
- .zi-any-colorify-as-uspl2 "$uspl2"
- uspl2col="$REPLY"
- builtin print "$uspl2col"
-
- string_widget=( "${(z@)ZI[BINDKEYS__$uspl2]}" )
- for sw in "${(Oa)string_widget[@]}"; do
- [[ -z "$sw" ]] && continue
- # Remove one level of quoting to split using (z)
- sw="${(Q)sw}"
- typeset -a sw_arr
- sw_arr=( "${(z@)sw}" )
-
- # Remove one level of quoting to pass to bindkey
- local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys
- local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget
- local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional -M or -A or -N
- local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional map name
- local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional -R (not with -A, -N)
-
- if [[ "$sw_arr3" = "-M" && "$sw_arr5" != "-R" ]]; then
- builtin print "bindkey $sw_arr1 $sw_arr2 ${ZI[col-info]}for keymap $sw_arr4${ZI[col-rst]}"
- elif [[ "$sw_arr3" = "-M" && "$sw_arr5" = "-R" ]]; then
- builtin print "${ZI[col-info]}range${ZI[col-rst]} bindkey $sw_arr1 $sw_arr2 ${ZI[col-info]}mapped to $sw_arr4${ZI[col-rst]}"
- elif [[ "$sw_arr3" != "-M" && "$sw_arr5" = "-R" ]]; then
- builtin print "${ZI[col-info]}range${ZI[col-rst]} bindkey $sw_arr1 $sw_arr2"
- elif [[ "$sw_arr3" = "-A" ]]; then
- builtin print "Override of keymap \`main'"
- elif [[ "$sw_arr3" = "-N" ]]; then
- builtin print "New keymap \`$sw_arr4'"
- else
- builtin print "bindkey $sw_arr1 $sw_arr2"
- fi
- done
+ local uspl2 uspl2col sw first=1
+ local -a string_widget
+ # KSH_ARRAYS immunity
+ integer correct=0
+ [[ -o "KSH_ARRAYS" ]] && correct=1
+ for uspl2 in "${(@ko)ZI[(I)BINDKEYS__*]}"; do
+ [[ -z "${ZI[$uspl2]}" ]] && continue
+ (( !first )) && builtin print
+ first=0
+ uspl2="${uspl2#BINDKEYS__}"
+ .zi-any-colorify-as-uspl2 "$uspl2"
+ uspl2col="$REPLY"
+ builtin print "$uspl2col"
+ string_widget=( "${(z@)ZI[BINDKEYS__$uspl2]}" )
+ for sw in "${(Oa)string_widget[@]}"; do
+ [[ -z "$sw" ]] && continue
+ # Remove one level of quoting to split using (z)
+ sw="${(Q)sw}"
+ typeset -a sw_arr
+ sw_arr=( "${(z@)sw}" )
+ # Remove one level of quoting to pass to bindkey
+ local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys
+ local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget
+ local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional -M or -A or -N
+ local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional map name
+ local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional -R (not with -A, -N)
+
+ if [[ "$sw_arr3" = "-M" && "$sw_arr5" != "-R" ]]; then
+ builtin print "bindkey $sw_arr1 $sw_arr2 ${ZI[col-info]}for keymap $sw_arr4${ZI[col-rst]}"
+ elif [[ "$sw_arr3" = "-M" && "$sw_arr5" = "-R" ]]; then
+ builtin print "${ZI[col-info]}range${ZI[col-rst]} bindkey $sw_arr1 $sw_arr2 ${ZI[col-info]}mapped to $sw_arr4${ZI[col-rst]}"
+ elif [[ "$sw_arr3" != "-M" && "$sw_arr5" = "-R" ]]; then
+ builtin print "${ZI[col-info]}range${ZI[col-rst]} bindkey $sw_arr1 $sw_arr2"
+ elif [[ "$sw_arr3" = "-A" ]]; then
+ builtin print "Override of keymap \`main'"
+ elif [[ "$sw_arr3" = "-N" ]]; then
+ builtin print "New keymap \`$sw_arr4'"
+ else
+ builtin print "bindkey $sw_arr1 $sw_arr2"
+ fi
done
+ done
}
# ]]]
@@ -2256,61 +2037,54 @@ ZI[EXTENDED_GLOB]=""
#
# User-action entry point.
.zi-compiled() {
- builtin setopt localoptions nullglob
+ builtin setopt localoptions nullglob
- typeset -a matches m
- matches=( ${ZI[PLUGINS_DIR]}/*/*.zwc(DN) )
+ typeset -a matches m
+ matches=( ${ZI[PLUGINS_DIR]}/*/*.zwc(DN) )
- if [[ "${#matches[@]}" -eq "0" ]]; then
- builtin print "No compiled plugins"
- return 0
+ if [[ "${#matches[@]}" -eq "0" ]]; then
+ builtin print "No compiled plugins"
+ return 0
+ fi
+ local cur_plugin="" uspl1 file user plugin
+ for m in "${matches[@]}"; do
+ file="${m:t}"
+ uspl1="${${m:h}:t}"
+ .zi-any-to-user-plugin "$uspl1"
+ user="${reply[-2]}" plugin="${reply[-1]}"
+ if [[ "$cur_plugin" != "$uspl1" ]]; then
+ [[ -n "$cur_plugin" ]] && builtin print # newline
+ .zi-any-colorify-as-uspl2 "$user" "$plugin"
+ builtin print -r -- "$REPLY:"
+ cur_plugin="$uspl1"
fi
-
- local cur_plugin="" uspl1 file user plugin
- for m in "${matches[@]}"; do
- file="${m:t}"
- uspl1="${${m:h}:t}"
- .zi-any-to-user-plugin "$uspl1"
- user="${reply[-2]}" plugin="${reply[-1]}"
-
- if [[ "$cur_plugin" != "$uspl1" ]]; then
- [[ -n "$cur_plugin" ]] && builtin print # newline
- .zi-any-colorify-as-uspl2 "$user" "$plugin"
- builtin print -r -- "$REPLY:"
- cur_plugin="$uspl1"
- fi
-
- builtin print "$file"
- done
+ builtin print "$file"
+ done
} # ]]]
# FUNCTION: .zi-compile-uncompile-all [[[
# Compiles or uncompiles all existing (on disk) plugins.
#
# User-action entry point.
.zi-compile-uncompile-all() {
- builtin setopt localoptions nullglob
-
- local compile="$1"
-
- typeset -a plugins
- plugins=( "${ZI[PLUGINS_DIR]}"/*(DN) )
-
- local p user plugin
- for p in "${plugins[@]}"; do
- [[ "${p:t}" = "custom" || "${p:t}" = "_local---zi" ]] && continue
-
- .zi-any-to-user-plugin "${p:t}"
- user="${reply[-2]}" plugin="${reply[-1]}"
-
- .zi-any-colorify-as-uspl2 "$user" "$plugin"
- builtin print -r -- "$REPLY:"
-
- if [[ "$compile" = "1" ]]; then
- .zi-compile-plugin "$user" "$plugin"
- else
- .zi-uncompile-plugin "$user" "$plugin" "1"
- fi
- done
+ builtin setopt localoptions nullglob
+
+ local compile="$1"
+ typeset -a plugins
+ plugins=( "${ZI[PLUGINS_DIR]}"/*(DN) )
+
+ local p user plugin
+ for p in "${plugins[@]}"; do
+ [[ "${p:t}" = "custom" || "${p:t}" = "_local---zi" ]] && continue
+ .zi-any-to-user-plugin "${p:t}"
+ user="${reply[-2]}" plugin="${reply[-1]}"
+ .zi-any-colorify-as-uspl2 "$user" "$plugin"
+ builtin print -r -- "$REPLY:"
+ if [[ "$compile" = "1" ]]; then
+ .zi-compile-plugin "$user" "$plugin"
+ else
+ .zi-uncompile-plugin "$user" "$plugin" "1"
+ fi
+ done
} # ]]]
# FUNCTION: .zi-uncompile-plugin [[[
# Uncompiles given plugin.
@@ -2320,32 +2094,29 @@ ZI[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-uncompile-plugin() {
- builtin setopt localoptions nullglob
-
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}" silent="$3"
-
- # There are plugins having ".plugin.zsh"
- # in ${plugin} directory name, also some
- # have ".zsh" there
- [[ "$user" = "%" ]] && local pdir_path="$plugin" || local pdir_path="${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}"
- typeset -a matches m
- matches=( $pdir_path/*.zwc(DN) )
-
- if [[ "${#matches[@]}" -eq "0" ]]; then
- if [[ "$silent" = "1" ]]; then
- builtin print "not compiled"
- else
- .zi-any-colorify-as-uspl2 "$user" "$plugin"
- builtin print -r -- "$REPLY not compiled"
- fi
- return 1
+ builtin setopt localoptions nullglob
+
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}" silent="$3"
+ # There are plugins having ".plugin.zsh"
+ # in ${plugin} directory name, also some
+ # have ".zsh" there
+ [[ "$user" = "%" ]] && local pdir_path="$plugin" || local pdir_path="${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}"
+ typeset -a matches m
+ matches=( $pdir_path/*.zwc(DN) )
+ if [[ "${#matches[@]}" -eq "0" ]]; then
+ if [[ "$silent" = "1" ]]; then
+ builtin print "not compiled"
+ else
+ .zi-any-colorify-as-uspl2 "$user" "$plugin"
+ builtin print -r -- "$REPLY not compiled"
fi
-
- for m in "${matches[@]}"; do
- builtin print "Removing ${ZI[col-info]}${m:t}${ZI[col-rst]}"
- command rm -f "$m"
- done
+ return 1
+ fi
+ for m in "${matches[@]}"; do
+ builtin print "Removing ${ZI[col-info]}${m:t}${ZI[col-rst]}"
+ command rm -f "$m"
+ done
} # ]]]
# FUNCTION: .zi-show-completions [[[
@@ -2357,89 +2128,75 @@ ZI[EXTENDED_GLOB]=""
#
# User-action entry point.
.zi-show-completions() {
- builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
- local count="${1:-3}"
-
- typeset -a completions
- completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc )
-
- local cpath c o s group
-
- # Prepare readlink command for establishing
- # completion's owner
- .zi-prepare-readlink
- local rdlink="$REPLY"
-
- float flmax=${#completions} flcur=0
- typeset -F1 flper
-
- local -A owner_to_group
- local -a packs splitted
-
- integer disabled unknown stray
- for cpath in "${completions[@]}"; do
- c="${cpath:t}"
- [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0
- c="${c#_}"
-
- # This will resolve completion's symlink to obtain
- # information about the repository it comes from, i.e.
- # about user and plugin, taken from directory name
- .zi-get-completion-owner "$cpath" "$rdlink"
- [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0
- o="$REPLY"
-
- # If we successfully read a symlink (unknown == 0), test if it isn't broken
- stray=0
- if (( unknown == 0 )); then
- [[ ! -f "$cpath" ]] && stray=1
- fi
-
- s=$(( 1*disabled + 2*unknown + 4*stray ))
-
- owner_to_group[${o}--$s]+="$c;"
- group="${owner_to_group[${o}--$s]%;}"
- splitted=( "${(s:;:)group}" )
-
- if [[ "${#splitted}" -ge "$count" ]]; then
- packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" )
- unset "owner_to_group[${o}--$s]"
- fi
-
- (( ++ flcur ))
- flper=$(( flcur / flmax * 100 ))
- builtin print -u 2 -n -- "\r${flper}% "
- done
-
- for o in "${(k)owner_to_group[@]}"; do
- group="${owner_to_group[$o]%;}"
- s="${o##*--}"
- o="${o%--*}"
- packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" )
- done
- packs=( "${(on)packs[@]}" )
-
- builtin print -u 2 # newline after percent
-
- # Find longest completion name
- integer longest=0
- local -a unpacked
- for c in "${packs[@]}"; do
- unpacked=( "${(Q@)${(z@)c}}" )
- [[ "${#unpacked[1]}" -gt "$longest" ]] && longest="${#unpacked[1]}"
- done
-
- for c in "${packs[@]}"; do
- unpacked=( "${(Q@)${(z@)c}}" ) # TODO: ${(Q)${(z@)c}[@]} ?
-
- .zi-any-colorify-as-uspl2 "$unpacked[2]"
- builtin print -n "${(r:longest+1:: :)unpacked[1]} $REPLY"
-
- (( unpacked[3] & 0x1 )) && builtin print -n " ${ZI[col-error]}[disabled]${ZI[col-rst]}"
- (( unpacked[3] & 0x2 )) && builtin print -n " ${ZI[col-error]}[unknown file, clean with cclear]${ZI[col-rst]}"
- (( unpacked[3] & 0x4 )) && builtin print -n " ${ZI[col-error]}[stray, clean with cclear]${ZI[col-rst]}"
- builtin print
- done
+ builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
+ local count="${1:-3}"
+ typeset -a completions
+ completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc )
+
+ local cpath c o s group
+ # Prepare readlink command for establishing
+ # completion's owner
+ .zi-prepare-readlink
+ local rdlink="$REPLY"
+ float flmax=${#completions} flcur=0
+ typeset -F1 flper
+ local -A owner_to_group
+ local -a packs splitted
+ integer disabled unknown stray
+ for cpath in "${completions[@]}"; do
+ c="${cpath:t}"
+ [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0
+ c="${c#_}"
+ # This will resolve completion's symlink to obtain
+ # information about the repository it comes from, i.e.
+ # about user and plugin, taken from directory name
+ .zi-get-completion-owner "$cpath" "$rdlink"
+ [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0
+ o="$REPLY"
+ # If we successfully read a symlink (unknown == 0), test if it isn't broken
+ stray=0
+ if (( unknown == 0 )); then
+ [[ ! -f "$cpath" ]] && stray=1
+ fi
+ s=$(( 1*disabled + 2*unknown + 4*stray ))
+ owner_to_group[${o}--$s]+="$c;"
+ group="${owner_to_group[${o}--$s]%;}"
+ splitted=( "${(s:;:)group}" )
+ if [[ "${#splitted}" -ge "$count" ]]; then
+ packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" )
+ unset "owner_to_group[${o}--$s]"
+ fi
+ (( ++ flcur ))
+ flper=$(( flcur / flmax * 100 ))
+ builtin print -u 2 -n -- "\r${flper}% "
+ done
+ for o in "${(k)owner_to_group[@]}"; do
+ group="${owner_to_group[$o]%;}"
+ s="${o##*--}"
+ o="${o%--*}"
+ packs+=( "${(q)group//;/, } ${(q)o} ${(q)s}" )
+ done
+ packs=( "${(on)packs[@]}" )
+
+ builtin print -u 2 # newline after percent
+
+ # Find longest completion name
+ integer longest=0
+ local -a unpacked
+ for c in "${packs[@]}"; do
+ unpacked=( "${(Q@)${(z@)c}}" )
+ [[ "${#unpacked[1]}" -gt "$longest" ]] && longest="${#unpacked[1]}"
+ done
+ for c in "${packs[@]}"; do
+ unpacked=( "${(Q@)${(z@)c}}" ) # TODO: ${(Q)${(z@)c}[@]} ?
+ .zi-any-colorify-as-uspl2 "$unpacked[2]"
+ builtin print -n "${(r:longest+1:: :)unpacked[1]} $REPLY"
+
+ (( unpacked[3] & 0x1 )) && builtin print -n " ${ZI[col-error]}[disabled]${ZI[col-rst]}"
+ (( unpacked[3] & 0x2 )) && builtin print -n " ${ZI[col-error]}[unknown file, clean with cclear]${ZI[col-rst]}"
+ (( unpacked[3] & 0x4 )) && builtin print -n " ${ZI[col-error]}[stray, clean with cclear]${ZI[col-rst]}"
+ builtin print
+ done
} # ]]]
# FUNCTION: .zi-clear-completions [[[
# Delete stray and improper completions.
@@ -2449,51 +2206,48 @@ ZI[EXTENDED_GLOB]=""
#
# User-action entry point.
.zi-clear-completions() {
- builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
-
- typeset -a completions
- completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc )
-
- # Find longest completion name
- local cpath c
- integer longest=0
- for cpath in "${completions[@]}"; do
- c="${cpath:t}"
- c="${c#_}"
- [[ "${#c}" -gt "$longest" ]] && longest="${#c}"
- done
+ builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
+
+ typeset -a completions
+ completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc )
+ # Find longest completion name
+ local cpath c
+ integer longest=0
+ for cpath in "${completions[@]}"; do
+ c="${cpath:t}"
+ c="${c#_}"
+ [[ "${#c}" -gt "$longest" ]] && longest="${#c}"
+ done
+
+ .zi-prepare-readlink
+ local rdlink="$REPLY"
+ integer disabled unknown stray
+ for cpath in "${completions[@]}"; do
+ c="${cpath:t}"
+ [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0
+ c="${c#_}"
- .zi-prepare-readlink
- local rdlink="$REPLY"
-
- integer disabled unknown stray
- for cpath in "${completions[@]}"; do
- c="${cpath:t}"
- [[ "${c#_}" = "${c}" ]] && disabled=1 || disabled=0
- c="${c#_}"
-
- # This will resolve completion's symlink to obtain
- # information about the repository it comes from, i.e.
- # about user and plugin, taken from directory name
- .zi-get-completion-owner "$cpath" "$rdlink"
- [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0
- .zi-any-colorify-as-uspl2 "$REPLY"
-
- # If we successfully read a symlink (unknown == 0), test if it isn't broken
- stray=0
- if (( unknown == 0 )); then
- [[ ! -f "$cpath" ]] && stray=1
- fi
+ # This will resolve completion's symlink to obtain
+ # information about the repository it comes from, i.e.
+ # about user and plugin, taken from directory name
+ .zi-get-completion-owner "$cpath" "$rdlink"
+ [[ "$REPLY" = "[unknown]" ]] && unknown=1 || unknown=0
+ .zi-any-colorify-as-uspl2 "$REPLY"
- if (( unknown == 1 || stray == 1 )); then
- builtin print -n "Removing completion: ${(r:longest+1:: :)c} $REPLY"
- (( disabled )) && builtin print -n " ${ZI[col-error]}[disabled]${ZI[col-rst]}"
- (( unknown )) && builtin print -n " ${ZI[col-error]}[unknown file]${ZI[col-rst]}"
- (( stray )) && builtin print -n " ${ZI[col-error]}[stray]${ZI[col-rst]}"
- builtin print
- command rm -f "$cpath"
- fi
- done
+ # If we successfully read a symlink (unknown == 0), test if it isn't broken
+ stray=0
+ if (( unknown == 0 )); then
+ [[ ! -f "$cpath" ]] && stray=1
+ fi
+ if (( unknown == 1 || stray == 1 )); then
+ builtin print -n "Removing completion: ${(r:longest+1:: :)c} $REPLY"
+ (( disabled )) && builtin print -n " ${ZI[col-error]}[disabled]${ZI[col-rst]}"
+ (( unknown )) && builtin print -n " ${ZI[col-error]}[unknown file]${ZI[col-rst]}"
+ (( stray )) && builtin print -n " ${ZI[col-error]}[stray]${ZI[col-rst]}"
+ builtin print
+ command rm -f "$cpath"
+ fi
+ done
} # ]]]
# FUNCTION: .zi-search-completions [[[
# While .zi-show-completions() shows what completions are
@@ -2502,59 +2256,52 @@ ZI[EXTENDED_GLOB]=""
#
# User-action entry point.
.zi-search-completions() {
- builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
-
- typeset -a plugin_paths
- plugin_paths=( "${ZI[PLUGINS_DIR]}"/*(DN) )
-
- # Find longest plugin name. Things are ran twice here, first pass
- # is to get longest name of plugin which is having any completions
- integer longest=0
- typeset -a completions
- local pp
- for pp in "${plugin_paths[@]}"; do
- completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) )
- if [[ "${#completions[@]}" -gt 0 ]]; then
- local pd="${pp:t}"
- [[ "${#pd}" -gt "$longest" ]] && longest="${#pd}"
- fi
- done
-
- builtin print "${ZI[col-info]}[+]${ZI[col-rst]} is installed, ${ZI[col-p]}[-]${ZI[col-rst]} uninstalled, ${ZI[col-error]}[+-]${ZI[col-rst]} partially installed"
-
- local c
- for pp in "${plugin_paths[@]}"; do
- completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) )
-
- if [[ "${#completions[@]}" -gt 0 ]]; then
- # Array of completions, e.g. ( _cp _xauth )
- completions=( "${completions[@]:t}" )
-
- # Detect if the completions are installed
- integer all_installed="${#completions[@]}"
- for c in "${completions[@]}"; do
- if [[ -e "${ZI[COMPLETIONS_DIR]}/$c" || -e "${ZI[COMPLETIONS_DIR]}/${c#_}" ]]; then
- (( all_installed -- ))
- fi
- done
-
- if [[ "$all_installed" -eq "${#completions[@]}" ]]; then
- builtin print -n "${ZI[col-p]}[-]${ZI[col-rst]} "
- elif [[ "$all_installed" -eq "0" ]]; then
- builtin print -n "${ZI[col-info]}[+]${ZI[col-rst]} "
- else
- builtin print -n "${ZI[col-error]}[+-]${ZI[col-rst]} "
- fi
-
- # Convert directory name to colorified $user/$plugin
- .zi-any-colorify-as-uspl2 "${pp:t}"
-
- # Adjust for escape code (nasty, utilizes fact that
- # ${ZI[col-rst]} is used twice, so as a $ZI_COL)
- integer adjust_ec=$(( ${#ZI[col-rst]} * 2 + ${#ZI[col-uname]} + ${#ZI[col-pname]} ))
- builtin print "${(r:longest+adjust_ec:: :)REPLY} ${(j:, :)completions}"
+ builtin setopt localoptions nullglob extendedglob nokshglob noksharrays
+
+ typeset -a plugin_paths
+ plugin_paths=( "${ZI[PLUGINS_DIR]}"/*(DN) )
+ # Find longest plugin name. Things are ran twice here, first pass
+ # is to get longest name of plugin which is having any completions
+ integer longest=0
+ typeset -a completions
+ local pp
+ for pp in "${plugin_paths[@]}"; do
+ completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) )
+ if [[ "${#completions[@]}" -gt 0 ]]; then
+ local pd="${pp:t}"
+ [[ "${#pd}" -gt "$longest" ]] && longest="${#pd}"
+ fi
+ done
+ builtin print "${ZI[col-info]}[+]${ZI[col-rst]} is installed, ${ZI[col-p]}[-]${ZI[col-rst]} uninstalled, ${ZI[col-error]}[+-]${ZI[col-rst]} partially installed"
+
+ local c
+ for pp in "${plugin_paths[@]}"; do
+ completions=( "$pp"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) )
+ if [[ "${#completions[@]}" -gt 0 ]]; then
+ # Array of completions, e.g. ( _cp _xauth )
+ completions=( "${completions[@]:t}" )
+ # Detect if the completions are installed
+ integer all_installed="${#completions[@]}"
+ for c in "${completions[@]}"; do
+ if [[ -e "${ZI[COMPLETIONS_DIR]}/$c" || -e "${ZI[COMPLETIONS_DIR]}/${c#_}" ]]; then
+ (( all_installed -- ))
fi
- done
+ done
+ if [[ "$all_installed" -eq "${#completions[@]}" ]]; then
+ builtin print -n "${ZI[col-p]}[-]${ZI[col-rst]} "
+ elif [[ "$all_installed" -eq "0" ]]; then
+ builtin print -n "${ZI[col-info]}[+]${ZI[col-rst]} "
+ else
+ builtin print -n "${ZI[col-error]}[+-]${ZI[col-rst]} "
+ fi
+ # Convert directory name to colorified $user/$plugin
+ .zi-any-colorify-as-uspl2 "${pp:t}"
+ # Adjust for escape code (nasty, utilizes fact that
+ # ${ZI[col-rst]} is used twice, so as a $ZI_COL)
+ integer adjust_ec=$(( ${#ZI[col-rst]} * 2 + ${#ZI[col-uname]} + ${#ZI[col-pname]} ))
+ builtin print "${(r:longest+adjust_ec:: :)REPLY} ${(j:, :)completions}"
+ fi
+ done
} # ]]]
# FUNCTION: .zi-cenable [[[
# Disables given installed completion.
@@ -2563,47 +2310,39 @@ ZI[EXTENDED_GLOB]=""
#
# $1 - e.g. "_mkdir" or "mkdir"
.zi-cenable() {
- local c="$1"
- c="${c#_}"
-
- local cfile="${ZI[COMPLETIONS_DIR]}/_${c}"
- local bkpfile="${cfile:h}/$c"
-
- if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then
- builtin print "${ZI[col-error]}No such completion \`$c'${ZI[col-rst]}"
- return 1
- fi
-
- # Check if there is no backup file
- # This is treated as if the completion is already enabled
- if [[ ! -e "$bkpfile" ]]; then
- builtin print "Completion ${ZI[col-info]}$c${ZI[col-rst]} already enabled"
-
- .zi-check-comp-consistency "$cfile" "$bkpfile" 0
- return 1
- fi
-
- # Disabled, but completion file already exists?
- if [[ -e "$cfile" ]]; then
- builtin print "${ZI[col-error]}Warning: completion's file \`${cfile:t}' exists, will overwrite${ZI[col-rst]}"
- builtin print "${ZI[col-error]}Completion is actually enabled and will re-enable it again${ZI[col-rst]}"
- .zi-check-comp-consistency "$cfile" "$bkpfile" 1
- command rm -f "$cfile"
- else
- .zi-check-comp-consistency "$cfile" "$bkpfile" 0
- fi
-
- # Enable
- command mv "$bkpfile" "$cfile" # move completion's backup file created when disabling
-
- # Prepare readlink command for establishing completion's owner
- .zi-prepare-readlink
- # Get completion's owning plugin
- .zi-get-completion-owner-uspl2col "$cfile" "$REPLY"
-
- builtin print "Enabled ${ZI[col-info]}$c${ZI[col-rst]} completion belonging to $REPLY"
-
- return 0
+ local c="$1"
+ c="${c#_}"
+ local cfile="${ZI[COMPLETIONS_DIR]}/_${c}"
+ local bkpfile="${cfile:h}/$c"
+ if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then
+ builtin print "${ZI[col-error]}No such completion \`$c'${ZI[col-rst]}"
+ return 1
+ fi
+ # Check if there is no backup file
+ # This is treated as if the completion is already enabled
+ if [[ ! -e "$bkpfile" ]]; then
+ builtin print "Completion ${ZI[col-info]}$c${ZI[col-rst]} already enabled"
+ .zi-check-comp-consistency "$cfile" "$bkpfile" 0
+ return 1
+ fi
+
+ # Disabled, but completion file already exists?
+ if [[ -e "$cfile" ]]; then
+ builtin print "${ZI[col-error]}Warning: completion's file \`${cfile:t}' exists, will overwrite${ZI[col-rst]}"
+ builtin print "${ZI[col-error]}Completion is actually enabled and will re-enable it again${ZI[col-rst]}"
+ .zi-check-comp-consistency "$cfile" "$bkpfile" 1
+ command rm -f "$cfile"
+ else
+ .zi-check-comp-consistency "$cfile" "$bkpfile" 0
+ fi
+ # Enable
+ command mv "$bkpfile" "$cfile" # move completion's backup file created when disabling
+ # Prepare readlink command for establishing completion's owner
+ .zi-prepare-readlink
+ # Get completion's owning plugin
+ .zi-get-completion-owner-uspl2col "$cfile" "$REPLY"
+ builtin print "Enabled ${ZI[col-info]}$c${ZI[col-rst]} completion belonging to $REPLY"
+ return 0
} # ]]]
# FUNCTION: .zi-cdisable [[[
# Enables given installed completion.
@@ -2612,46 +2351,39 @@ ZI[EXTENDED_GLOB]=""
#
# $1 - e.g. "_mkdir" or "mkdir"
.zi-cdisable() {
- local c="$1"
- c="${c#_}"
-
- local cfile="${ZI[COMPLETIONS_DIR]}/_${c}"
- local bkpfile="${cfile:h}/$c"
-
- if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then
- builtin print "${ZI[col-error]}No such completion \`$c'${ZI[col-rst]}"
- return 1
- fi
-
- # Check if it's already disabled
- # Not existing "$cfile" says that
- if [[ ! -e "$cfile" ]]; then
- builtin print "Completion ${ZI[col-info]}$c${ZI[col-rst]} already disabled"
-
- .zi-check-comp-consistency "$cfile" "$bkpfile" 0
- return 1
- fi
-
- # No disable, but bkpfile exists?
- if [[ -e "$bkpfile" ]]; then
- builtin print "${ZI[col-error]}Warning: completion's backup file \`${bkpfile:t}' already exists, will overwrite${ZI[col-rst]}"
- .zi-check-comp-consistency "$cfile" "$bkpfile" 1
- command rm -f "$bkpfile"
- else
- .zi-check-comp-consistency "$cfile" "$bkpfile" 0
- fi
-
- # Disable
- command mv "$cfile" "$bkpfile"
-
- # Prepare readlink command for establishing completion's owner
- .zi-prepare-readlink
- # Get completion's owning plugin
- .zi-get-completion-owner-uspl2col "$bkpfile" "$REPLY"
-
- builtin print "Disabled ${ZI[col-info]}$c${ZI[col-rst]} completion belonging to $REPLY"
-
- return 0
+ local c="$1"
+ c="${c#_}"
+ local cfile="${ZI[COMPLETIONS_DIR]}/_${c}"
+ local bkpfile="${cfile:h}/$c"
+
+ if [[ ! -e "$cfile" && ! -e "$bkpfile" ]]; then
+ builtin print "${ZI[col-error]}No such completion \`$c'${ZI[col-rst]}"
+ return 1
+ fi
+ # Check if it's already disabled
+ # Not existing "$cfile" says that
+ if [[ ! -e "$cfile" ]]; then
+ builtin print "Completion ${ZI[col-info]}$c${ZI[col-rst]} already disabled"
+ .zi-check-comp-consistency "$cfile" "$bkpfile" 0
+ return 1
+ fi
+ # No disable, but bkpfile exists?
+ if [[ -e "$bkpfile" ]]; then
+ builtin print "${ZI[col-error]}Warning: completion's backup file \`${bkpfile:t}' already exists, will overwrite${ZI[col-rst]}"
+ .zi-check-comp-consistency "$cfile" "$bkpfile" 1
+ command rm -f "$bkpfile"
+ else
+ .zi-check-comp-consistency "$cfile" "$bkpfile" 0
+ fi
+ # Disable
+ command mv "$cfile" "$bkpfile"
+ # Prepare readlink command for establishing completion's owner
+ .zi-prepare-readlink
+ # Get completion's owning plugin
+ .zi-get-completion-owner-uspl2col "$bkpfile" "$REPLY"
+ builtin print "Disabled ${ZI[col-info]}$c${ZI[col-rst]} completion belonging to $REPLY"
+
+ return 0
} # ]]]
# FUNCTION: .zi-cd [[[
@@ -2662,43 +2394,42 @@ ZI[EXTENDED_GLOB]=""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-cd() {
- builtin emulate -LR zsh
- builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
+ builtin emulate -LR zsh
+ builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
- .zi-get-path "$1" "$2" && {
- if [[ -e $REPLY ]]; then
- builtin pushd $REPLY
- else
- +zi-message "No such plugin or snippet"
- return 1
- fi
- builtin print
- } || {
- +zi-message "No such plugin or snippet"
- return 1
- }
+ .zi-get-path "$1" "$2" && {
+ if [[ -e $REPLY ]]; then
+ builtin pushd $REPLY
+ else
+ +zi-message "No such plugin or snippet"
+ return 1
+ fi
+ builtin print
+ } || {
+ +zi-message "No such plugin or snippet"
+ return 1
+ }
} # ]]]
# FUNCTION: .zi-run-delete-hooks [[[
.zi-run-delete-hooks() {
- if [[ -n ${ICE[atdelete]} ]]; then
- .zi-countdown "atdelete" && ( (( ${+ICE[nocd]} == 0 )) && \
- { builtin cd -q "$5" && eval "${ICE[atdelete]}"; ((1)); } || \
- eval "${ICE[atdelete]}" )
- fi
-
- local -a arr
- local key
-
- # Run annexes' atdelete hooks
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:atdelete-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:atdelete-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:atdelete-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" "$1" "$2" $3 "$4" "$5" "${${key##(zi|z-annex) hook:}%% <->}" delete:TODO
- done
+ if [[ -n ${ICE[atdelete]} ]]; then
+ .zi-countdown "atdelete" && ( (( ${+ICE[nocd]} == 0 )) && \
+ { builtin cd -q "$5" && eval "${ICE[atdelete]}"; ((1)); } || \
+ eval "${ICE[atdelete]}" )
+ fi
+
+ local -a arr
+ local key
+ # Run annexes' atdelete hooks
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:atdelete-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:atdelete-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:atdelete-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" "$1" "$2" $3 "$4" "$5" "${${key##(zi|z-annex) hook:}%% <->}" delete:TODO
+ done
}
# ]]]
# FUNCTION: .zi-delete [[[
@@ -2709,31 +2440,26 @@ ZI[EXTENDED_GLOB]=""
# $1 - snippet URL or plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-delete() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent
-
- local -a opts match mbegin mend
- local MATCH; integer MBEGIN MEND _retval
-
- # Parse options
- .zi-parse-opts delete "$@"
- builtin set -- "${reply[@]}"
- if (( $@[(I)-*] || OPTS[opt_-h,--help] )) { +zi-prehelp-usage-message delete $___opt_map[delete] $@; return 1; }
-
- local the_id="$1${${1:#(%|/)*}:+${2:+/}}$2"
-
- # -a/--all given?
- if (( OPTS[opt_-a,--all] )); then
- .zi-confirm "Prune all plugins in \`${ZI[PLUGINS_DIR]}'"\
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent
+ local -a opts match mbegin mend
+ local MATCH; integer MBEGIN MEND _retval
+ # Parse options
+ .zi-parse-opts delete "$@"
+ builtin set -- "${reply[@]}"
+ if (( $@[(I)-*] || OPTS[opt_-h,--help] )) { +zi-prehelp-usage-message delete $___opt_map[delete] $@; return 1; }
+ local the_id="$1${${1:#(%|/)*}:+${2:+/}}$2"
+ # -a/--all given?
+ if (( OPTS[opt_-a,--all] )); then
+ .zi-confirm "Prune all plugins in \`${ZI[PLUGINS_DIR]}'"\
"and snippets in \`${ZI[SNIPPETS_DIR]}'?" \
"command rm -rf ${${ZI[PLUGINS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcEFG312}/*~*/_local---zi(ND) "\
"${${ZI[SNIPPETS_DIR]%%[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcEFG312}/*~*/plugins(ND)"
- return $?
- fi
-
- # -c/--clean given?
- if (( OPTS[opt_-c,--clean] )) {
- .zi-confirm "Prune ${ZI[col-info]}CURRENTLY NOT LOADED${ZI[col-rst]}"\
+ return $?
+ fi
+ # -c/--clean given?
+ if (( OPTS[opt_-c,--clean] )) {
+ .zi-confirm "Prune ${ZI[col-info]}CURRENTLY NOT LOADED${ZI[col-rst]}"\
" plugins in $ZI[col-file]$ZI[PLUGINS_DIR]%f%b"\
" and snippets in $ZI[col-file]$ZI[SNIPPETS_DIR]%f%b?" \
" # Delete unloaded snippets
@@ -2749,7 +2475,7 @@ todelete=( \${todelete[@]//(#m)(#s)[^\/]##(#e)/\$ZI[col-file]\$MATCH\$ZI[col-rst
final_todelete=( \${\${\${(@)\${(@)final_todelete##\$dir/#}//(#i)(#m)(http(s|)|ftp(s|)|ssh|rsync)--/\${MATCH%--}://}//--//}//(#b)(*)\/([^\/]##)(#e)/\$match[1]/\$match[2]} )
builtin print; print -Prln \"\$ZI[col-obj]Deleting the following \"\
\"\$ZI[col-file]\${#todelete}\$ZI[col-msg2] UNLOADED\$ZI[col-obj] snippets:%f%b\" \
- \$todelete \"%f%b\"
+\$todelete \"%f%b\"
sleep 3
local snip
for snip ( \$final_todelete ) { zi delete -q -y \$snip; _retval+=\$?; }
@@ -2765,73 +2491,69 @@ builtin print -Prl \"\" \"\$ZI[col-obj]Deleting the following \"\
sleep 3
for snip ( \$dirs ) { zi delete -q -y \$snip; _retval+=\$?; }
builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
- return _retval
- }
-
- local -A ICE2
- local local_dir filename is_snippet
-
- .zi-compute-ice "$the_id" "pack" \
- ICE2 local_dir filename is_snippet || return 1
-
- if [[ "$local_dir" != /* ]]
- then
- builtin print "Obtained a risky, not-absolute path ($local_dir), aborting"
+ return _retval
+ }
+
+ local -A ICE2
+ local local_dir filename is_snippet
+ .zi-compute-ice "$the_id" "pack" \
+ ICE2 local_dir filename is_snippet || return 1
+ if [[ "$local_dir" != /* ]]
+ then
+ builtin print "Obtained a risky, not-absolute path ($local_dir), aborting"
+ return 1
+ fi
+
+ ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}"
+
+ local -a files
+ files=( "$local_dir"/*.(zsh|sh|bash|ksh)(DN:t)
+ "$local_dir"/*(*DN:t) "$local_dir"/*(@DN:t) "$local_dir"/*(.DN:t)
+ "$local_dir"/*~*/.(_zi|svn|git)(/DN:t) "$local_dir"/*(=DN:t)
+ "$local_dir"/*(pDN:t) "$local_dir"/*(%DN:t)
+ )
+ (( !${#files} )) && files=( "no files?" )
+ files=( ${(@)files[1,4]} ${files[4]+more…} )
+
+ # Make the ices available for the hooks.
+ local -A ICE
+ ICE=( "${(kv)ICE2[@]}" )
+ if (( is_snippet )); then
+ if [[ "${+ICE2[svn]}" = "1" ]] {
+ if [[ -e "$local_dir" ]]
+ then
+ .zi-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \
+ ".zi-run-delete-hooks snippet \"${ICE2[teleid]}\" \"\" \"$the_id\" \
+ \"$local_dir\"; \
+ command rm -rf ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}"
+ else
+ builtin print "No such snippet"
return 1
- fi
-
- ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}"
-
- local -a files
- files=( "$local_dir"/*.(zsh|sh|bash|ksh)(DN:t)
- "$local_dir"/*(*DN:t) "$local_dir"/*(@DN:t) "$local_dir"/*(.DN:t)
- "$local_dir"/*~*/.(_zi|svn|git)(/DN:t) "$local_dir"/*(=DN:t)
- "$local_dir"/*(pDN:t) "$local_dir"/*(%DN:t)
- )
- (( !${#files} )) && files=( "no files?" )
- files=( ${(@)files[1,4]} ${files[4]+more…} )
-
- # Make the ices available for the hooks.
- local -A ICE
- ICE=( "${(kv)ICE2[@]}" )
-
- if (( is_snippet )); then
- if [[ "${+ICE2[svn]}" = "1" ]] {
- if [[ -e "$local_dir" ]]
- then
- .zi-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \
- ".zi-run-delete-hooks snippet \"${ICE2[teleid]}\" \"\" \"$the_id\" \
- \"$local_dir\"; \
- command rm -rf ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}"
- else
- builtin print "No such snippet"
- return 1
- fi
- } else {
- if [[ -e "$local_dir" ]]; then
- .zi-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \
- ".zi-run-delete-hooks snippet \"${ICE2[teleid]}\" \"\" \"$the_id\" \
- \"$local_dir\"; command rm -rf \
- ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}"
- else
- builtin print "No such snippet"
- return 1
- fi
- }
+ fi
+ } else {
+ if [[ -e "$local_dir" ]]; then
+ .zi-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \
+ ".zi-run-delete-hooks snippet \"${ICE2[teleid]}\" \"\" \"$the_id\" \
+ \"$local_dir\"; command rm -rf \
+ ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}"
+ else
+ builtin print "No such snippet"
+ return 1
+ fi
+ }
+ else
+ .zi-any-to-user-plugin "${ICE2[teleid]}"
+ if [[ -e "$local_dir" ]]; then
+ .zi-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \
+ ".zi-run-delete-hooks plugin \"${reply[-2]}\" \"${reply[-1]}\" \"$the_id\" \
+ \"$local_dir\"; \
+ command rm -rf ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}"
else
- .zi-any-to-user-plugin "${ICE2[teleid]}"
- if [[ -e "$local_dir" ]]; then
- .zi-confirm "Delete $local_dir? (it holds: ${(j:, :)${(@u)files}})" \
- ".zi-run-delete-hooks plugin \"${reply[-2]}\" \"${reply[-1]}\" \"$the_id\" \
- \"$local_dir\"; \
- command rm -rf ${(q)${${local_dir:#[/[:space:]]##}:-${TMPDIR:-${TMPDIR:-/tmp}}/abcYZX321}}"
- else
- builtin print -r -- "No such plugin or snippet"
- return 1
- fi
+ builtin print -r -- "No such plugin or snippet"
+ return 1
fi
-
- return 0
+ fi
+ return 0
} # ]]]
# FUNCTION: .zi-confirm [[[
# Prints given question, waits for "y" key, evals
@@ -2840,28 +2562,28 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
# $1 - question
# $2 - expression
.zi-confirm() {
- if (( OPTS[opt_-y,--yes] )); then
- integer retval
- eval "$2"; retval=$?
- (( OPTS[opt_-q,--quiet] )) || builtin print "\nDone (action executed, exit code: $retval)"
- else
- builtin print -Pr -- "$1"
- builtin print "[yY/n…]"
- local ans
- if [[ -t 0 ]] {
- read -q ans
- } else {
- read -k1 -u0 ans
- }
- if [[ "$ans" = "y" ]] {
- eval "$2"
- builtin print "\nDone (action executed, exit code: $?)"
- } else {
- builtin print "\nBreak, no action"
- return 1
- }
- fi
- return 0
+ if (( OPTS[opt_-y,--yes] )); then
+ integer retval
+ eval "$2"; retval=$?
+ (( OPTS[opt_-q,--quiet] )) || builtin print "\nDone (action executed, exit code: $retval)"
+ else
+ builtin print -Pr -- "$1"
+ builtin print "[yY/n…]"
+ local ans
+ if [[ -t 0 ]] {
+ read -q ans
+ } else {
+ read -k1 -u0 ans
+ }
+ if [[ "$ans" = "y" ]] {
+ eval "$2"
+ builtin print "\nDone (action executed, exit code: $?)"
+ } else {
+ builtin print "\nBreak, no action"
+ return 1
+ }
+ fi
+ return 0
}
# ]]]
# FUNCTION: .zi-changes [[[
@@ -2872,15 +2594,13 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-changes() {
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}"
-
- .zi-exists-physically-message "$user" "$plugin" || return 1
-
- (
- builtin cd -q "${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" && \
- command git log -p --graph --decorate --date=relative -C -M
- )
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}"
+ .zi-exists-physically-message "$user" "$plugin" || return 1
+ (
+ builtin cd -q "${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" && \
+ command git log -p --graph --decorate --date=relative -C -M
+ )
} # ]]]
# FUNCTION: .zi-recently [[[
# Shows plugins that obtained commits in specified past time.
@@ -2889,34 +2609,29 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
#
# $1 - time spec, e.g. "1 week"
.zi-recently() {
- emulate -LR zsh
- builtin setopt nullglob extendedglob warncreateglobal \
- typesetsilent noshortloops
-
- local IFS=.
- local gitout
- local timespec=${*// ##/.}
- timespec=${timespec//.##/.}
- [[ -z $timespec ]] && timespec=1.week
-
- typeset -a plugins
- plugins=( ${ZI[PLUGINS_DIR]}/*(DN-/) )
-
- local p uspl1
- for p in ${plugins[@]}; do
- uspl1=${p:t}
- [[ $uspl1 = custom || $uspl1 = _local---zi ]] && continue
-
- pushd "$p" >/dev/null || continue
- if [[ -d .git ]]; then
- gitout=`command git log --all --max-count=1 --since=$timespec 2>/dev/null`
- if [[ -n $gitout ]]; then
- .zi-any-colorify-as-uspl2 "$uspl1"
- builtin print -r -- "$REPLY"
- fi
- fi
- popd >/dev/null
- done
+ emulate -LR zsh
+ builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
+ local IFS=.
+ local gitout
+ local timespec=${*// ##/.}
+ timespec=${timespec//.##/.}
+ [[ -z $timespec ]] && timespec=1.week
+ typeset -a plugins
+ plugins=( ${ZI[PLUGINS_DIR]}/*(DN-/) )
+ local p uspl1
+ for p in ${plugins[@]}; do
+ uspl1=${p:t}
+ [[ $uspl1 = custom || $uspl1 = _local---zi ]] && continue
+ pushd "$p" >/dev/null || continue
+ if [[ -d .git ]]; then
+ gitout=`command git log --all --max-count=1 --since=$timespec 2>/dev/null`
+ if [[ -n $gitout ]]; then
+ .zi-any-colorify-as-uspl2 "$uspl1"
+ builtin print -r -- "$REPLY"
+ fi
+ fi
+ popd >/dev/null
+ done
} # ]]]
# FUNCTION: .zi-create [[[
# Creates a plugin, also on Github (if not "_local/name" plugin).
@@ -2926,80 +2641,71 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
# $1 - (optional) plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - (optional) plugin (only when $1 - i.e. user - given)
.zi-create() {
- emulate -LR zsh
- setopt localoptions extendedglob warncreateglobal typesetsilent \
- noshortloops rcquotes
-
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}"
-
- if (( ${+commands[curl]} == 0 || ${+commands[git]} == 0 )); then
- builtin print "${ZI[col-error]}curl and git are needed${ZI[col-rst]}"
- return 1
- fi
-
- # Read whether to create under organization
- local isorg
- vared -cp 'Create under an organization? (y/n): ' isorg
-
+ emulate -LR zsh
+ setopt localoptions extendedglob warncreateglobal typesetsilent noshortloops rcquotes
+
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}"
+ if (( ${+commands[curl]} == 0 || ${+commands[git]} == 0 )); then
+ builtin print "${ZI[col-error]}curl and git are needed${ZI[col-rst]}"
+ return 1
+ fi
+ # Read whether to create under organization
+ local isorg
+ vared -cp 'Create under an organization? (y/n): ' isorg
+ if [[ $isorg = (y|yes) ]]; then
+ local org="$user"
+ vared -cp "Github organization name: " org
+ fi
+ # Read user
+ local compcontext="user:User Name:(\"$USER\" \"$user\")"
+ vared -cp "Github user name or just \"_local\" (or leave blank, for an userless plugin): " user
+ # Read plugin
+ unset compcontext
+ vared -cp 'Plugin name: ' plugin
+ if [[ "$plugin" = "_unknown" ]]; then
+ builtin print "${ZI[col-error]}No plugin name entered${ZI[col-rst]}"
+ return 1
+ fi
+ plugin="${plugin//[^a-zA-Z0-9_]##/-}"
+ .zi-any-colorify-as-uspl2 "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin"
+ local uspl2col="$REPLY"
+ builtin print "Plugin is $uspl2col"
+
+ if .zi-exists-physically "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin"; then
+ builtin print "${ZI[col-error]}Repository${ZI[col-rst]} $uspl2col ${ZI[col-error]}already exists locally${ZI[col-rst]}"
+ return 1
+ fi
+
+ builtin cd -q "${ZI[PLUGINS_DIR]}"
+
+ if [[ "$user" != "_local" && -n "$user" ]]; then
+ builtin print "${ZI[col-info]}Creating Github repository${ZI[col-rst]}"
if [[ $isorg = (y|yes) ]]; then
- local org="$user"
- vared -cp "Github organization name: " org
- fi
-
- # Read user
- local compcontext="user:User Name:(\"$USER\" \"$user\")"
- vared -cp "Github user name or just \"_local\" (or leave blank, for an userless plugin): " user
-
- # Read plugin
- unset compcontext
- vared -cp 'Plugin name: ' plugin
-
- if [[ "$plugin" = "_unknown" ]]; then
- builtin print "${ZI[col-error]}No plugin name entered${ZI[col-rst]}"
- return 1
- fi
-
- plugin="${plugin//[^a-zA-Z0-9_]##/-}"
- .zi-any-colorify-as-uspl2 "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin"
- local uspl2col="$REPLY"
- builtin print "Plugin is $uspl2col"
-
- if .zi-exists-physically "${${${(M)isorg:#(y|yes)}:+$org}:-$user}" "$plugin"; then
- builtin print "${ZI[col-error]}Repository${ZI[col-rst]} $uspl2col ${ZI[col-error]}already exists locally${ZI[col-rst]}"
- return 1
- fi
-
- builtin cd -q "${ZI[PLUGINS_DIR]}"
-
- if [[ "$user" != "_local" && -n "$user" ]]; then
- builtin print "${ZI[col-info]}Creating Github repository${ZI[col-rst]}"
- if [[ $isorg = (y|yes) ]]; then
- curl --silent -u "$user" https://api.github.com/orgs/$org/repos -d '{"name":"'"$plugin"'"}' >/dev/null
- else
- curl --silent -u "$user" https://api.github.com/user/repos -d '{"name":"'"$plugin"'"}' >/dev/null
- fi
- command git clone "https://github.com/${${${(M)isorg:#(y|yes)}:+$org}:-$user}/${plugin}.git" "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}" || {
- builtin print "${ZI[col-error]}Creation of remote repository $uspl2col ${ZI[col-error]}failed${ZI[col-rst]}"
- builtin print "${ZI[col-error]}Bad credentials?${ZI[col-rst]}"
- return 1
- }
- builtin cd -q "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}"
- command git config credential.https://github.com.username "${user}"
+ curl --silent -u "$user" https://api.github.com/orgs/$org/repos -d '{"name":"'"$plugin"'"}' >/dev/null
else
- builtin print "${ZI[col-info]}Creating local git repository${${user:+.}:-, ${ZI[col-pname]}free-style, without the \"_local/\" part${ZI[col-info]}.}${ZI[col-rst]}"
- command mkdir "${user:+${user}---}${plugin//\//---}"
- builtin cd -q "${user:+${user}---}${plugin//\//---}"
- command git init || {
- builtin print "Git repository initialization failed, aborting"
- return 1
- }
+ curl --silent -u "$user" https://api.github.com/user/repos -d '{"name":"'"$plugin"'"}' >/dev/null
fi
+ command git clone "https://github.com/${${${(M)isorg:#(y|yes)}:+$org}:-$user}/${plugin}.git" "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}" || {
+ builtin print "${ZI[col-error]}Creation of remote repository $uspl2col ${ZI[col-error]}failed${ZI[col-rst]}"
+ builtin print "${ZI[col-error]}Bad credentials?${ZI[col-rst]}"
+ return 1
+ }
+ builtin cd -q "${${${(M)isorg:#(y|yes)}:+$org}:-$user}---${plugin//\//---}"
+ command git config credential.https://github.com.username "${user}"
+ else
+ builtin print "${ZI[col-info]}Creating local git repository${${user:+.}:-, ${ZI[col-pname]}free-style, without the \"_local/\" part${ZI[col-info]}.}${ZI[col-rst]}"
+ command mkdir "${user:+${user}---}${plugin//\//---}"
+ builtin cd -q "${user:+${user}---}${plugin//\//---}"
+ command git init || {
+ builtin print "Git repository initialization failed, aborting"
+ return 1
+ }
+ fi
+ local user_name="$(command git config user.name 2>/dev/null)"
+ local year="${$(command date "+%Y"):-2020}"
- local user_name="$(command git config user.name 2>/dev/null)"
- local year="${$(command date "+%Y"):-2020}"
-
- command cat >! "${plugin:t}.plugin.zsh" <! "${plugin:t}.plugin.zsh" <>! .git/config <>! .git/config <! .gitattributes
- builtin print -r -- "*.md diff=markdown" >! .gitattributes
- builtin print -r -- "# $plugin" >! "README.md"
- command cp -vf "${ZI[BIN_DIR]}/LICENSE" LICENSE
- command cp -vf "${ZI[BIN_DIR]}/lib/templates/zsh.gitignore" .gitignore
- command cp -vf "${ZI[BIN_DIR]}/lib/templates/example-script" .
-
- command sed -i -e "s/MY_PLUGIN_DIR/${${(U)plugin:t}//-/_}_DIR/g" example-script
- command sed -i -e "s/USER_NAME/$user_name/g" example-script
- command sed -i -e "s/YEAR/$year/g" example-script
-
- if [[ "$user" != "_local" && -n "$user" ]]; then
- builtin print "Remote repository $uspl2col set up as origin."
- builtin print "You're in plugin's local folder, the files aren't added to git."
- builtin print "Your next step after commiting will be:"
- builtin print "git push -u origin master (or \`… -u origin main')"
- else
- builtin print "Created local $uspl2col plugin."
- builtin print "You're in plugin's repository folder, the files aren't added to git."
- fi
+ builtin print -r -- "*.zsh diff=zsh" >! .gitattributes
+ builtin print -r -- "*.md diff=markdown" >! .gitattributes
+ builtin print -r -- "# $plugin" >! "README.md"
+ command cp -vf "${ZI[BIN_DIR]}/LICENSE" LICENSE
+ command cp -vf "${ZI[BIN_DIR]}/lib/templates/zsh.gitignore" .gitignore
+ command cp -vf "${ZI[BIN_DIR]}/lib/templates/example-script" .
+
+ command sed -i -e "s/MY_PLUGIN_DIR/${${(U)plugin:t}//-/_}_DIR/g" example-script
+ command sed -i -e "s/USER_NAME/$user_name/g" example-script
+ command sed -i -e "s/YEAR/$year/g" example-script
+
+ if [[ "$user" != "_local" && -n "$user" ]]; then
+ builtin print "Remote repository $uspl2col set up as origin."
+ builtin print "You're in plugin's local folder, the files aren't added to git."
+ builtin print "Your next step after commiting will be:"
+ builtin print "git push -u origin master (or \`… -u origin main')"
+ else
+ builtin print "Created local $uspl2col plugin."
+ builtin print "You're in plugin's repository folder, the files aren't added to git."
+ fi
} # ]]]
# FUNCTION: .zi-glance [[[
# Shows colorized source code of plugin. Is able to use pygmentize,
@@ -3066,45 +2772,43 @@ EOF
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-glance() {
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}"
-
- .zi-exists-physically-message "$user" "$plugin" || return 1
-
- .zi-first "$1" "$2" || {
- builtin print "${ZI[col-error]}No source file found, cannot glance${ZI[col-rst]}"
- return 1
- }
-
- local fname="${reply[-1]}"
-
- integer has_256_colors=0
- [[ "$TERM" = xterm* || "$TERM" = "screen" ]] && has_256_colors=1
-
- {
- if (( ${+commands[pygmentize]} )); then
- builtin print "Glancing with ${ZI[col-info]}pygmentize${ZI[col-rst]}"
- pygmentize -l bash -g "$fname"
- elif (( ${+commands[highlight]} )); then
- builtin print "Glancing with ${ZI[col-info]}highlight${ZI[col-rst]}"
- if (( has_256_colors )); then
- highlight -q --force -S sh -O xterm256 "$fname"
- else
- highlight -q --force -S sh -O ansi "$fname"
- fi
- elif (( ${+commands[source-highlight]} )); then
- builtin print "Glancing with ${ZI[col-info]}source-highlight${ZI[col-rst]}"
- source-highlight -fesc --failsafe -s zsh -o STDOUT -i "$fname"
- else
- cat "$fname"
- fi
- } | {
- if [[ -t 1 ]]; then
- .zi-pager
- else
- cat
- fi
- }
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}"
+
+ .zi-exists-physically-message "$user" "$plugin" || return 1
+
+ .zi-first "$1" "$2" || {
+ builtin print "${ZI[col-error]}No source file found, cannot glance${ZI[col-rst]}"
+ return 1
+ }
+ local fname="${reply[-1]}"
+
+ integer has_256_colors=0
+ [[ "$TERM" = xterm* || "$TERM" = "screen" ]] && has_256_colors=1
+ {
+ if (( ${+commands[pygmentize]} )); then
+ builtin print "Glancing with ${ZI[col-info]}pygmentize${ZI[col-rst]}"
+ pygmentize -l bash -g "$fname"
+ elif (( ${+commands[highlight]} )); then
+ builtin print "Glancing with ${ZI[col-info]}highlight${ZI[col-rst]}"
+ if (( has_256_colors )); then
+ highlight -q --force -S sh -O xterm256 "$fname"
+ else
+ highlight -q --force -S sh -O ansi "$fname"
+ fi
+ elif (( ${+commands[source-highlight]} )); then
+ builtin print "Glancing with ${ZI[col-info]}source-highlight${ZI[col-rst]}"
+ source-highlight -fesc --failsafe -s zsh -o STDOUT -i "$fname"
+ else
+ cat "$fname"
+ fi
+ } | {
+ if [[ -t 1 ]]; then
+ .zi-pager
+ else
+ cat
+ fi
+ }
} # ]]]
# FUNCTION: .zi-edit [[[
# Runs $EDITOR on source of given plugin. If the variable is not
@@ -3115,28 +2819,26 @@ EOF
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-edit() {
- local -A ICE2
- local local_dir filename is_snippet the_id="$1${${1:#(%|/)*}:+${2:+/}}$2"
-
- .zi-compute-ice "$the_id" "pack" \
- ICE2 local_dir filename is_snippet || return 1
+ local -A ICE2
+ local local_dir filename is_snippet the_id="$1${${1:#(%|/)*}:+${2:+/}}$2"
- ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}"
+ .zi-compute-ice "$the_id" "pack" \
+ ICE2 local_dir filename is_snippet || return 1
- if (( is_snippet )); then
- if [[ ! -e "$local_dir" ]]; then
- builtin print "No such snippet"
- return 1
- fi
- else
- if [[ ! -e "$local_dir" ]]; then
- builtin print -r -- "No such plugin or snippet"
- return 1
- fi
+ ICE2[teleid]="${ICE2[teleid]:-${ICE2[id-as]}}"
+ if (( is_snippet )); then
+ if [[ ! -e "$local_dir" ]]; then
+ builtin print "No such snippet"
+ return 1
fi
-
- "${EDITOR:-vim}" "$local_dir"
- return 0
+ else
+ if [[ ! -e "$local_dir" ]]; then
+ builtin print -r -- "No such plugin or snippet"
+ return 1
+ fi
+ fi
+ "${EDITOR:-vim}" "$local_dir"
+ return 0
} # ]]]
# FUNCTION: .zi-stress [[[
# Compiles plugin with various options on and off to see
@@ -3150,149 +2852,132 @@ EOF
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-stress() {
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}"
-
- .zi-exists-physically-message "$user" "$plugin" || return 1
-
- .zi-first "$1" "$2" || {
- builtin print "${ZI[col-error]}No source file found, cannot stress${ZI[col-rst]}"
- return 1
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}"
+ .zi-exists-physically-message "$user" "$plugin" || return 1
+ .zi-first "$1" "$2" || {
+ builtin print "${ZI[col-error]}No source file found, cannot stress${ZI[col-rst]}"
+ return 1
+ }
+ local pdir_path="${reply[-2]}" fname="${reply[-1]}"
+ integer compiled=1
+ [[ -e "${fname}.zwc" ]] && command rm -f "${fname}.zwc" || compiled=0
+ local -a ZI_STRESS_TEST_OPTIONS
+ ZI_STRESS_TEST_OPTIONS=(
+ "NO_SHORT_LOOPS" "IGNORE_BRACES" "IGNORE_CLOSE_BRACES"
+ "SH_GLOB" "CSH_JUNKIE_QUOTES" "NO_MULTI_FUNC_DEF"
+ )
+ (
+ emulate -LR ksh
+ builtin unsetopt shglob kshglob
+ for i in "${ZI_STRESS_TEST_OPTIONS[@]}"; do
+ builtin setopt "$i"
+ builtin print -n "Stress-testing ${fname:t} for option $i "
+ zcompile -UR "$fname" 2>/dev/null && {
+ builtin print "[${ZI[col-success]}Success${ZI[col-rst]}]"
+ } || {
+ builtin print "[${ZI[col-failure]}Fail${ZI[col-rst]}]"
}
-
- local pdir_path="${reply[-2]}" fname="${reply[-1]}"
-
- integer compiled=1
- [[ -e "${fname}.zwc" ]] && command rm -f "${fname}.zwc" || compiled=0
-
- local -a ZI_STRESS_TEST_OPTIONS
- ZI_STRESS_TEST_OPTIONS=(
- "NO_SHORT_LOOPS" "IGNORE_BRACES" "IGNORE_CLOSE_BRACES"
- "SH_GLOB" "CSH_JUNKIE_QUOTES" "NO_MULTI_FUNC_DEF"
- )
-
- (
- emulate -LR ksh
- builtin unsetopt shglob kshglob
- for i in "${ZI_STRESS_TEST_OPTIONS[@]}"; do
- builtin setopt "$i"
- builtin print -n "Stress-testing ${fname:t} for option $i "
- zcompile -UR "$fname" 2>/dev/null && {
- builtin print "[${ZI[col-success]}Success${ZI[col-rst]}]"
- } || {
- builtin print "[${ZI[col-failure]}Fail${ZI[col-rst]}]"
- }
- builtin unsetopt "$i"
- done
- )
-
- command rm -f "${fname}.zwc"
- (( compiled )) && zcompile -U "$fname"
+ builtin unsetopt "$i"
+ done
+ )
+ command rm -f "${fname}.zwc"
+ (( compiled )) && zcompile -U "$fname"
} # ]]]
# FUNCTION: .zi-list-compdef-replay [[[
-# Shows recorded compdefs (called by plugins loaded earlier).
-# Plugins often call `compdef' hoping for `compinit' being
-# already ran. ZI solves this by recording compdefs.
+# Shows recorded compdefs (called by plugins loaded earlier). Plugins often call `compdef' hoping
+# for `compinit' being already ran. ❮ ZI ❯ solves this by recording compdefs.
#
# User-action entry point.
.zi-list-compdef-replay() {
- builtin print "Recorded compdefs:"
- local cdf
- for cdf in "${ZI_COMPDEF_REPLAY[@]}"; do
- builtin print "compdef ${(Q)cdf}"
- done
+ builtin print "Recorded compdefs:"
+ local cdf
+ for cdf in "${ZI_COMPDEF_REPLAY[@]}"; do
+ builtin print "compdef ${(Q)cdf}"
+ done
} # ]]]
# FUNCTION: .zi-ls [[[
.zi-ls() {
- (( ${+commands[tree]} )) || {
- builtin print "${ZI[col-error]}No \`tree' program, it is required by the subcommand \`ls\'${ZI[col-rst]}"
- builtin print "Download from: http://mama.indstate.edu/users/ice/tree/"
- builtin print "It is also available probably in all distributions and Homebrew, as package \`tree'"
- }
- (
- setopt localoptions extendedglob nokshglob noksharrays
- builtin cd -q "${ZI[SNIPPETS_DIR]}"
- local -a list
- list=( "${(f@)"$(LANG=en_US.utf-8 tree -L 3 --charset utf-8)"}" )
- # Oh-My-Zsh single file
- list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--raw--master(--)(#c0,1)(*))/$ZI[col-info]Oh-My-Zsh$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](single-file)$ZI[col-rst] ${match[1]}}" )
- # Oh-My-Zsh SVN
- list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--trunk(--)(#c0,1)(*))/$ZI[col-info]Oh-My-Zsh$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](SVN)$ZI[col-rst] ${match[1]}}" )
- # Prezto single file
- list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--raw--master(--)(#c0,1)(*))/$ZI[col-info]Prezto$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](single-file)$ZI[col-rst] ${match[1]}}" )
- # Prezto SVN
- list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--trunk(--)(#c0,1)(*))/$ZI[col-info]Prezto$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](SVN)$ZI[col-rst] ${match[1]}}" )
-
- # First-level names
- list=( "${list[@]//(#b)(#s)(│ └──| └──| ├──|│ ├──) (*)/${match[1]} $ZI[col-p]${match[2]}$ZI[col-rst]}" )
- list[-1]+=", located at ZI[SNIPPETS_DIR], i.e. ${ZI[SNIPPETS_DIR]}"
- builtin print -rl -- "${list[@]}"
- )
-}
-# ]]]
+ (( ${+commands[tree]} )) || {
+ builtin print "${ZI[col-error]}No \`tree' program, it is required by the subcommand \`ls\'${ZI[col-rst]}"
+ builtin print "Download from: http://mama.indstate.edu/users/ice/tree/"
+ builtin print "It is also available probably in all distributions and Homebrew, as package \`tree'"
+ }
+ (
+ builtin cd -q "${ZI[SNIPPETS_DIR]}"
+ local -a list
+ list=( "${(f@)"$(LANG=en_US.utf-8 tree -L 3 --charset utf-8)"}" )
+ # Oh-My-Zsh single file
+ list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--raw--master(--)(#c0,1)(*))/$ZI[col-info]Oh-My-Zsh$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](single-file)$ZI[col-rst] ${match[1]}}" )
+ # Oh-My-Zsh SVN
+ list=( "${list[@]//(#b)(https--github.com--(ohmyzsh|robbyrussel)l--oh-my-zsh--trunk(--)(#c0,1)(*))/$ZI[col-info]Oh-My-Zsh$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](SVN)$ZI[col-rst] ${match[1]}}" )
+ # Prezto single file
+ list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--raw--master(--)(#c0,1)(*))/$ZI[col-info]Prezto$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](single-file)$ZI[col-rst] ${match[1]}}" )
+ # Prezto SVN
+ list=( "${list[@]//(#b)(https--github.com--sorin-ionescu--prezto--trunk(--)(#c0,1)(*))/$ZI[col-info]Prezto$ZI[col-error]${match[2]/--//}$ZI[col-pname]${match[3]//--/$ZI[col-error]/$ZI[col-pname]} $ZI[col-info](SVN)$ZI[col-rst] ${match[1]}}" )
+ # First-level names
+ list=( "${list[@]//(#b)(#s)(│ └──| └──| ├──|│ ├──) (*)/${match[1]} $ZI[col-p]${match[2]}$ZI[col-rst]}" )
+ list[-1]+=", located at ZI[SNIPPETS_DIR], i.e. ${ZI[SNIPPETS_DIR]}"
+ builtin print -rl -- "${list[@]}"
+ )
+} # ]]]
# FUNCTION: .zi-get-path [[[
# Returns path of given ID-string, which may be a plugin-spec
# (like "user/plugin" or "user" "plugin"), an absolute path
# ("%" "/home/..." and also "%SNIPPETS/..." etc.), or a plugin
# nickname (i.e. id-as'' ice-mod), or a snippet nickname.
.zi-get-path() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops
- [[ $1 == % ]] && local id_as=%$2 || local id_as=$1${1:+/}$2
- .zi-get-object-path snippet "$id_as" || \
- .zi-get-object-path plugin "$id_as"
-
- return $(( 1 - reply[3] ))
-}
-# ]]]
+ [[ $1 == % ]] && local id_as=%$2 || local id_as=$1${1:+/}$2
+ .zi-get-object-path snippet "$id_as" || \
+ .zi-get-object-path plugin "$id_as"
+ return $(( 1 - reply[3] ))
+} # ]]]
# FUNCTION: .zi-recall [[[
.zi-recall() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops
-
- local -A ice
- local el val cand1 cand2 local_dir filename is_snippet
-
- local -a ice_order nval_ices output
- ice_order=(
- ${(s.|.)ZI[ice-list]}
-
- # Include all additional ices – after
- # stripping them from the possible: ''
- ${(@)${(@Akons:|:u)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
- )
- nval_ices=(
- ${(s.|.)ZI[nval-ice-list]}
- # Include only those additional ices,
- # don't have the '' in their name, i.e.
- # aren't designed to hold value
- ${(@)${(@)${(@Akons:|:u)ZI_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/}
- # Must be last
- svn
- )
- .zi-compute-ice "$1${${1:#(%|/)*}:+${2:+/}}$2" "pack" \
- ice local_dir filename is_snippet || return 1
-
- [[ -e $local_dir ]] && {
- for el ( ${ice_order[@]} ) {
- val="${ice[$el]}"
- cand1="${(qqq)val}"
- cand2="${(qq)val}"
- if [[ -n "$val" ]] {
- [[ "${cand1/\\\$/}" != "$cand1" || "${cand1/\\\!/}" != "$cand1" ]] && output+=( "$el$cand2" ) || output+=( "$el$cand1" )
- } elif [[ ${+ice[$el]} = 1 && -n "${nval_ices[(r)$el]}" ]] {
- output+=( "$el" )
- }
- }
-
- if [[ ${#output} = 0 ]]; then
- builtin print -zr "# No Ice modifiers"
- else
- builtin print -zr "zi ice ${output[*]}; zi "
- fi
- +zi-deploy-message @rst
- } || builtin print -r -- "No such plugin or snippet"
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops
+
+ local -A ice
+ local el val cand1 cand2 local_dir filename is_snippet
+ local -a ice_order nval_ices output
+ ice_order=(
+ ${(s.|.)ZI[ice-list]}
+ # Include all additional ices – after
+ # stripping them from the possible: ''
+ ${(@)${(@Akons:|:u)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
+ )
+ nval_ices=(
+ ${(s.|.)ZI[nval-ice-list]}
+ # Include only those additional ices,
+ # don't have the '' in their name, i.e.
+ # aren't designed to hold value
+ ${(@)${(@)${(@Akons:|:u)ZI_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/}
+ # Must be last
+ svn
+ )
+ .zi-compute-ice "$1${${1:#(%|/)*}:+${2:+/}}$2" "pack" \
+ ice local_dir filename is_snippet || return 1
+ [[ -e $local_dir ]] && {
+ for el ( ${ice_order[@]} ) {
+ val="${ice[$el]}"
+ cand1="${(qqq)val}"
+ cand2="${(qq)val}"
+ if [[ -n "$val" ]] {
+ [[ "${cand1/\\\$/}" != "$cand1" || "${cand1/\\\!/}" != "$cand1" ]] && output+=( "$el$cand2" ) || output+=( "$el$cand1" )
+ } elif [[ ${+ice[$el]} = 1 && -n "${nval_ices[(r)$el]}" ]] {
+ output+=( "$el" )
+ }
+ }
+ if [[ ${#output} = 0 ]]; then
+ builtin print -zr "# No Ice modifiers"
+ else
+ builtin print -zr "zi ice ${output[*]}; zi "
+ fi
+ +zi-deploy-message @rst
+ } || builtin print -r -- "No such plugin or snippet"
}
# ]]]
# FUNCTION: .zi-module [[[
@@ -3300,77 +2985,76 @@ EOF
# It's an attempt to plugin only this one function into `zi' function
# defined in zi.zsh, to not make this file longer than it's needed.
.zi-module() {
- if [[ "$1" = "build" ]]; then
- .zi-build-module "${@[2,-1]}"
- elif [[ "$1" = "info" ]]; then
- if [[ "$2" = "--link" ]]; then
- builtin print -r "You can copy the error messages and submit"
- builtin print -r "error-report at: https://github.com/z-shell/zpmod/issues"
- else
- builtin print -r "To load the module, add following 2 lines to .zshrc, at top:"
- builtin print -r " module_path+=( ${ZI[ZMODULES_DIR]}/zpmod/Src )"
- builtin print -r " zmodload zi/zpmod"
- builtin print -r ""
- builtin print -r "After loading, use command \`zpmod' to communicate with the module."
- builtin print -r "See \`zpmod -h' for more information."
- fi
- elif [[ "$1" = (help|usage) ]]; then
- builtin print -r "Usage: zi module {build|info|help} [options]"
- builtin print -r " zi module build [--clean]"
- builtin print -r " zi module info [--link]"
- builtin print -r ""
- builtin print -r "To start using the ZI Zsh module run: \`zi module build'"
- builtin print -r "and follow the instructions. Option --clean causes \`make distclean'"
- builtin print -r "to be run. To display the instructions on loading the module, run:"
- builtin print -r "\`zi module info'."
+ if [[ "$1" = "build" ]]; then
+ .zi-build-module "${@[2,-1]}"
+ elif [[ "$1" = "info" ]]; then
+ if [[ "$2" = "--link" ]]; then
+ builtin print -r "You can copy the error messages and submit"
+ builtin print -r "error-report at: https://github.com/z-shell/zpmod/issues"
+ else
+ builtin print -r "To load the module, add following 2 lines to .zshrc, at top:"
+ builtin print -r " module_path+=( ${ZI[ZMODULES_DIR]}/zpmod/Src )"
+ builtin print -r " zmodload zi/zpmod"
+ builtin print -r ""
+ builtin print -r "After loading, use command \`zpmod' to communicate with the module."
+ builtin print -r "See \`zpmod -h' for more information."
fi
+ elif [[ "$1" = (help|usage) ]]; then
+ builtin print -r "Usage: zi module {build|info|help} [options]"
+ builtin print -r " zi module build [--clean]"
+ builtin print -r " zi module info [--link]"
+ builtin print -r ""
+ builtin print -r "To start using the ❮ ZI ❯ Zsh module run: \`zi module build'"
+ builtin print -r "and follow the instructions. Option --clean causes \`make distclean'"
+ builtin print -r "to be run. To display the instructions on loading the module, run:"
+ builtin print -r "\`zi module info'."
+ fi
}
# ]]]
# FUNCTION: .zi-build-module [[[
-# Performs ./configure && make on the module and displays information
-# how to load the module in .zshrc.
+# Performs ./configure && make on the module and displays information how to load the module in .zshrc.
.zi-build-module() {
- if command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" rev-parse 2>/dev/null; then
- command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" clean -d -f -f
- command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" reset --hard HEAD
- command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" pull
- else
- if ! test -d "${${ZI[ZMODULES_DIR]}}/zpmod"; then
- mkdir -p "${${ZI[ZMODULES_DIR]}}/zpmod"
- chmod g-rwX "${${ZI[ZMODULES_DIR]}}/zpmod"
- fi
- command git clone "https://github.com/z-shell/zpmod.git" "${${ZI[ZMODULES_DIR]}}/zpmod" || {
- builtin print "${ZI[col-error]}Failed to clone module repo${ZI[col-rst]}"
- return 1
- }
+ if command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" rev-parse 2>/dev/null; then
+ command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" clean -d -f -f
+ command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" reset --hard HEAD
+ command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" pull
+ else
+ if ! test -d "${${ZI[ZMODULES_DIR]}}/zpmod"; then
+ mkdir -p "${${ZI[ZMODULES_DIR]}}/zpmod"
+ chmod g-rwX "${${ZI[ZMODULES_DIR]}}/zpmod"
fi
- ( builtin cd -q "${ZI[ZMODULES_DIR]}/zpmod"
- +zi-message "{pname}== Building module zi/zpmod, running: make clean, then ./configure and then make =={rst}"
- +zi-message "{pname}== The module sources are located at: "${ZI[ZMODULES_DIR]}/zpmod" =={rst}"
- if [[ -f Makefile ]] {
- if [[ "$1" = "--clean" ]] {
- noglob +zi-message {p}-- make distclean --{rst}
- make distclean
- ((1))
- } else {
- noglob +zi-message {p}-- make clean --{rst}
- make clean
- }
- }
- noglob +zi-message {p}-- ./configure --{rst}
- CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && {
- noglob +zi-message {p}-- make --{rst}
- if { make } {
- [[ -f Src/zi/zpmod.so ]] && cp -vf Src/zi/zpmod.{so,bundle}
- noglob +zi-message "{info}Module has been built correctly.{rst}"
- .zi-module info
- } else {
- noglob +zi-message "{error}Module didn't build.{rst} "
- .zi-module info --link
- }
- }
- builtin print $EPOCHSECONDS >! "${ZI[ZMODULES_DIR]}/zpmod/COMPILED_AT"
- )
+ command git clone "https://github.com/z-shell/zpmod.git" "${${ZI[ZMODULES_DIR]}}/zpmod" || {
+ builtin print "${ZI[col-error]}Failed to clone module repo${ZI[col-rst]}"
+ return 1
+ }
+ fi
+ ( builtin cd -q "${ZI[ZMODULES_DIR]}/zpmod"
+ +zi-message "{pname}== Building module zi/zpmod, running: make clean, then ./configure and then make =={rst}"
+ +zi-message "{pname}== The module sources are located at: "${ZI[ZMODULES_DIR]}/zpmod" =={rst}"
+ if [[ -f Makefile ]] {
+ if [[ "$1" = "--clean" ]] {
+ noglob +zi-message {p}-- make distclean --{rst}
+ make distclean
+ ((1))
+ } else {
+ noglob +zi-message {p}-- make clean --{rst}
+ make clean
+ }
+ }
+ noglob +zi-message {p}-- ./configure --{rst}
+ CPPFLAGS=-I/usr/local/include CFLAGS="-g -Wall -O3" LDFLAGS=-L/usr/local/lib ./configure --disable-gdbm --without-tcsetpgrp && {
+ noglob +zi-message {p}-- make --{rst}
+ if { make } {
+ [[ -f Src/zi/zpmod.so ]] && cp -vf Src/zi/zpmod.{so,bundle}
+ noglob +zi-message "{info}Module has been built correctly.{rst}"
+ .zi-module info
+ } else {
+ noglob +zi-message "{error}Module didn't build.{rst} "
+ .zi-module info --link
+ }
+ }
+ builtin print $EPOCHSECONDS >! "${ZI[ZMODULES_DIR]}/zpmod/COMPILED_AT"
+ )
} # ]]]
#
@@ -3382,33 +3066,32 @@ EOF
#
# User-action entry point.
.zi-help() {
- builtin print -r -- "${ZI[col-p]}Usage${ZI[col-rst]}:
-»»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»»
-❯ analytics – ZI Analytics
-❯ control – ZI Control options
-❯ self-update – ZI Self update and compile
-❯ compinit – Refresh completions
-❯ cdreplay [-q] – Replay compdefs (to be done after compinit), -q – quiet
-❯ cdclear [-q] – Clear compdef replay list, -q – quiet
-❯ bindkeys – Lists bindkeys
-❯ help – ZI usage
-❯ man – ZI manual
-❯ module – Manage zpmod (binary Zsh module), see \`zi module help'
+ builtin print -r -- "${ZI[col-p]}❮ ZI ❯ Usage${ZI[col-rst]}:
+»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
+❯ analytics – ❮ ZI ❯ Analytics
+❯ control – ❮ ZI ❯ Control options
+❯ self-update – ❮ ZI ❯ Self update and compile
+❯ compinit – Refresh completions
+❯ cdreplay [-q] – Replay compdefs (to be done after compinit), -q – quiet
+❯ cdclear [-q] – Clear compdef replay list, -q – quiet
+❯ bindkeys – Lists bindkeys
+❯ module – Manage zpmod (binary Zsh module), see \`zi module help'
❯ env-whitelist [-v|-h] {env..} – Specify names or paterns of variables left unchanged during an unload. -v – verbose
-»»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»»"
- integer idx
- local type key
- local -a arr
- for type in subcommand hook; do
- for (( idx=1; idx <= ZI_EXTS[seqno]; ++ idx )); do
- key="${(k)ZI_EXTS[(r)$idx *]}"
- [[ -z "$key" || "$key" != "z-annex $type:"* ]] && continue
- arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
- (( ${+functions[${arr[6]}]} )) && { "${arr[6]}"; ((1)); } || \
- { builtin print -rl -- "(Couldn't find the help-handler \`${arr[6]}' of the z-annex \`${arr[3]}')"; }
- done
+❯ man – Manual
+❯ help – Help
+»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»"
+ integer idx
+ local type key
+ local -a arr
+ for type in subcommand hook; do
+ for (( idx=1; idx <= ZI_EXTS[seqno]; ++ idx )); do
+ key="${(k)ZI_EXTS[(r)$idx *]}"
+ [[ -z "$key" || "$key" != "z-annex $type:"* ]] && continue
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
+ (( ${+functions[${arr[6]}]} )) && { "${arr[6]}"; ((1)); } || \
+ { builtin print -rl -- "(Couldn't find the help-handler \`${arr[6]}' of the z-annex \`${arr[3]}')"; }
done
-
+ done
local -a ice_order
ice_order=( ${${(s.|.)ZI[ice-list]}:#teleid} ${(@)${(@)${(@Akons:|:u)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}:#(.*|dynamic-unscope)} )
print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
@@ -3419,12 +3102,12 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
#
# FUNCTION: .zi-analytics-menu [[[
-# Shows ZI analytics.
+# Shows ❮ ZI ❯ analytics.
#
# User-action entry point.
.zi-analytics-menu() {
- builtin print -r -- "${ZI[col-p]}ZI Analytics${ZI[col-rst]}:
-»»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»»
+ builtin print -r -- "${ZI[col-p]}❮ ZI ❯ Analytics${ZI[col-rst]}:
+»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
❯ cd ${ZI[col-pname]}[plugin]${ZI[col-rst]} – Enter plugin's directory; also support snippets, if feed with URL
❯ status ${ZI[col-pname]}[plugin]${ZI[col-rst]}|URL – Git status for plugin or svn status for snippet; – accepts --all
❯ report ${ZI[col-pname]}[plugin]${ZI[col-rst]} – Show plugin's report; – accepts --all
@@ -3433,7 +3116,7 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
❯ changes ${ZI[col-pname]}[plugin]${ZI[col-rst]} – View plugin's git log
❯ recently ${ZI[col-info]}[time]${ZI[col-rst]} – Show plugins that changed recently, argument is e.g. 1 month 2 days
❯ times [-s] [-m] – Statistics on plugin load times, sorted in order of loading; -s – use seconds instead of milliseconds, -m – show plugin loading moments
-❯ zstatus – Overall ZI status
+❯ zstatus – Overall ❮ ZI ❯ status
❯ dtrace|dstart – Start tracking what's going on in session
❯ dstop – Stop tracking what's going on in session
❯ dreport – Report what was going on in session
@@ -3445,7 +3128,7 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
❯ cdlist – Show compdef replay list
❯ csearch – Search for available completions from any plugin
❯ ls – List snippets in formatted and colorized manner
-»»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»»"
+»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»"
} # ]]]
#
@@ -3457,8 +3140,8 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
#
# User-action entry point.
.zi-control-menu() {
- builtin print -r -- "${ZI[col-p]}ZI Control${ZI[col-rst]}:
-»»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»»
+ builtin print -r -- "${ZI[col-p]}ZI Control${ZI[col-rst]}:
+»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
❯ update [-q] ${ZI[col-pname]}[plugin]${ZI[col-rst]}|URL – Git update plugin or snippet; – accepts --all; -q/--quiet; -r/--reset causes to run 'git reset --hard' or 'svn revert'
❯ load ${ZI[col-pname]}[plugin]${ZI[col-rst]} – Load plugin, can also receive absolute local path
❯ light [-b] ${ZI[col-pname]}[plugin]${ZI[col-rst]} – Light plugin load, without reporting/tracking (-b – do track but bindkey-calls only)
@@ -3478,5 +3161,5 @@ print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
❯ run [-l] ${ZI[col-pname]}[plugin]${ZI[col-rst]}|CMD – Runs command in the given plugin's directory; if -l given then plugin should be skipped – the option will cause the previous plugin to be reused
❯ ice ${ZI[col-pname]}${ZI[col-rst]} – Add ICE to next command, e.g. from\"gitlab\"
❯ srv ${ZI[col-pname]}{service-id}${ZI[col-rst]}|CMD – Control a service, command can be: stop,start,restart,next,quit; \`next' moves the service to another Z-Shell
-»»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»» »»»"
-} # ]]]
\ No newline at end of file
+»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»"
+} # ]]]
diff --git a/lib/zsh/git-process-output.zsh b/lib/zsh/git-process-output.zsh
index 1582b4de..2977916b 100755
--- a/lib/zsh/git-process-output.zsh
+++ b/lib/zsh/git-process-output.zsh
@@ -6,7 +6,7 @@ setopt typesetsilent extendedglob warncreateglobal
{ typeset -g COLS="$(tput cols)" } 2>/dev/null
if (( COLS < 10 )) {
- COLS=40
+ COLS=40
}
# Credit to molovo/revolver for the ideas
typeset -ga progress_frames
@@ -26,13 +26,13 @@ typeset -F SECONDS=0 last_time=0
# Alpine Linux doesn't have tput; FreeBSD and Dragonfly BSD have termcap
if whence tput &> /dev/null; then
if [[ $OSTYPE == freebsd* ]] || [[ $OSTYPE == dragonfly* ]]; then
- # termcap commands
- ZI_CNORM='tput ve'
- ZI_CIVIS='tput vi'
+ # termcap commands
+ ZI_CNORM='tput ve'
+ ZI_CIVIS='tput vi'
else
- # terminfo is more common
- ZI_CNORM='tput cnorm'
- ZI_CIVIS='tput civis'
+ # terminfo is more common
+ ZI_CNORM='tput cnorm'
+ ZI_CIVIS='tput civis'
fi
fi
@@ -53,11 +53,10 @@ timeline() {
local -a frames_splitted
frames_splitted=( ${(@zQ)progress_frames[progress_style]} )
if (( SECONDS - last_time >= frames_splitted[1] )) {
- (( cur_frame = (cur_frame+1) % (${#frames_splitted}+1-1) ))
- (( cur_frame = cur_frame ? cur_frame : 1 ))
- last_time=$SECONDS
+ (( cur_frame = (cur_frame+1) % (${#frames_splitted}+1-1) ))
+ (( cur_frame = cur_frame ? cur_frame : 1 ))
+ last_time=$SECONDS
}
-
print -nr -- ${frames_splitted[cur_frame+1]}" "
print -nPr "%F{183}"
print -f "%s %s" "${bar// /░}" ""
@@ -69,32 +68,32 @@ timeline() {
# $4 - receiving percentage
# $5 - resolving percentage
print_my_line() {
- local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}"
- [[ -n "${4#...}" && -z "${5#...}" ]] && col3="%F{81}"
- [[ -n "${5#...}" ]] && col4="%F{81}"
- if (( COLS >= 70 )) {
- print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} "
- } elif (( COLS >= 60 )) {
- print -Pnr -- "${col}OBJ%f: $1, ${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} "
- } else {
- print -Pnr -- "${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} "
- }
- print -n $'\015'
+ local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}"
+ [[ -n "${4#...}" && -z "${5#...}" ]] && col3="%F{81}"
+ [[ -n "${5#...}" ]] && col4="%F{81}"
+ if (( COLS >= 70 )) {
+ print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} "
+ } elif (( COLS >= 60 )) {
+ print -Pnr -- "${col}OBJ%f: $1, ${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} "
+ } else {
+ print -Pnr -- "${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} "
+ }
+ print -n $'\015'
}
print_my_line_compress() {
- local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}"
- [[ -n "${4#...}" && -z "${5#...}" && -z "${6#...}" ]] && col3="%F{81}"
- [[ -n "${5#...}" && -z "${6#...}" ]] && col4="%F{81}"
- [[ -n "${6#...}" ]] && col5="%F{81}"
- if (( COLS >= 80 )) {
- print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3, ${col3}COMPR%f: $4%%${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} "
- } elif (( COLS >= 65 )) {
- print -Pnr -- "${col}OBJ%f: $1, ${col3}COMPR%f: $4%%${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} "
- } else {
- print -Pnr -- "${col}OBJ%f: $1, ${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} "
- }
- print -n $'\015'
+ local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}"
+ [[ -n "${4#...}" && -z "${5#...}" && -z "${6#...}" ]] && col3="%F{81}"
+ [[ -n "${5#...}" && -z "${6#...}" ]] && col4="%F{81}"
+ [[ -n "${6#...}" ]] && col5="%F{81}"
+ if (( COLS >= 80 )) {
+ print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3, ${col3}COMPR%f: $4%%${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} "
+ } elif (( COLS >= 65 )) {
+ print -Pnr -- "${col}OBJ%f: $1, ${col3}COMPR%f: $4%%${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} "
+ } else {
+ print -Pnr -- "${col}OBJ%f: $1, ${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} "
+ }
+ print -n $'\015'
}
integer have_1_counting=0 have_2_total=0 have_3_receiving=0 have_4_deltas=0 have_5_compress=0
@@ -106,76 +105,74 @@ IFS=''
[[ $+ZI_CIVIS == 1 && -n $TERM ]] && eval $ZI_CIVIS
if [[ -n $TERM ]] {
-
{ command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r/\n/' || \
- gstdbuf -o0 gtr '\r' '\n' || \
- cat } |& \
+ gstdbuf -o0 gtr '\r' '\n' || \
+ cat } |& \
while read -r line; do
- (( ++ loop_count ))
- if [[ "$line" = "Cloning into"* ]]; then
- print; print $line
- continue
- elif [[ "$line" = (#i)*user*name* || "$line" = (#i)*password* ]]; then
- print; print $line
- continue
- elif [[ "$line" = remote:*~*(Counting|Total|Compressing|Enumerating)* || "$line" = fatal:* ]]; then
- print $line
- continue
- fi
- if [[ "$line" = (#b)"remote: Counting objects:"[\ ]#([0-9]##)(*) ]]; then
- have_1_counting=1
- counting_1="${match[1]}"
- fi
- if [[ "$line" = (#b)"remote: Enumerating objects:"[\ ]#([0-9]##)(*) ]]; then
- have_1_counting=1
- counting_1="${match[1]}"
- fi
- if [[ "$line" = (#b)*"remote: Total"[\ ]#([0-9]##)*"pack-reused"[\ ]#([0-9]##)* ]]; then
- have_2_total=1
- total_2="${match[1]}" total_packed_2="${match[2]}"
- fi
- if [[ "$line" = (#b)"Receiving objects:"[\ ]#([0-9]##)%([[:blank:]]#\(([0-9]##)/([0-9]##)\)|)* ]]; then
- have_3_receiving=1
- receiving_3="${match[1]}"
- [[ -n "${match[2]}" ]] && {
- have_2_total=1
- total_packed_2="${match[3]}" total_2="${match[4]}"
- }
- fi
- if [[ "$line" = (#b)"Resolving deltas:"[\ ]#([0-9]##)%* ]]; then
- have_4_deltas=1
- deltas_4="${match[1]}"
- fi
- if [[ "$line" = (#b)"remote: Compressing objects:"[\ ]#([0-9]##)"%"(*) ]]; then
- have_5_compress=1
- compress_5="${match[1]}"
- fi
-
- if (( loop_count >= 2 )); then
- integer pr
- (( pr = have_4_deltas ? deltas_4 / 10 : (
- have_3_receiving ? receiving_3 / 10 : (
- have_5_compress ? compress_5 / 10 : ( ( ( loop_count - 1 ) / 14 ) % 10 ) + 1 ) ) ))
- timeline "" $pr 11
- if (( have_5_compress )); then
- print_my_line_compress "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \
- "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \
- "${${${(M)have_2_total:#1}:+$total_2}:-0}" \
- "${${${(M)have_5_compress:#1}:+$compress_5}:-...}" \
- "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \
- "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}"
- else
- print_my_line "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \
- "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \
- "${${${(M)have_2_total:#1}:+$total_2}:-0}" \
- "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \
- "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}"
- fi
+ (( ++ loop_count ))
+ if [[ "$line" = "Cloning into"* ]]; then
+ print; print $line
+ continue
+ elif [[ "$line" = (#i)*user*name* || "$line" = (#i)*password* ]]; then
+ print; print $line
+ continue
+ elif [[ "$line" = remote:*~*(Counting|Total|Compressing|Enumerating)* || "$line" = fatal:* ]]; then
+ print $line
+ continue
+ fi
+ if [[ "$line" = (#b)"remote: Counting objects:"[\ ]#([0-9]##)(*) ]]; then
+ have_1_counting=1
+ counting_1="${match[1]}"
+ fi
+ if [[ "$line" = (#b)"remote: Enumerating objects:"[\ ]#([0-9]##)(*) ]]; then
+ have_1_counting=1
+ counting_1="${match[1]}"
+ fi
+ if [[ "$line" = (#b)*"remote: Total"[\ ]#([0-9]##)*"pack-reused"[\ ]#([0-9]##)* ]]; then
+ have_2_total=1
+ total_2="${match[1]}" total_packed_2="${match[2]}"
+ fi
+ if [[ "$line" = (#b)"Receiving objects:"[\ ]#([0-9]##)%([[:blank:]]#\(([0-9]##)/([0-9]##)\)|)* ]]; then
+ have_3_receiving=1
+ receiving_3="${match[1]}"
+ [[ -n "${match[2]}" ]] && {
+ have_2_total=1
+ total_packed_2="${match[3]}" total_2="${match[4]}"
+ }
+ fi
+ if [[ "$line" = (#b)"Resolving deltas:"[\ ]#([0-9]##)%* ]]; then
+ have_4_deltas=1
+ deltas_4="${match[1]}"
+ fi
+ if [[ "$line" = (#b)"remote: Compressing objects:"[\ ]#([0-9]##)"%"(*) ]]; then
+ have_5_compress=1
+ compress_5="${match[1]}"
+ fi
+ if (( loop_count >= 2 )); then
+ integer pr
+ (( pr = have_4_deltas ? deltas_4 / 10 : (
+ have_3_receiving ? receiving_3 / 10 : (
+ have_5_compress ? compress_5 / 10 : ( ( ( loop_count - 1 ) / 14 ) % 10 ) + 1 ) ) ))
+ timeline "" $pr 11
+ if (( have_5_compress )); then
+ print_my_line_compress "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \
+ "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \
+ "${${${(M)have_2_total:#1}:+$total_2}:-0}" \
+ "${${${(M)have_5_compress:#1}:+$compress_5}:-...}" \
+ "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \
+ "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}"
+ else
+ print_my_line "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \
+ "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \
+ "${${${(M)have_2_total:#1}:+$total_2}:-0}" \
+ "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \
+ "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}"
fi
+ fi
done
} else {
- grep fatal:
+ grep fatal:
}
print
diff --git a/lib/zsh/install.zsh b/lib/zsh/install.zsh
index 194b3309..793911da 100755
--- a/lib/zsh/install.zsh
+++ b/lib/zsh/install.zsh
@@ -1,321 +1,313 @@
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors.
# Copyright (c) 2021 Salvydas Lukosius and Z-Shell ZI contributors.
-# Adjust the shellcheck fot Zsh compatibility.
-# shellcheck shell=sh disable=SC1009,1073,1027,1036,1072
-
builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col-error]}ERROR:%f%b Couldn't find ${ZI[col-obj]}/lib/zsh/side.zsh%f%b."; return 1; }
# FUNCTION: .zi-parse-json [[[
-# Retrievies the ice-list from given profile from
-# the JSON of the package.json.
+# Retrievies the ice-list from given profile from the JSON of the package.json.
.zi-parse-json() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent
-
- local -A ___pos_to_level ___level_to_pos ___pair_map \
- ___final_pairs ___Strings ___Counts
- local ___input=$1 ___workbuf=$1 ___key=$2 ___varname=$3 \
- ___style ___quoting
- integer ___nest=${4:-1} ___idx=0 ___pair_idx ___level=0 \
- ___start ___end ___sidx=1 ___had_quoted_value=0
- local -a match mbegin mend ___pair_order
- (( ${(P)+___varname} )) || typeset -gA "$___varname"
- ___pair_map=( "{" "}" "[" "]" )
-
- while [[ $___workbuf = (#b)[^"{}[]\\\"'":,]#((["{[]}\"'":,])|[\\](*))(*) ]]; do
- if [[ -n ${match[3]} ]] {
- ___idx+=${mbegin[1]}
-
- [[ $___quoting = \' ]] && \
- { ___workbuf=${match[3]}; } || \
- { ___workbuf=${match[3]:1}; (( ++ ___idx )); }
-
- } else {
- ___idx+=${mbegin[1]}
- if [[ -z $___quoting ]] {
- if [[ ${match[1]} = ["({["] ]]; then
- ___Strings[$___level/${___Counts[$___level]}]+=" $'\0'--object--$'\0'"
- ___pos_to_level[$___idx]=$(( ++ ___level ))
- ___level_to_pos[$___level]=$___idx
- (( ___Counts[$___level] += 1 ))
- ___sidx=___idx+1
- ___had_quoted_value=0
- elif [[ ${match[1]} = ["]})"] ]]; then
- (( !___had_quoted_value )) && \
- ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]//((#s)[[:blank:]]##|([[:blank:]]##(#e)))}"
- ___had_quoted_value=1
- if (( ___level > 0 )); then
- ___pair_idx=${___level_to_pos[$___level]}
- ___pos_to_level[$___idx]=$(( ___level -- ))
- if [[ ${___pair_map[${___input[___pair_idx]}]} = ${___input[___idx]} ]] {
- ___final_pairs[$___idx]=$___pair_idx
- ___final_pairs[$___pair_idx]=$___idx
- ___pair_order+=( $___idx )
- }
- else
- ___pos_to_level[$___idx]=-1
- fi
- fi
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent
+
+ local -A ___pos_to_level ___level_to_pos ___pair_map ___final_pairs ___Strings ___Counts
+ local ___input=$1 ___workbuf=$1 ___key=$2 ___varname=$3 ___style ___quoting
+ integer ___nest=${4:-1} ___idx=0 ___pair_idx ___level=0 ___start ___end ___sidx=1 ___had_quoted_value=0
+ local -a match mbegin mend ___pair_order
+ (( ${(P)+___varname} )) || typeset -gA "$___varname"
+ ___pair_map=( "{" "}" "[" "]" )
+
+ while [[ $___workbuf = (#b)[^"{}[]\\\"'":,]#((["{[]}\"'":,])|[\\](*))(*) ]]; do
+ if [[ -n ${match[3]} ]] {
+ ___idx+=${mbegin[1]}
+
+ [[ $___quoting = \' ]] && \
+ { ___workbuf=${match[3]}; } || \
+ { ___workbuf=${match[3]:1}; (( ++ ___idx )); }
+ } else {
+ ___idx+=${mbegin[1]}
+ if [[ -z $___quoting ]] {
+ if [[ ${match[1]} = ["({["] ]]; then
+ ___Strings[$___level/${___Counts[$___level]}]+=" $'\0'--object--$'\0'"
+ ___pos_to_level[$___idx]=$(( ++ ___level ))
+ ___level_to_pos[$___level]=$___idx
+ (( ___Counts[$___level] += 1 ))
+ ___sidx=___idx+1
+ ___had_quoted_value=0
+ elif [[ ${match[1]} = ["]})"] ]]; then
+ (( !___had_quoted_value )) && \
+ ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]//((#s)[[:blank:]]##|([[:blank:]]##(#e)))}"
+ ___had_quoted_value=1
+ if (( ___level > 0 )); then
+ ___pair_idx=${___level_to_pos[$___level]}
+ ___pos_to_level[$___idx]=$(( ___level -- ))
+ if [[ ${___pair_map[${___input[___pair_idx]}]} = ${___input[___idx]} ]] {
+ ___final_pairs[$___idx]=$___pair_idx
+ ___final_pairs[$___pair_idx]=$___idx
+ ___pair_order+=( $___idx )
}
+ else
+ ___pos_to_level[$___idx]=-1
+ fi
+ fi
+ }
- [[ ${match[1]} = \" && $___quoting != \' ]] && \
- if [[ $___quoting = '"' ]]; then
- ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]}"
- ___quoting=""
- else
- ___had_quoted_value=1
- ___sidx=___idx+1
- ___quoting='"'
- fi
-
- [[ ${match[1]} = , && -z $___quoting ]] && \
- {
- (( !___had_quoted_value )) && \
- ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]//((#s)[[:blank:]]##|([[:blank:]]##(#e)))}"
- ___sidx=___idx+1
- ___had_quoted_value=0
- }
-
- [[ ${match[1]} = : && -z $___quoting ]] && \
- {
- ___had_quoted_value=0
- ___sidx=___idx+1
- }
+ [[ ${match[1]} = \" && $___quoting != \' ]] && \
+ if [[ $___quoting = '"' ]]; then
+ ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]}"
+ ___quoting=""
+ else
+ ___had_quoted_value=1
+ ___sidx=___idx+1
+ ___quoting='"'
+ fi
- [[ ${match[1]} = \' && $___quoting != \" ]] && \
- if [[ $___quoting = "'" ]]; then
- ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]}"
- ___quoting=""
- else
- ___had_quoted_value=1
- ___sidx=___idx+1
- ___quoting="'"
- fi
-
- ___workbuf=${match[4]}
+ [[ ${match[1]} = , && -z $___quoting ]] && \
+ {
+ (( !___had_quoted_value )) && \
+ ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]//((#s)[[:blank:]]##|([[:blank:]]##(#e)))}"
+ ___sidx=___idx+1
+ ___had_quoted_value=0
}
- done
-
- local ___text ___found
- if (( ___nest != 2 )) {
- integer ___pair_a ___pair_b
- for ___pair_a ( "${___pair_order[@]}" ) {
- ___pair_b="${___final_pairs[$___pair_a]}"
- ___text="${___input[___pair_b,___pair_a]}"
- if [[ $___text = [[:space:]]#\{[[:space:]]#[\"\']${___key}[\"\']* ]]; then
- ___found="$___text"
- fi
+
+ [[ ${match[1]} = : && -z $___quoting ]] && \
+ {
+ ___had_quoted_value=0
+ ___sidx=___idx+1
}
- }
- if [[ -n $___found && $___nest -lt 2 ]] {
- .zi-parse-json "$___found" "$___key" "$___varname" 2
- }
+ [[ ${match[1]} = \' && $___quoting != \" ]] && \
+ if [[ $___quoting = "'" ]]; then
+ ___Strings[$___level/${___Counts[$___level]}]+=" ${(q)___input[___sidx,___idx-1]}"
+ ___quoting=""
+ else
+ ___had_quoted_value=1
+ ___sidx=___idx+1
+ ___quoting="'"
+ fi
- if (( ___nest == 2 )) {
- : ${(PAA)___varname::="${(kv)___Strings[@]}"}
+ ___workbuf=${match[4]}
+ }
+ done
+
+ local ___text ___found
+ if (( ___nest != 2 )) {
+ integer ___pair_a ___pair_b
+ for ___pair_a ( "${___pair_order[@]}" ) {
+ ___pair_b="${___final_pairs[$___pair_a]}"
+ ___text="${___input[___pair_b,___pair_a]}"
+ if [[ $___text = [[:space:]]#\{[[:space:]]#[\"\']${___key}[\"\']* ]]; then
+ ___found="$___text"
+ fi
}
+ }
+
+ if [[ -n $___found && $___nest -lt 2 ]] {
+ .zi-parse-json "$___found" "$___key" "$___varname" 2
+ }
+
+ if (( ___nest == 2 )) {
+ : ${(PAA)___varname::="${(kv)___Strings[@]}"}
+ }
}
# ]]]
# FUNCTION: .zi-get-package [[[
.zi-get-package() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
- local user=$1 pkg=$2 plugin=$2 id_as=$3 dir=$4 profile=$5 \
- local_path=${ZI[PLUGINS_DIR]}/${3//\//---} pkgjson \
- tmpfile=${$(mktemp):-${TMPDIR:-/tmp}/zsh.xYzAbc123} \
- URL=https://raw.githubusercontent.com/z-shell/$2/HEAD/package.json
+ local user=$1 pkg=$2 plugin=$2 id_as=$3 dir=$4 profile=$5 \
+ local_path=${ZI[PLUGINS_DIR]}/${3//\//---} pkgjson \
+ tmpfile=${$(mktemp):-${TMPDIR:-/tmp}/zsh.xYzAbc123} \
+ URL=https://raw.githubusercontent.com/z-shell/$2/HEAD/package.json
- local pro_sep="{rst}, {profile}" epro_sep="{error}, {profile}" \
- tool_sep="{rst}, {cmd}" \
- lhi_hl="{lhi}" profile_hl="{profile}"
+ local pro_sep="{rst}, {profile}" epro_sep="{error}, {profile}" \
+ tool_sep="{rst}, {cmd}" \
+ lhi_hl="{lhi}" profile_hl="{profile}"
- trap "rmdir ${(qqq)local_path} 2>/dev/null; return 1" INT TERM QUIT HUP
- trap "rmdir ${(qqq)local_path} 2>/dev/null" EXIT
+ trap "rmdir ${(qqq)local_path} 2>/dev/null; return 1" INT TERM QUIT HUP
+ trap "rmdir ${(qqq)local_path} 2>/dev/null" EXIT
- if [[ $profile != ./* ]] {
- if { ! .zi-download-file-stdout $URL 0 1 2>/dev/null > $tmpfile } {
- rm -f $tmpfile; .zi-download-file-stdout $URL 1 1 2>/dev/null >1 $tmpfile
- }
- } else {
- tmpfile=${profile%:*}
- profile=${${${(M)profile:#*:*}:+${profile#*:}}:-default}
+ if [[ $profile != ./* ]] {
+ if { ! .zi-download-file-stdout $URL 0 1 2>/dev/null > $tmpfile } {
+ rm -f $tmpfile; .zi-download-file-stdout $URL 1 1 2>/dev/null >1 $tmpfile
}
-
- pkgjson="$(<$tmpfile)"
-
- if [[ -z $pkgjson ]]; then
- +zi-message "{u-warn}Error{b-warn}:{error} the package {apo}\`{pid}$id_as{apo}\`"\
- "{error}couldn't be found.{rst}"
- return 1
- fi
-
- local -A Strings
- .zi-parse-json "$pkgjson" "plugin-info" Strings
-
- local -A jsondata1
- jsondata1=( ${(@Q)${(@z)Strings[2/1]}} )
- local user=${jsondata1[user]} plugin=${jsondata1[plugin]} \
- url=${jsondata1[url]} message=${jsondata1[message]} \
- required=${jsondata1[required]:-${jsondata1[requires]}}
-
- local -a profiles
- local key value
- integer pos
- profiles=( ${(@Q)${(@z)Strings[2/2]}} )
- profiles=( ${profiles[@]:#$'\0'--object--$'\0'} )
- pos=${${(@Q)${(@z)Strings[2/2]}}[(I)$profile]}
- if (( pos )) {
- for key value ( "${(@Q)${(@z)Strings[3/$(( (pos + 1) / 2 ))]}}" ) {
- (( ${+ICE[$key]} )) && [[ ${ICE[$key]} != +* ]] && continue
- ICE[$key]=$value${ICE[$key]#+}
- }
- ICE=( "${(kv)ICE[@]//\\\"/\"}" )
- [[ ${ICE[as]} = program ]] && ICE[as]="command"
- [[ -n ${ICE[on-update-of]} ]] && ICE[subscribe]="${ICE[subscribe]:-${ICE[on-update-of]}}"
- [[ -n ${ICE[pick]} ]] && ICE[pick]="${ICE[pick]//\$ZPFX/${ZPFX%/}}"
- if [[ -n ${ICE[id-as]} ]] {
- @zi-substitute 'ICE[id-as]'
- local -A map
- map=( "\"" "\\\"" "\\" "\\" )
- eval "ICE[id-as]=\"${ICE[id-as]//(#m)[\"\\]/${map[$MATCH]}}\""
- }
- } else {
- # Assumption: the default profile is the first in the table (see another color).
- +zi-message "{u-warn}Error{b-warn}:{error} the profile {apo}\`{hi}$profile{apo}\`" \
- "{error}couldn't be found, aborting. Available profiles are:" \
- "{lhi}${(pj:$epro_sep:)profiles[@]}{error}.{rst}"
- return 1
+ } else {
+ tmpfile=${profile%:*}
+ profile=${${${(M)profile:#*:*}:+${profile#*:}}:-default}
+ }
+
+ pkgjson="$(<$tmpfile)"
+
+ if [[ -z $pkgjson ]]; then
+ +zi-message "{u-warn}Error{b-warn}:{error} the package {apo}\`{pid}$id_as{apo}\`"\
+ "{error}couldn't be found.{rst}"
+ return 1
+ fi
+
+ local -A Strings
+ .zi-parse-json "$pkgjson" "plugin-info" Strings
+
+ local -A jsondata1
+ jsondata1=( ${(@Q)${(@z)Strings[2/1]}} )
+ local user=${jsondata1[user]} plugin=${jsondata1[plugin]} \
+ url=${jsondata1[url]} message=${jsondata1[message]} \
+ required=${jsondata1[required]:-${jsondata1[requires]}}
+
+ local -a profiles
+ local key value
+ integer pos
+ profiles=( ${(@Q)${(@z)Strings[2/2]}} )
+ profiles=( ${profiles[@]:#$'\0'--object--$'\0'} )
+ pos=${${(@Q)${(@z)Strings[2/2]}}[(I)$profile]}
+ if (( pos )) {
+ for key value ( "${(@Q)${(@z)Strings[3/$(( (pos + 1) / 2 ))]}}" ) {
+ (( ${+ICE[$key]} )) && [[ ${ICE[$key]} != +* ]] && continue
+ ICE[$key]=$value${ICE[$key]#+}
}
-
- +zi-message "{info3}Package{ehi}:{rst} {pid}$pkg{rst}. Selected" \
- "profile{ehi}:{rst} {hi}$profile{rst}. Available" \
- "profiles:${${${(M)profile:#default}:+$lhi_hl}:-$profile_hl}" \
- "${(pj:$pro_sep:)profiles[@]}{rst}."
- if [[ $profile != *bgn* && -n ${(M)profiles[@]:#*bgn*} ]] {
- +zi-message "{note}Note:{rst} The {apo}\`{profile}bgn{glob}*{apo}\`{rst}" \
- "profiles (if any are available) are the recommended ones (the reason" \
- "is that they expose the binaries provided by the package without" \
- "altering (i.e.: {slight}cluttering{rst}{…}) the {var}\$PATH{rst}" \
- "environment variable)."
+ ICE=( "${(kv)ICE[@]//\\\"/\"}" )
+ [[ ${ICE[as]} = program ]] && ICE[as]="command"
+ [[ -n ${ICE[on-update-of]} ]] && ICE[subscribe]="${ICE[subscribe]:-${ICE[on-update-of]}}"
+ [[ -n ${ICE[pick]} ]] && ICE[pick]="${ICE[pick]//\$ZPFX/${ZPFX%/}}"
+ if [[ -n ${ICE[id-as]} ]] {
+ @zi-substitute 'ICE[id-as]'
+ local -A map
+ map=( "\"" "\\\"" "\\" "\\" )
+ eval "ICE[id-as]=\"${ICE[id-as]//(#m)[\"\\]/${map[$MATCH]}}\""
}
-
- ICE[required]=${ICE[required]:-$ICE[requires]}
- local -a req
- req=( ${(s.;.)${:-${required:+$required\;}${ICE[required]}}} )
- for required ( $req ) {
- if [[ $required == (bgn|dl|monitor) ]]; then
- if [[ ( $required == bgn && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-bin-gem-node *]} ) || \
- ( $required == dl && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-patch-dl *]} ) || \
- ( $required == monitor && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-readurl *]} )
- ]]; then
- local -A namemap
- namemap=( bgn Bin-Gem-Node dl Patch-Dl monitor readurl )
- +zi-message -n "{u-warn}ERROR{b-warn}: {error}the "
- if [[ -z ${(MS)ICE[required]##(\;|(#s))$required(\;|(#e))} ]]; then
- +zi-message -n "{error}requested profile {apo}\`{hi}$profile{apo}\`{error} "
- else
- +zi-message -n "{error}package {pid}$pkg{error} "
- fi
- +zi-message '{error}requires the {apo}`{annex}'${namemap[$required]}'{apo}`' \
- "{error}annex, which is currently not installed." \
- "{nl}{nl}If you'd like to install it, you can visit its homepage:" \
- "{nl}– {url}https://github.com/z-shell/z-a-${(L)namemap[$required]}{rst}" \
- "{nl}for instructions."
- (( ${#profiles[@]:#$profile} > 0 )) && \
- +zi-message "{nl}Other available profiles are:" \
+ } else {
+ # Assumption: the default profile is the first in the table (see another color).
+ +zi-message "{u-warn}Error{b-warn}:{error} the profile {apo}\`{hi}$profile{apo}\`" \
+ "{error}couldn't be found, aborting. Available profiles are:" \
+ "{lhi}${(pj:$epro_sep:)profiles[@]}{error}.{rst}"
+ return 1
+ }
+
+ +zi-message "{info3}Package{ehi}:{rst} {pid}$pkg{rst}. Selected" \
+ "profile{ehi}:{rst} {hi}$profile{rst}. Available" \
+ "profiles:${${${(M)profile:#default}:+$lhi_hl}:-$profile_hl}" \
+ "${(pj:$pro_sep:)profiles[@]}{rst}."
+ if [[ $profile != *bgn* && -n ${(M)profiles[@]:#*bgn*} ]] {
+ +zi-message "{note}Note:{rst} The {apo}\`{profile}bgn{glob}*{apo}\`{rst}" \
+ "profiles (if any are available) are the recommended ones (the reason" \
+ "is that they expose the binaries provided by the package without" \
+ "altering (i.e.: {slight}cluttering{rst}{…}) the {var}\$PATH{rst}" \
+ "environment variable)."
+ }
+
+ ICE[required]=${ICE[required]:-$ICE[requires]}
+ local -a req
+ req=( ${(s.;.)${:-${required:+$required\;}${ICE[required]}}} )
+ for required ( $req ) {
+ if [[ $required == (bgn|dl|monitor) ]]; then
+ if [[ ( $required == bgn && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-bin-gem-node *]} ) || \
+ ( $required == dl && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-patch-dl *]} ) || \
+ ( $required == monitor && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-readurl *]} )
+ ]]; then
+ local -A namemap
+ namemap=( bgn Bin-Gem-Node dl Patch-Dl monitor readurl )
+ +zi-message -n "{u-warn}ERROR{b-warn}: {error}the "
+ if [[ -z ${(MS)ICE[required]##(\;|(#s))$required(\;|(#e))} ]]; then
+ +zi-message -n "{error}requested profile {apo}\`{hi}$profile{apo}\`{error} "
+ else
+ +zi-message -n "{error}package {pid}$pkg{error} "
+ fi
+ +zi-message '{error}requires the {apo}`{annex}'${namemap[$required]}'{apo}`' \
+ "{error}annex, which is currently not installed." \
+ "{nl}{nl}If you'd like to install it, you can visit its homepage:" \
+ "{nl}– {url}https://github.com/z-shell/z-a-${(L)namemap[$required]}{rst}" \
+ "{nl}for instructions."
+ (( ${#profiles[@]:#$profile} > 0 )) && \
+ +zi-message "{nl}Other available profiles are:" \
"{profile}${(pj:$pro_sep:)${profiles[@]:#$profile}}{rst}."
- return 1
- fi
+ return 1
+ fi
+ else
+ if ! command -v $required &>/dev/null; then
+ +zi-message -n "{u-warn}ERROR{b-warn}: {error}the "
+ if [[ -n ${(MS)ICE[required]##(\;|(#s))$required(\;|(#e))} ]]; then
+ +zi-message -n "{error}requested profile {apo}\`{hi}$profile{apo}\`{error} "
else
- if ! command -v $required &>/dev/null; then
- +zi-message -n "{u-warn}ERROR{b-warn}: {error}the "
- if [[ -n ${(MS)ICE[required]##(\;|(#s))$required(\;|(#e))} ]]; then
- +zi-message -n "{error}requested profile {apo}\`{hi}$profile{apo}\`{error} "
- else
- +zi-message -n "{error}package {pid}$pkg{error} "
- fi
- +zi-message '{error}requires a {apo}`{cmd}'$required'{apo}`{error}' \
- "command to be available in {var}\$PATH{error}.{rst}" \
- "{nl}{error}The package cannot be installed unless the" \
- "command will be available."
- (( ${#profiles[@]:#$profile} > 0 )) && \
- +zi-message "{nl}Other available profiles are:" \
- "{profile}${(pj:$pro_sep:)${profiles[@]:#$profile}}{rst}."
- return 1
- fi
+ +zi-message -n "{error}package {pid}$pkg{error} "
fi
- }
-
- if [[ -n ${ICE[dl]} && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-patch-dl *]} ]] {
- +zi-message "{nl}{u-warn}WARNING{b-warn}:{rst} the profile uses" \
- "{ice}dl''{rst} ice however there's currently no {annex}z-a-patch-dl{rst}" \
- "annex loaded, which provides it."
- +zi-message "The ice will be inactive, i.e.: no additional" \
- "files will become downloaded (the ice downloads the given URLs)." \
- "The package should still work, as it doesn't indicate to" \
- "{u}{slight}require{rst} the annex."
- +zi-message "{nl}You can download the" \
- "annex from its homepage at {url}https://github.com/z-shell/z-a-patch-dl{rst}."
- }
-
- [[ -n ${jsondata1[message]} ]] && \
- +zi-message "{info}${jsondata1[message]}{rst}"
-
- if (( ${+ICE[is-snippet]} )) {
- reply=( "" "$url" )
- REPLY=snippet
- return 0
- }
-
- if (( !${+ICE[git]} && !${+ICE[from]} )) {
- (
- .zi-parse-json "$pkgjson" "_from" Strings
- local -A jsondata
- jsondata=( "${(@Q)${(@z)Strings[1/1]}}" )
+ +zi-message '{error}requires a {apo}`{cmd}'$required'{apo}`{error}' \
+ "command to be available in {var}\$PATH{error}.{rst}" \
+ "{nl}{error}The package cannot be installed unless the" \
+ "command will be available."
+ (( ${#profiles[@]:#$profile} > 0 )) && \
+ +zi-message "{nl}Other available profiles are:" \
+ "{profile}${(pj:$pro_sep:)${profiles[@]:#$profile}}{rst}."
+ return 1
+ fi
+ fi
+ }
+
+ if [[ -n ${ICE[dl]} && -z ${(k)ZI_EXTS[(r)<-> z-annex-data: z-a-patch-dl *]} ]] {
+ +zi-message "{nl}{u-warn}WARNING{b-warn}:{rst} the profile uses" \
+ "{ice}dl''{rst} ice however there's currently no {annex}z-a-patch-dl{rst}" \
+ "annex loaded, which provides it."
+ +zi-message "The ice will be inactive, i.e.: no additional" \
+ "files will become downloaded (the ice downloads the given URLs)." \
+ "The package should still work, as it doesn't indicate to" \
+ "{u}{slight}require{rst} the annex."
+ +zi-message "{nl}You can download the" \
+ "annex from its homepage at {url}https://github.com/z-shell/z-a-patch-dl{rst}."
+ }
+
+ [[ -n ${jsondata1[message]} ]] && \
+ +zi-message "{info}${jsondata1[message]}{rst}"
+
+ if (( ${+ICE[is-snippet]} )) {
+ reply=( "" "$url" )
+ REPLY=snippet
+ return 0
+ }
- local URL=${jsondata[_resolved]}
- local fname="${${URL%%\?*}:t}"
+ if (( !${+ICE[git]} && !${+ICE[from]} )) {
+ (
+ .zi-parse-json "$pkgjson" "_from" Strings
+ local -A jsondata
+ jsondata=( "${(@Q)${(@z)Strings[1/1]}}" )
- command mkdir -p $dir || {
- +zi-message "{u-warn}Error{b-warn}:{error} Couldn't create directory:" \
- "{dir}$dir{error}, aborting.{rst}"
- return 1
- }
- builtin cd -q $dir || return 1
+ local URL=${jsondata[_resolved]}
+ local fname="${${URL%%\?*}:t}"
- +zi-message "Downloading tarball for {pid}$plugin{rst}{…}"
+ command mkdir -p $dir || {
+ +zi-message "{u-warn}Error{b-warn}:{error} Couldn't create directory:" \
+ "{dir}$dir{error}, aborting.{rst}"
+ return 1
+ }
+ builtin cd -q $dir || return 1
- if { ! .zi-download-file-stdout "$URL" 0 1 >! "$fname" } {
- if { ! .zi-download-file-stdout "$URL" 1 1 >! "$fname" } {
- command rm -f "$fname"
- +zi-message "Download of the file {apo}\`{file}$fname{apo}\`{rst}" \
- "failed. No available download tool? One of:" \
- "{cmd}${(pj:$tool_sep:)${=:-curl wget lftp lynx}}{rst}."
+ +zi-message "Downloading tarball for {pid}$plugin{rst}{…}"
- return 1
- }
- }
+ if { ! .zi-download-file-stdout "$URL" 0 1 >! "$fname" } {
+ if { ! .zi-download-file-stdout "$URL" 1 1 >! "$fname" } {
+ command rm -f "$fname"
+ +zi-message "Download of the file {apo}\`{file}$fname{apo}\`{rst}" \
+ "failed. No available download tool? One of:" \
+ "{cmd}${(pj:$tool_sep:)${=:-curl wget lftp lynx}}{rst}."
- ziextract "$fname" --move
- return 0
- ) && {
- reply=( "$user" "$plugin" )
- REPLY=tarball
+ return 1
}
- } else {
- reply=( "${ICE[user]:-$user}" "${ICE[plugin]:-$plugin}" )
- if [[ ${ICE[from]} = (|gh-r|github-rel) ]]; then
- REPLY=github
- else
- REPLY=unknown
- fi
- }
+ }
- return $?
+ ziextract "$fname" --move
+ return 0
+ ) && {
+ reply=( "$user" "$plugin" )
+ REPLY=tarball
+ }
+ } else {
+ reply=( "${ICE[user]:-$user}" "${ICE[plugin]:-$plugin}" )
+ if [[ ${ICE[from]} = (|gh-r|github-rel) ]]; then
+ REPLY=github
+ else
+ REPLY=unknown
+ fi
+ }
+
+ return $?
} # ]]]
# FUNCTION: .zi-setup-plugin-dir [[[
# Clones given plugin into PLUGIN_DIR. Supports multiple
@@ -325,213 +317,224 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
# $1 - user
# $2 - plugin
.zi-setup-plugin-dir() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal noshortloops rcquotes
-
- local user=$1 plugin=$2 id_as=$3 remote_url_path=${1:+$1/}$2 \
- local_path tpe=$4 update=$5 version=$6
-
- if .zi-get-object-path plugin "$id_as" && [[ -z $update ]] {
- +zi-message "{u-warn}ERROR{b-warn}:{error} A plugin named {pid}$id_as{error}" \
- "already exists, aborting."
- return 1
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal noshortloops rcquotes
+
+ local user=$1 plugin=$2 id_as=$3 remote_url_path=${1:+$1/}$2 \
+ local_path tpe=$4 update=$5 version=$6
+
+ if .zi-get-object-path plugin "$id_as" && [[ -z $update ]] {
+ +zi-message "{u-warn}ERROR{b-warn}:{error} A plugin named {pid}$id_as{error}" \
+ "already exists, aborting."
+ return 1
+ }
+ local_path=$REPLY
+
+ trap "rmdir ${(qqq)local_path}/._zi ${(qqq)local_path} 2>/dev/null" EXIT
+ trap "rmdir ${(qqq)local_path}/._zi ${(qqq)local_path} 2>/dev/null; return 1" INT TERM QUIT HUP
+
+ local -A sites
+ sites=(
+ github github.com
+ gh github.com
+ bitbucket bitbucket.org
+ bb bitbucket.org
+ gitlab gitlab.com
+ gl gitlab.com
+ notabug notabug.org
+ nb notabug.org
+ github-rel github.com/$remote_url_path/releases
+ gh-r github.com/$remote_url_path/releases
+ cygwin cygwin
+ )
+
+ ZI[annex-multi-flag:pull-active]=${${${(M)update:#-u}:+${ZI[annex-multi-flag:pull-active]}}:-2}
+
+ local -a arr
+
+ if [[ $user = _local ]]; then
+ builtin print "Warning: no local plugin \`$plugin\'."
+ builtin print "(should be located at: $local_path)"
+ return 1
+ fi
+
+ command rm -f ${TMPDIR:-/tmp}/zi-execs.$$.lst ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst \
+ ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst ${TMPDIR:-/tmp}/zi.compiled.$$.lst
+
+ if [[ $tpe != tarball ]] {
+ if [[ -z $update ]] {
+ .zi-any-colorify-as-uspl2 "$user" "$plugin"
+ local pid_hl='{pid}' id_msg_part=" (at label{ehi}:{rst} {id-as}$id_as{rst}{…})"
+ (( $+ICE[pack] )) && local infix_m="({b}{ice}pack{apo}''{rst}) "
+ +zi-message "{nl}Downloading $infix_m{pid}$user${user:+/}$plugin{…}${${${id_as:#$user/$plugin}}:+$id_msg_part}"
}
- local_path=$REPLY
-
- trap "rmdir ${(qqq)local_path}/._zi ${(qqq)local_path} 2>/dev/null" EXIT
- trap "rmdir ${(qqq)local_path}/._zi ${(qqq)local_path} 2>/dev/null; return 1" INT TERM QUIT HUP
-
- local -A sites
- sites=(
- github github.com
- gh github.com
- bitbucket bitbucket.org
- bb bitbucket.org
- gitlab gitlab.com
- gl gitlab.com
- notabug notabug.org
- nb notabug.org
- github-rel github.com/$remote_url_path/releases
- gh-r github.com/$remote_url_path/releases
- cygwin cygwin
- )
- ZI[annex-multi-flag:pull-active]=${${${(M)update:#-u}:+${ZI[annex-multi-flag:pull-active]}}:-2}
+ local site
+ [[ -n ${ICE[from]} ]] && site=${sites[${ICE[from]}]}
+ if [[ -z $site && ${ICE[from]} = *(gh-r|github-rel)* ]] {
+ site=${ICE[from]/(gh-r|github-re)/${sites[gh-r]}}
+ }
+ }
- local -a arr
+ (
+ if [[ $site = */releases ]] {
+ local url=$site/${ICE[ver]}
- if [[ $user = _local ]]; then
- builtin print "Warning: no local plugin \`$plugin\'."
- builtin print "(should be located at: $local_path)"
- return 1
- fi
+ .zi-get-latest-gh-r-url-part "$user" "$plugin" "$url" || return $?
- command rm -f ${TMPDIR:-/tmp}/zi-execs.$$.lst ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst \
- ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst ${TMPDIR:-/tmp}/zi.compiled.$$.lst
+ command mkdir -p "$local_path"
+ [[ -d "$local_path" ]] || return 1
- if [[ $tpe != tarball ]] {
- if [[ -z $update ]] {
- .zi-any-colorify-as-uspl2 "$user" "$plugin"
- local pid_hl='{pid}' id_msg_part=" (at label{ehi}:{rst} {id-as}$id_as{rst}{…})"
- (( $+ICE[pack] )) && local infix_m="({b}{ice}pack{apo}''{rst}) "
- +zi-message "{nl}Downloading $infix_m{pid}$user${user:+/}$plugin{…}${${${id_as:#$user/$plugin}}:+$id_msg_part}"
- }
+ (
+ () { setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1
+ integer count
- local site
- [[ -n ${ICE[from]} ]] && site=${sites[${ICE[from]}]}
- if [[ -z $site && ${ICE[from]} = *(gh-r|github-rel)* ]] {
- site=${ICE[from]/(gh-r|github-re)/${sites[gh-r]}}
+ for REPLY ( $reply ) {
+ count+=1
+ url="https://github.com${REPLY}"
+ if [[ -d $local_path/._zi ]] {
+ { local old_version="$(<$local_path/._zi/is_release${count:#1})"; } 2>/dev/null
+ old_version=${old_version/(#b)(\/[^\/]##)(#c4,4)\/([^\/]##)*/${match[2]}}
+ }
+ +zi-message "(Requesting \`${REPLY:t}'${version:+, version $version}{…}${old_version:+ Current version: $old_version.})"
+ if { ! .zi-download-file-stdout "$url" 0 1 >! "${REPLY:t}" } {
+ if { ! .zi-download-file-stdout "$url" 1 1 >! "${REPLY:t}" } {
+ command rm -f "${REPLY:t}"
+ +zi-message "Download of release for \`$remote_url_path' " \
+ "failed.{nl}Tried url: $url."
+ return 1
+ }
+ }
+ if .zi-download-file-stdout "$url.sig" 2>/dev/null >! "${REPLY:t}.sig"; then
+ :
+ else
+ command rm -f "${REPLY:t}.sig"
+ fi
+
+ command mkdir -p ._zi
+ [[ -d ._zi ]] || return 2
+ builtin print -r -- $url >! ._zi/url || return 3
+ builtin print -r -- ${REPLY} >! ._zi/is_release${count:#1} || return 4
+ ziextract ${REPLY:t} ${${${#reply}:#1}:+--nobkp}
}
+ return $?
+ ) || {
+ return 1
+ }
+ } elif [[ $site = cygwin ]] {
+ command mkdir -p "$local_path/._zi"
+ [[ -d "$local_path" ]] || return 1
+
+ (
+ () { setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1
+ .zi-get-cygwin-package "$remote_url_path" || return 1
+ builtin print -r -- $REPLY >! ._zi/is_release
+ ziextract "$REPLY"
+ ) || return $?
+ } elif [[ $tpe = github ]] {
+ case ${ICE[proto]} in
+ (|https|git|http|ftp|ftps|rsync|ssh)
+ :zi-git-clone() {
+ command git clone --progress ${(s: :)ICE[cloneopts]---recursive} \
+ ${(s: :)ICE[depth]:+--depth ${ICE[depth]}} \
+ "${ICE[proto]:-https}://${site:-${ICE[from]:-github.com}}/$remote_url_path" \
+ "$local_path" \
+ --config transfer.fsckobjects=false \
+ --config receive.fsckobjects=false \
+ --config fetch.fsckobjects=false \
+ --config pull.rebase=false
+ integer retval=$?
+ unfunction :zi-git-clone
+ return $retval
+ }
+ :zi-git-clone |& { command ${ZI[BIN_DIR]}/lib/zsh/git-process-output.zsh || cat; }
+ if (( pipestatus[1] == 141 )) {
+ :zi-git-clone
+ integer retval=$?
+ if (( retval )) {
+ builtin print -Pr -- "$ZI[col-error]Clone failed (code: $ZI[col-obj]$retval$ZI[col-error]).%f%b"
+ return 1
+ }
+ } elif (( pipestatus[1] )) {
+ builtin print -Pr -- "$ZI[col-error]Clone failed (code: $ZI[col-obj]$pipestatus[1]$ZI[col-error]).%f%b"
+ return 1
+ }
+ ;;
+ (*)
+ builtin print -Pr "${ZI[col-error]}Unknown protocol:%f%b ${ICE[proto]}."
+ return 1
+ esac
+
+ if [[ -n ${ICE[ver]} ]] {
+ command git -C "$local_path" checkout "${ICE[ver]}"
+ }
}
- (
- if [[ $site = */releases ]] {
- local url=$site/${ICE[ver]}
-
- .zi-get-latest-gh-r-url-part "$user" "$plugin" "$url" || return $?
-
- command mkdir -p "$local_path"
- [[ -d "$local_path" ]] || return 1
-
- (
- () { setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1
- integer count
-
- for REPLY ( $reply ) {
- count+=1
- url="https://github.com${REPLY}"
- if [[ -d $local_path/._zi ]] {
- { local old_version="$(<$local_path/._zi/is_release${count:#1})"; } 2>/dev/null
- old_version=${old_version/(#b)(\/[^\/]##)(#c4,4)\/([^\/]##)*/${match[2]}}
- }
- +zi-message "(Requesting \`${REPLY:t}'${version:+, version $version}{…}${old_version:+ Current version: $old_version.})"
- if { ! .zi-download-file-stdout "$url" 0 1 >! "${REPLY:t}" } {
- if { ! .zi-download-file-stdout "$url" 1 1 >! "${REPLY:t}" } {
- command rm -f "${REPLY:t}"
- +zi-message "Download of release for \`$remote_url_path' " \
- "failed.{nl}Tried url: $url."
- return 1
- }
- }
- if .zi-download-file-stdout "$url.sig" 2>/dev/null >! "${REPLY:t}.sig"; then
- :
- else
- command rm -f "${REPLY:t}.sig"
- fi
-
- command mkdir -p ._zi
- [[ -d ._zi ]] || return 2
- builtin print -r -- $url >! ._zi/url || return 3
- builtin print -r -- ${REPLY} >! ._zi/is_release${count:#1} || return 4
- ziextract ${REPLY:t} ${${${#reply}:#1}:+--nobkp}
- }
- return $?
- ) || {
- return 1
- }
- } elif [[ $site = cygwin ]] {
- command mkdir -p "$local_path/._zi"
- [[ -d "$local_path" ]] || return 1
-
- (
- () { setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1
- .zi-get-cygwin-package "$remote_url_path" || return 1
- builtin print -r -- $REPLY >! ._zi/is_release
- ziextract "$REPLY"
- ) || return $?
- } elif [[ $tpe = github ]] {
- case ${ICE[proto]} in
- (|https|git|http|ftp|ftps|rsync|ssh)
- :zi-git-clone() {
- command git clone --progress ${(s: :)ICE[cloneopts]---recursive} \
- ${(s: :)ICE[depth]:+--depth ${ICE[depth]}} \
- "${ICE[proto]:-https}://${site:-${ICE[from]:-github.com}}/$remote_url_path" \
- "$local_path" \
- --config transfer.fsckobjects=false \
- --config receive.fsckobjects=false \
- --config fetch.fsckobjects=false \
- --config pull.rebase=false
- integer retval=$?
- unfunction :zi-git-clone
- return $retval
- }
- :zi-git-clone |& { command ${ZI[BIN_DIR]}/lib/zsh/git-process-output.zsh || cat; }
- if (( pipestatus[1] == 141 )) {
- :zi-git-clone
- integer retval=$?
- if (( retval )) {
- builtin print -Pr -- "$ZI[col-error]Clone failed (code: $ZI[col-obj]$retval$ZI[col-error]).%f%b"
- return 1
- }
- } elif (( pipestatus[1] )) {
- builtin print -Pr -- "$ZI[col-error]Clone failed (code: $ZI[col-obj]$pipestatus[1]$ZI[col-error]).%f%b"
- return 1
- }
- ;;
- (*)
- builtin print -Pr "${ZI[col-error]}Unknown protocol:%f%b ${ICE[proto]}."
- return 1
- esac
-
- if [[ -n ${ICE[ver]} ]] {
- command git -C "$local_path" checkout "${ICE[ver]}"
- }
+ if [[ $update != -u ]] {
+ hook_rc=0
+ # Store ices at clone of a plugin
+ .zi-store-ices "$local_path/._zi" ICE "" "" "" ""
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:\\\!atclone-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_path" "${${key##(zi|z-annex) hook:}%% <->}" load
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
}
-
- if [[ $update != -u ]] {
- # Store ices at clone of a plugin
- .zi-store-ices "$local_path/._zi" ICE "" "" "" ""
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:\\\!atclone-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_path" "${${key##(zi|z-annex) hook:}%% <->}" load
- done
- # Run annexes' atclone hooks (the after atclone-ice ones)
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:atclone-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:atclone-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:atclone-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_path" "${${key##(zi|z-annex) hook:}%% <->}"
- done
+ done
+ # Run annexes' atclone hooks (the after atclone-ice ones)
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:atclone-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:atclone-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:atclone-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" plugin "$user" "$plugin" "$id_as" "$local_path" "${${key##(zi|z-annex) hook:}%% <->}"
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
}
-
- ((1))
- ) || return $?
-
- typeset -ga INSTALLED_EXECS
- { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-/tmp}/zi-execs.$$.lst)}" ) } 2>/dev/null
-
- # After additional executions like atclone'' - install completions (1 - plugins)
- local -A OPTS
- OPTS[opt_-q,--quiet]=1
- [[ 0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0 ]] && \
- .zi-install-completions "$id_as" "" "0"
-
- if [[ -e ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst || -e ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst ]] {
- typeset -ga INSTALLED_COMPS SKIPPED_COMPS
- { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.installed_comps.$$.lst)}" ) } 2>/dev/null
- { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst)}" ) } 2>/dev/null
+ done
}
- if [[ -e ${TMPDIR:-/tmp}/zi.compiled.$$.lst ]] {
- typeset -ga ADD_COMPILED
- { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-/tmp}/zi.compiled.$$.lst)}" ) } 2>/dev/null
- }
+ return "$retval"
+ ) || return $?
- # After any download – rehash the command table
- # This will however miss the as"program" binaries
- # as their PATH gets extended - and it is done
- # later. It will however work for sbin'' ice.
- (( !OPTS[opt_-p,--parallel] )) && rehash
+ typeset -ga INSTALLED_EXECS
+ { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-/tmp}/zi-execs.$$.lst)}" ) } 2>/dev/null
- return 0
+ # After additional executions like atclone'' - install completions (1 - plugins)
+ local -A OPTS
+ OPTS[opt_-q,--quiet]=1
+ [[ 0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0 ]] && \
+ .zi-install-completions "$id_as" "" "0"
+
+ if [[ -e ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst || -e ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst ]] {
+ typeset -ga INSTALLED_COMPS SKIPPED_COMPS
+ { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.installed_comps.$$.lst)}" ) } 2>/dev/null
+ { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst)}" ) } 2>/dev/null
+ }
+
+ if [[ -e ${TMPDIR:-/tmp}/zi.compiled.$$.lst ]] {
+ typeset -ga ADD_COMPILED
+ { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-/tmp}/zi.compiled.$$.lst)}" ) } 2>/dev/null
+ }
+
+ # After any download – rehash the command table
+ # This will however miss the as"program" binaries
+ # as their PATH gets extended - and it is done
+ # later. It will however work for sbin'' ice.
+ (( !OPTS[opt_-p,--parallel] )) && rehash
+
+ return 0
} # ]]]
# FUNCTION: .zi-install-completions [[[
# Installs all completions of given plugin. After that they are
@@ -543,253 +546,248 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
# $2 - plugin (only when $1 - i.e. user - given)
# $3 - if 1, then reinstall, otherwise only install completions that aren't there
.zi-install-completions() {
- builtin emulate -LR zsh
- setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
-
- local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}}
- local reinstall=${3:-0} quiet=${${4:+1}:-0}
- (( OPTS[opt_-q,--quiet] )) && quiet=1
- [[ $4 = -Q ]] && quiet=2
- typeset -ga INSTALLED_COMPS SKIPPED_COMPS
- INSTALLED_COMPS=() SKIPPED_COMPS=()
-
- .zi-any-to-user-plugin "$id_as" ""
- local user=${reply[-2]}
- local plugin=${reply[-1]}
- .zi-any-colorify-as-uspl2 "$user" "$plugin"
- local abbrev_pspec=$REPLY
-
- .zi-exists-physically-message "$id_as" "" || return 1
-
- # Symlink any completion files included in plugin's directory
- typeset -a completions already_symlinked backup_comps
- local c cfile bkpfile
- # The plugin == . is a semi-hack/trick to handle `creinstall .' properly
- [[ $user == % || ( -z $user && $plugin == . ) ]] && \
- completions=( "${plugin}"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) ) || \
- completions=( "${ZI[PLUGINS_DIR]}/${id_as//\//---}"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) )
- already_symlinked=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) )
- backup_comps=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) )
-
- # Symlink completions if they are not already there
- # either as completions (_fname) or as backups (fname)
- # OR - if it's a reinstall
- for c in "${completions[@]}"; do
- cfile="${c:t}"
- bkpfile="${cfile#_}"
- if [[ ( -z ${already_symlinked[(r)*/$cfile]} || $reinstall = 1 ) &&
- -z ${backup_comps[(r)*/$bkpfile]}
- ]]; then
- if [[ $reinstall = 1 ]]; then
- # Remove old files
- command rm -f "${ZI[COMPLETIONS_DIR]}/$cfile" "${ZI[COMPLETIONS_DIR]}/$bkpfile"
- fi
- INSTALLED_COMPS+=( $cfile )
- (( quiet )) || builtin print -Pr "Symlinking completion ${ZI[col-uname]}$cfile%f%b to completions directory."
- command ln -fs "$c" "${ZI[COMPLETIONS_DIR]}/$cfile"
- # Make compinit notice the change
- .zi-forget-completion "$cfile" "$quiet"
- else
- SKIPPED_COMPS+=( $cfile )
- (( quiet )) || builtin print -Pr "Not symlinking completion \`${ZI[col-obj]}$cfile%f%b', it already exists."
- (( quiet )) || builtin print -Pr "${ZI[col-info2]}Use \`${ZI[col-pname]}zi creinstall $abbrev_pspec${ZI[col-info2]}' to force install.%f%b"
- fi
- done
-
- if (( quiet == 1 && (${#INSTALLED_COMPS} || ${#SKIPPED_COMPS}) )) {
- +zi-message "{msg}Installed {num}${#INSTALLED_COMPS}" \
- "{msg}completions. They are stored in{var}" \
- "\$INSTALLED_COMPS{msg} array."
- if (( ${#SKIPPED_COMPS} )) {
- +zi-message "{msg}Skipped installing" \
- "{num}${#SKIPPED_COMPS}{msg} completions." \
- "They are stored in {var}\$SKIPPED_COMPS{msg} array."
- }
+ builtin emulate -LR zsh
+ setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
+
+ local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}}
+ local reinstall=${3:-0} quiet=${${4:+1}:-0}
+ (( OPTS[opt_-q,--quiet] )) && quiet=1
+ [[ $4 = -Q ]] && quiet=2
+ typeset -ga INSTALLED_COMPS SKIPPED_COMPS
+ INSTALLED_COMPS=() SKIPPED_COMPS=()
+
+ .zi-any-to-user-plugin "$id_as" ""
+ local user=${reply[-2]}
+ local plugin=${reply[-1]}
+ .zi-any-colorify-as-uspl2 "$user" "$plugin"
+ local abbrev_pspec=$REPLY
+
+ .zi-exists-physically-message "$id_as" "" || return 1
+
+ # Symlink any completion files included in plugin's directory
+ typeset -a completions already_symlinked backup_comps
+ local c cfile bkpfile
+ # The plugin == . is a semi-hack/trick to handle `creinstall .' properly
+ [[ $user == % || ( -z $user && $plugin == . ) ]] && \
+ completions=( "${plugin}"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) ) || \
+ completions=( "${ZI[PLUGINS_DIR]}/${id_as//\//---}"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN^/) )
+ already_symlinked=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) )
+ backup_comps=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) )
+
+ # Symlink completions if they are not already there
+ # either as completions (_fname) or as backups (fname)
+ # OR - if it's a reinstall
+ for c in "${completions[@]}"; do
+ cfile="${c:t}"
+ bkpfile="${cfile#_}"
+ if [[ ( -z ${already_symlinked[(r)*/$cfile]} || $reinstall = 1 ) &&
+ -z ${backup_comps[(r)*/$bkpfile]}
+ ]]; then
+ if [[ $reinstall = 1 ]]; then
+ # Remove old files
+ command rm -f "${ZI[COMPLETIONS_DIR]}/$cfile" "${ZI[COMPLETIONS_DIR]}/$bkpfile"
+ fi
+ INSTALLED_COMPS+=( $cfile )
+ (( quiet )) || builtin print -Pr "Symlinking completion ${ZI[col-uname]}$cfile%f%b to completions directory."
+ command ln -fs "$c" "${ZI[COMPLETIONS_DIR]}/$cfile"
+ # Make compinit notice the change
+ .zi-forget-completion "$cfile" "$quiet"
+ else
+ SKIPPED_COMPS+=( $cfile )
+ (( quiet )) || builtin print -Pr "Not symlinking completion \`${ZI[col-obj]}$cfile%f%b', it already exists."
+ (( quiet )) || builtin print -Pr "${ZI[col-info2]}Use \`${ZI[col-pname]}zi creinstall $abbrev_pspec${ZI[col-info2]}' to force install.%f%b"
+ fi
+ done
+
+ if (( quiet == 1 && (${#INSTALLED_COMPS} || ${#SKIPPED_COMPS}) )) {
+ +zi-message "{msg}Installed {num}${#INSTALLED_COMPS}" \
+ "{msg}completions. They are stored in{var}" \
+ "\$INSTALLED_COMPS{msg} array."
+ if (( ${#SKIPPED_COMPS} )) {
+ +zi-message "{msg}Skipped installing" \
+ "{num}${#SKIPPED_COMPS}{msg} completions." \
+ "They are stored in {var}\$SKIPPED_COMPS{msg} array."
}
+ }
- if (( ZSH_SUBSHELL )) {
- builtin print -rl -- $INSTALLED_COMPS >! ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst
- builtin print -rl -- $SKIPPED_COMPS >! ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst
- }
+ if (( ZSH_SUBSHELL )) {
+ builtin print -rl -- $INSTALLED_COMPS >! ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst
+ builtin print -rl -- $SKIPPED_COMPS >! ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst
+ }
- .zi-compinit 1 1 &>/dev/null
+ .zi-compinit 1 1 &>/dev/null
} # ]]]
# FUNCTION: .zi-compinit [[[
-# User-exposed `compinit' frontend which first ensures that all
-# completions managed by ZI are forgotten by Z-shell. After
-# that it runs normal `compinit', which should more easily detect
-# ZI's completions.
+# User-exposed `compinit' frontend which first ensures that all completions managed by ❮ ZI ❯ are forgotten by Z-shell.
+# After that it runs normal `compinit', which should more easily detect ❮ ZI ❯ completions.
#
# No arguments.
.zi-compinit() {
- [[ -n ${OPTS[opt_-p,--parallel]} && $1 != 1 ]] && return
+ [[ -n ${OPTS[opt_-p,--parallel]} && $1 != 1 ]] && return
- emulate -LR zsh
- builtin setopt nullglob extendedglob warncreateglobal typesetsilent
+ emulate -LR zsh
+ builtin setopt nullglob extendedglob warncreateglobal typesetsilent
- integer use_C=$2
+ integer use_C=$2
- typeset -a symlinked backup_comps
- local c cfile bkpfile action
+ typeset -a symlinked backup_comps
+ local c cfile bkpfile action
- symlinked=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc )
- backup_comps=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc )
+ symlinked=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc )
+ backup_comps=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc )
- # Delete completions if they are really there, either
- # as completions (_fname) or backups (fname)
- for c in "${symlinked[@]}" "${backup_comps[@]}"; do
- action=0
- cfile="${c:t}"
- cfile="_${cfile#_}"
- bkpfile="${cfile#_}"
+ # Delete completions if they are really there, either
+ # as completions (_fname) or backups (fname)
+ for c in "${symlinked[@]}" "${backup_comps[@]}"; do
+ action=0
+ cfile="${c:t}"
+ cfile="_${cfile#_}"
+ bkpfile="${cfile#_}"
- #print -Pr "${ZI[col-info]}Processing completion $cfile%f%b"
- .zi-forget-completion "$cfile"
- done
+ #print -Pr "${ZI[col-info]}Processing completion $cfile%f%b"
+ .zi-forget-completion "$cfile"
+ done
- +zi-message "Initializing completion ({func}compinit{rst}){…}"
- command rm -f ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump}
+ +zi-message "Initializing completion ({func}compinit{rst}){…}"
+ command rm -f ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump}
- # Workaround for a nasty trick in _vim
- (( ${+functions[_vim_files]} )) && unfunction _vim_files
+ # Workaround for a nasty trick in _vim
+ (( ${+functions[_vim_files]} )) && unfunction _vim_files
- builtin autoload -Uz compinit
- compinit ${${(M)use_C:#1}:+-C} -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
+ builtin autoload -Uz compinit
+ compinit ${${(M)use_C:#1}:+-C} -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
} # ]]]
# FUNCTION: .zi-download-file-stdout [[[
# Downloads file to stdout. Supports following backend commands:
# curl, wget, lftp, lynx. Used by snippet loading.
.zi-download-file-stdout() {
- local url="$1" restart="$2" progress="${(M)3:#1}"
+ local url="$1" restart="$2" progress="${(M)3:#1}"
- emulate -LR zsh
- setopt localtraps extendedglob
+ emulate -LR zsh
+ setopt localtraps extendedglob
- if (( restart )) {
- (( ${path[(I)/usr/local/bin]} )) || \
- {
- path+=( "/usr/local/bin" );
- trap "path[-1]=()" EXIT
- }
+ if (( restart )) {
+ (( ${path[(I)/usr/local/bin]} )) || \
+ {
+ path+=( "/usr/local/bin" );
+ trap "path[-1]=()" EXIT
+ }
- if (( ${+commands[curl]} )); then
- if [[ -n $progress ]]; then
- command curl --progress-bar -fSL "$url" 2> >($ZI[BIN_DIR]/lib/zsh/single-line.zsh >&2) || return 1
- else
- command curl -fsSL "$url" || return 1
- fi
- elif (( ${+commands[wget]} )); then
- command wget ${${progress:--q}:#1} "$url" -O - || return 1
- elif (( ${+commands[lftp]} )); then
- command lftp -c "cat $url" || return 1
- elif (( ${+commands[lynx]} )); then
- command lynx -source "$url" || return 1
- else
- +zi-message "{u-warn}ERROR{b-warn}:{rst}No download tool detected" \
- "(one of: {cmd}curl{rst}, {cmd}wget{rst}, {cmd}lftp{rst}," \
- "{cmd}lynx{rst})."
- return 2
- fi
- } else {
- if type curl 2>/dev/null 1>&2; then
- if [[ -n $progress ]]; then
- command curl --progress-bar -fSL "$url" 2> >($ZI[BIN_DIR]/lib/zsh/single-line.zsh >&2) || return 1
- else
- command curl -fsSL "$url" || return 1
- fi
- elif type wget 2>/dev/null 1>&2; then
- command wget ${${progress:--q}:#1} "$url" -O - || return 1
- elif type lftp 2>/dev/null 1>&2; then
- command lftp -c "cat $url" || return 1
- else
- .zi-download-file-stdout "$url" "1" "$progress"
- return $?
- fi
- }
+ if (( ${+commands[curl]} )); then
+ if [[ -n $progress ]]; then
+ command curl --progress-bar -fSL "$url" 2> >($ZI[BIN_DIR]/lib/zsh/single-line.zsh >&2) || return 1
+ else
+ command curl -fsSL "$url" || return 1
+ fi
+ elif (( ${+commands[wget]} )); then
+ command wget ${${progress:--q}:#1} "$url" -O - || return 1
+ elif (( ${+commands[lftp]} )); then
+ command lftp -c "cat $url" || return 1
+ elif (( ${+commands[lynx]} )); then
+ command lynx -source "$url" || return 1
+ else
+ +zi-message "{u-warn}ERROR{b-warn}:{rst}No download tool detected" \
+ "(one of: {cmd}curl{rst}, {cmd}wget{rst}, {cmd}lftp{rst}," \
+ "{cmd}lynx{rst})."
+ return 2
+ fi
+ } else {
+ if type curl 2>/dev/null 1>&2; then
+ if [[ -n $progress ]]; then
+ command curl --progress-bar -fSL "$url" 2> >($ZI[BIN_DIR]/lib/zsh/single-line.zsh >&2) || return 1
+ else
+ command curl -fsSL "$url" || return 1
+ fi
+ elif type wget 2>/dev/null 1>&2; then
+ command wget ${${progress:--q}:#1} "$url" -O - || return 1
+ elif type lftp 2>/dev/null 1>&2; then
+ command lftp -c "cat $url" || return 1
+ else
+ .zi-download-file-stdout "$url" "1" "$progress"
+ return $?
+ fi
+ }
- return 0
+ return 0
} # ]]]
# FUNCTION: .zi-get-url-mtime [[[
-# For the given URL returns the date in the Last-Modified
-# header as a time stamp
+# For the given URL returns the date in the Last-Modified header as a time stamp
.zi-get-url-mtime() {
- local url="$1" IFS line header
- local -a cmd
-
- setopt localoptions localtraps
-
- (( !${path[(I)/usr/local/bin]} )) && \
- {
- path+=( "/usr/local/bin" );
- trap "path[-1]=()" EXIT
- }
-
- if (( ${+commands[curl]} )) || type curl 2>/dev/null 1>&2; then
- cmd=(command curl -sIL "$url")
- elif (( ${+commands[wget]} )) || type wget 2>/dev/null 1>&2; then
- cmd=(command wget --server-response --spider -q "$url" -O -)
- else
- REPLY=$(( $(date +"%s") ))
- return 2
- fi
-
- "${cmd[@]}" |& command grep -i Last-Modified: | while read -r line; do
- header="${${line#*, }//$'\r'}"
- done
+ local url="$1" IFS line header
+ local -a cmd
- if [[ -z $header ]] {
- REPLY=$(( $(date +"%s") ))
- return 3
- }
+ setopt localoptions localtraps
- LANG=C TZ=UTC strftime -r -s REPLY "%d %b %Y %H:%M:%S GMT" "$header" &>/dev/null || {
- REPLY=$(( $(date +"%s") ))
- return 4
+ (( !${path[(I)/usr/local/bin]} )) && \
+ {
+ path+=( "/usr/local/bin" );
+ trap "path[-1]=()" EXIT
}
- return 0
+ if (( ${+commands[curl]} )) || type curl 2>/dev/null 1>&2; then
+ cmd=(command curl -sIL "$url")
+ elif (( ${+commands[wget]} )) || type wget 2>/dev/null 1>&2; then
+ cmd=(command wget --server-response --spider -q "$url" -O -)
+ else
+ REPLY=$(( $(date +"%s") ))
+ return 2
+ fi
+
+ "${cmd[@]}" |& command grep -i Last-Modified: | while read -r line; do
+ header="${${line#*, }//$'\r'}"
+ done
+
+ if [[ -z $header ]] {
+ REPLY=$(( $(date +"%s") ))
+ return 3
+ }
+
+ LANG=C TZ=UTC strftime -r -s REPLY "%d %b %Y %H:%M:%S GMT" "$header" &>/dev/null || {
+ REPLY=$(( $(date +"%s") ))
+ return 4
+ }
+
+ return 0
} # ]]]
# FUNCTION: .zi-mirror-using-svn [[[
-# Used to clone subdirectories from Github. If in update mode
-# (see $2), then invokes `svn update', in normal mode invokes
-# `svn checkout --non-interactive -q '. In test mode only
-# compares remote and local revision and outputs true if update
-# is needed.
+# Used to clone subdirectories from Github. If in update mode (see $2), then invokes `svn update',
+# in normal mode invokes `svn checkout --non-interactive -q '. In test mode only
+# compares remote and local revision and outputs true if update is needed.
#
# $1 - URL
# $2 - mode, "" - normal, "-u" - update, "-t" - test
# $3 - subdirectory (not path) with working copy, needed for -t and -u
.zi-mirror-using-svn() {
- setopt localoptions extendedglob warncreateglobal
- local url="$1" update="$2" directory="$3"
-
- (( ${+commands[svn]} )) || \
- builtin print -Pr -- "${ZI[col-error]}Warning:%f%b Subversion not found" \
- ", please install it to use \`${ZI[col-obj]}svn%f%b' ice."
-
- if [[ "$update" = "-t" ]]; then
- (
- () { setopt localoptions noautopushd; builtin cd -q "$directory"; }
- local -a out1 out2
- out1=( "${(f@)"$(LANG=C svn info -r HEAD)"}" )
- out2=( "${(f@)"$(LANG=C svn info)"}" )
-
- out1=( "${(M)out1[@]:#Revision:*}" )
- out2=( "${(M)out2[@]:#Revision:*}" )
- [[ "${out1[1]##[^0-9]##}" != "${out2[1]##[^0-9]##}" ]] && return 0
- return 1
- )
- return $?
- fi
- if [[ "$update" = "-u" && -d "$directory" && -d "$directory/.svn" ]]; then
- ( () { setopt localoptions noautopushd; builtin cd -q "$directory"; }
- command svn update
- return $? )
- else
- command svn checkout --non-interactive -q "$url" "$directory"
- fi
+ setopt localoptions extendedglob warncreateglobal
+ local url="$1" update="$2" directory="$3"
+
+ (( ${+commands[svn]} )) || \
+ builtin print -Pr -- "${ZI[col-error]}Warning:%f%b Subversion not found" \
+ ", please install it to use \`${ZI[col-obj]}svn%f%b' ice."
+
+ if [[ "$update" = "-t" ]]; then
+ (
+ () { setopt localoptions noautopushd; builtin cd -q "$directory"; }
+ local -a out1 out2
+ out1=( "${(f@)"$(LANG=C svn info -r HEAD)"}" )
+ out2=( "${(f@)"$(LANG=C svn info)"}" )
+
+ out1=( "${(M)out1[@]:#Revision:*}" )
+ out2=( "${(M)out2[@]:#Revision:*}" )
+ [[ "${out1[1]##[^0-9]##}" != "${out2[1]##[^0-9]##}" ]] && return 0
+ return 1
+ )
return $?
+ fi
+ if [[ "$update" = "-u" && -d "$directory" && -d "$directory/.svn" ]]; then
+ ( () { setopt localoptions noautopushd; builtin cd -q "$directory"; }
+ command svn update
+ return $? )
+ else
+ command svn checkout --non-interactive -q "$url" "$directory"
+ fi
+ return $?
}
# ]]]
# FUNCTION: .zi-forget-completion [[[
@@ -798,721 +796,744 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
#
# $1 - completion function name, e.g. "_cp"; can also be "cp"
.zi-forget-completion() {
- emulate -LR zsh
- setopt extendedglob typesetsilent warncreateglobal
+ emulate -LR zsh
+ setopt extendedglob typesetsilent warncreateglobal
- local f="$1" quiet="$2"
+ local f="$1" quiet="$2"
- typeset -a commands
- commands=( ${(k)_comps[(Re)$f]} )
+ typeset -a commands
+ commands=( ${(k)_comps[(Re)$f]} )
- [[ "${#commands}" -gt 0 ]] && (( quiet == 0 )) && builtin print -Prn "Forgetting commands completed by \`${ZI[col-obj]}$f%f%b': "
+ [[ "${#commands}" -gt 0 ]] && (( quiet == 0 )) && builtin print -Prn "Forgetting commands completed by \`${ZI[col-obj]}$f%f%b': "
- local k
- integer first=1
- for k ( $commands ) {
- unset "_comps[$k]"
- (( quiet )) || builtin print -Prn "${${first:#1}:+, }${ZI[col-info]}$k%f%b"
- first=0
- }
- (( quiet || first )) || builtin print
+ local k
+ integer first=1
+ for k ( $commands ) {
+ unset "_comps[$k]"
+ (( quiet )) || builtin print -Prn "${${first:#1}:+, }${ZI[col-info]}$k%f%b"
+ first=0
+ }
+ (( quiet || first )) || builtin print
- unfunction -- 2>/dev/null "$f"
+ unfunction -- 2>/dev/null "$f"
} # ]]]
# FUNCTION: .zi-compile-plugin [[[
-# Compiles given plugin (its main source file, and also an
-# additional "....zsh" file if it exists).
+# Compiles given plugin (its main source file, and also an additional "....zsh" file if it exists).
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-compile-plugin() {
- builtin emulate -LR zsh
- builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
-
- local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}} first plugin_dir filename is_snippet
- local -a list
-
- local -A ICE
- .zi-compute-ice "$id_as" "pack" \
- ICE plugin_dir filename is_snippet || return 1
-
- if [[ ${ICE[pick]} != /dev/null && ${ICE[as]} != null && \
- ${+ICE[null]} -eq 0 && ${ICE[as]} != command && ${+ICE[binary]} -eq 0 && \
- ( ${+ICE[nocompile]} = 0 || ${ICE[nocompile]} = \! )
- ]] {
- reply=()
- if [[ -n ${ICE[pick]} ]]; then
- list=( ${~${(M)ICE[pick]:#/*}:-$plugin_dir/$ICE[pick]}(DN) )
- if [[ ${#list} -eq 0 ]] {
- builtin print "No files for compilation found (pick-ice didn't match)."
- return 1
- }
- reply=( "${list[1]:h}" "${list[1]}" )
- else
- if (( is_snippet )) {
- if [[ -f $plugin_dir/$filename ]] {
- reply=( "$plugin_dir" $plugin_dir/$filename )
- } elif { ! .zi-first % "$plugin_dir" } {
- +zi-message "No files for compilation found."
- return 1
- }
- } else {
- .zi-first "$1" "$2" || {
- +zi-message "No files for compilation found."
- return 1
- }
- }
- fi
- local pdir_path=${reply[-2]}
- first=${reply[-1]}
- local fname=${first#$pdir_path/}
-
- +zi-message -n "{note}Note:{rst} Compiling{ehi}:{rst} {b}{file}$fname{rst}{…}"
- if [[ -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} ]] {
- () {
- builtin emulate -LR zsh -o extendedglob
- if { ! zcompile -U "$first" } {
- +zi-message "{msg2}Warning:{rst} Compilation failed. Don't worry, the plugin will work also without compilation."
- +zi-message "{msg2}Warning:{rst} Consider submitting an error report to ZI or to the plugin's author."
- } else {
- +zi-message " {ok}OK{rst}."
- }
- # Try to catch possible additional file
- zcompile -U "${${first%.plugin.zsh}%.zsh-theme}.zsh" 2>/dev/null
- }
+ builtin emulate -LR zsh
+ builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
+
+ local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}} first plugin_dir filename is_snippet
+ local -a list
+ local -A ICE
+ .zi-compute-ice "$id_as" "pack" \
+ ICE plugin_dir filename is_snippet || return 1
+
+ if [[ ${ICE[pick]} != /dev/null && ${ICE[as]} != null && \
+ ${+ICE[null]} -eq 0 && ${ICE[as]} != command && ${+ICE[binary]} -eq 0 && \
+ ( ${+ICE[nocompile]} = 0 || ${ICE[nocompile]} = \! )
+ ]] {
+ reply=()
+ if [[ -n ${ICE[pick]} ]]; then
+ list=( ${~${(M)ICE[pick]:#/*}:-$plugin_dir/$ICE[pick]}(DN) )
+ if [[ ${#list} -eq 0 ]] {
+ builtin print "No files for compilation found (pick-ice didn't match)."
+ return 1
+ }
+ reply=( "${list[1]:h}" "${list[1]}" )
+ else
+ if (( is_snippet )) {
+ if [[ -f $plugin_dir/$filename ]] {
+ reply=( "$plugin_dir" $plugin_dir/$filename )
+ } elif { ! .zi-first % "$plugin_dir" } {
+ +zi-message "No files for compilation found."
+ return 1
}
- }
-
- if [[ -n "${ICE[compile]}" ]]; then
- local -a pats
- pats=( ${(s.;.)ICE[compile]} )
- local pat
- list=()
- for pat ( $pats ) {
- eval "list+=( \$plugin_dir/$~pat(N) )"
+ } else {
+ .zi-first "$1" "$2" || {
+ +zi-message "No files for compilation found."
+ return 1
}
- if [[ ${#list} -eq 0 ]] {
- +zi-message "{u-warn}Warning{b-warn}:{rst} ice {ice}compile{apo}''{rst} didn't match any files."
+ }
+ fi
+ local pdir_path=${reply[-2]}
+ first=${reply[-1]}
+ local fname=${first#$pdir_path/}
+
+ +zi-message -n "{note}Note:{rst} Compiling{ehi}:{rst} {b}{file}$fname{rst}{…}"
+ if [[ -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} ]] {
+ () {
+ builtin emulate -LR zsh -o extendedglob
+ if { ! zcompile -U "$first" } {
+ +zi-message "{msg2}Warning:{rst} Compilation failed. Don't worry, the plugin will work also without compilation."
+ +zi-message "{msg2}Warning:{rst} Consider submitting an error report to ❮ ZI ❯ or to the plugin's author."
} else {
- integer retval
- for first in $list; do
- () {
- builtin emulate -LR zsh -o extendedglob
- zcompile -U "$first"; retval+=$?
- }
- done
- builtin print -rl -- ${list[@]#$plugin_dir/} >! ${TMPDIR:-/tmp}/zi.compiled.$$.lst
- if (( retval )) {
- +zi-message "{note}Note:{rst} The additional {num}${#list}{rst} compiled files" \
- "are listed in the {var}\$ADD_COMPILED{rst} array (operation exit" \
- "code: {ehi}$retval{rst})."
- } else {
- +zi-message "{note}Note:{rst} The additional {num}${#list}{rst} compiled files" \
- "are listed in the {var}\$ADD_COMPILED{rst} array."
- }
+ +zi-message " {ok}OK{rst}."
}
- fi
+ # Try to catch possible additional file
+ zcompile -U "${${first%.plugin.zsh}%.zsh-theme}.zsh" 2>/dev/null
+ }
+ }
+ }
+
+ if [[ -n "${ICE[compile]}" ]]; then
+ local -a pats
+ pats=( ${(s.;.)ICE[compile]} )
+ local pat
+ list=()
+ for pat ( $pats ) {
+ eval "list+=( \$plugin_dir/$~pat(N) )"
+ }
+ if [[ ${#list} -eq 0 ]] {
+ +zi-message "{u-warn}Warning{b-warn}:{rst} ice {ice}compile{apo}''{rst} didn't match any files."
+ } else {
+ integer retval
+ for first in $list; do
+ () {
+ builtin emulate -LR zsh -o extendedglob
+ zcompile -U "$first"; retval+=$?
+ }
+ done
+ builtin print -rl -- ${list[@]#$plugin_dir/} >! ${TMPDIR:-/tmp}/zi.compiled.$$.lst
+ if (( retval )) {
+ +zi-message "{note}Note:{rst} The additional {num}${#list}{rst} compiled files" \
+ "are listed in the {var}\$ADD_COMPILED{rst} array (operation exit" \
+ "code: {ehi}$retval{rst})."
+ } else {
+ +zi-message "{note}Note:{rst} The additional {num}${#list}{rst} compiled files" \
+ "are listed in the {var}\$ADD_COMPILED{rst} array."
+ }
+ }
+ fi
- return 0
+ return 0
} # ]]]
# FUNCTION: .zi-download-snippet [[[
-# Downloads snippet – either a file – with curl, wget, lftp or lynx,
-# or a directory, with Subversion – when svn-ICE is active. Github
-# supports Subversion protocol and allows to clone subdirectories.
-# This is used to provide a layer of support for Oh-My-Zsh and Prezto.
+# Downloads snippet – either a file – with curl, wget, lftp or lynx, or a directory,
+# with Subversion – when svn-ICE is active. Github supports Subversion protocol and allows
+# to clone subdirectories. This is used to provide a layer of support for Oh-My-Zsh and Prezto.
.zi-download-snippet() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent
+
+ local save_url=$1 url=$2 id_as=$3 local_dir=$4 dirname=$5 filename=$6 update=$7
+
+ trap "command rmdir ${(qqq)local_dir}/${(qqq)dirname} 2>/dev/null; return 1;" INT TERM QUIT HUP
+
+ local -a list arr
+ integer retval=0 hook_rc=0
+ local teleid_clean=${ICE[teleid]%%\?*}
+ [[ $teleid_clean == *://* ]] && \
+ local sname=${(M)teleid_clean##*://[^/]##(/[^/]##)(#c0,4)} || \
+ local sname=${${teleid_clean:h}:t}/${teleid_clean:t}
+ [[ $sname = */trunk* ]] && sname=${${ICE[teleid]%%/trunk*}:t}/${ICE[teleid]:t}
+ sname=${sname#./}
+
+ if (( ${+ICE[svn]} )) {
+ [[ $url = *(${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}}|robbyrussell*oh-my-zsh|ohmyzsh/ohmyzsh)* ]] && local ZSH=${ZI[SNIPPETS_DIR]}
+ url=${url/(#s)(#m)(${(~kj.|.)ZI_1MAP})/$ZI_1MAP[$MATCH]}
+ } else {
+ url=${url/(#s)(#m)(${(~kj.|.)ZI_2MAP})/$ZI_2MAP[$MATCH]}
+ if [[ $save_url == (${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}})* ]] {
+ if [[ $url != *.zsh(|-theme) && $url != */_[^/]## ]] {
+ if [[ $save_url == OMZT::* ]] {
+ url+=.zsh-theme
+ } else {
+ url+=/${${url#*::}:t}.plugin.zsh
+ }
+ }
+ } elif [[ $save_url = (${(~kj.|.)${(kM)ZI_1MAP:#PZT*}})* ]] {
+ if [[ $url != *.zsh && $url != */_[^/]## ]] {
+ url+=/init.zsh
+ }
+ }
+ }
+
+ # Change the url to point to raw github content if it isn't like that
+ if [[ "$url" = *github.com* && ! "$url" = */raw/* && "${+ICE[svn]}" = "0" ]] {
+ url="${${url/\/blob\///raw/}/\/tree\///raw/}"
+ }
+
+ command rm -f ${TMPDIR:-/tmp}/zi-execs.$$.lst ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst \
+ ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst ${TMPDIR:-/tmp}/zi.compiled.$$.lst
+
+ if [[ ! -d $local_dir/$dirname ]]; then
+ local id_msg_part="{…} (at label{ehi}:{rst} {id-as}$id_as{rst})"
+ [[ $update != -u ]] && +zi-message "{nl}{info}Setting up snippet:" \
+ "{url}$sname{rst}${ICE[id-as]:+$id_msg_part}"
+ command mkdir -p "$local_dir"
+ fi
+
+ if [[ $update = -u && ${OPTS[opt_-q,--quiet]} != 1 ]]; then
+ local id_msg_part="{…} (identified as{ehi}:{rst} {id-as}$id_as{rst})"
+ +zi-message "{nl}{info2}Updating snippet: {url}$sname{rst}${ICE[id-as]:+$id_msg_part}"
+ fi
+
+ # A flag for the annexes. 0 – no new commits, 1 - run-atpull mode,
+ # 2 – full update/there are new commits to download, 3 - full but
+ # a forced download (i.e.: the medium doesn't allow to peek update)
+ #
+ # The below inherits the flag if it's an update call (i.e.: -u given),
+ # otherwise it sets it to 2 – a new download is treated like a full
+ # update.
+ ZI[annex-multi-flag:pull-active]=${${${(M)update:#-u}:+${ZI[annex-multi-flag:pull-active]}}:-2}
+
+ (
+ if [[ $url = (http|https|ftp|ftps|scp)://* ]] {
+ # URL
+ (
+ () { setopt localoptions noautopushd; builtin cd -q "$local_dir"; } || return 4
+
+ (( !OPTS[opt_-q,--quiet] )) && +zi-message "Downloading {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" (with Subversion)"}:-" (with curl, wget, lftp)"}{…}"
+
+ if (( ${+ICE[svn]} )) {
+ if [[ $update = -u ]] {
+ # Test if update available
+ if ! .zi-mirror-using-svn "$url" "-t" "$dirname"; then
+ if (( ${+ICE[run-atpull]} || OPTS[opt_-u,--urge] )) {
+ ZI[annex-multi-flag:pull-active]=1
+ } else { return 0; }
+ # Will return when no updates so atpull'' code below doesn't need any checks.
+ # This return 0 statement also sets the pull-active flag outside this subshell.
+ else
+ ZI[annex-multi-flag:pull-active]=2
+ fi
+ # Run annexes' atpull hooks (the before atpull-ice ones). The SVN block.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
+ ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:svn
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
- local save_url=$1 url=$2 id_as=$3 local_dir=$4 dirname=$5 filename=$6 update=$7
+ if (( ZI[annex-multi-flag:pull-active] == 2 )) {
+ # Do the update
+ # The condition is reversed on purpose – to show only
+ # the messages on an actual update
+ if (( OPTS[opt_-q,--quiet] )); then
+ local id_msg_part="{…} (identified as{ehi}: {id-as}$id_as{rst})"
+ +zi-message "{nl}{info2}Updating snippet {url}${sname}{rst}${ICE[id-as]:+$id_msg_part}"
+ +zi-message "Downloading {apo}\`{rst}$sname{apo}\`{rst} (with Subversion){…}"
+ fi
+ .zi-mirror-using-svn "$url" "-u" "$dirname" || return 4
+ }
+ } else {
+ .zi-mirror-using-svn "$url" "" "$dirname" || return 4
+ }
- trap "command rmdir ${(qqq)local_dir}/${(qqq)dirname} 2>/dev/null; return 1;" INT TERM QUIT HUP
+ # Redundant code, just to compile SVN snippet
+ if [[ ${ICE[as]} != command ]]; then
+ if [[ -n ${ICE[pick]} ]]; then
+ list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
+ elif [[ -z ${ICE[pick]} ]]; then
+ list=(
+ $local_dir/$dirname/*.plugin.zsh(DN) $local_dir/$dirname/*.zsh-theme(DN) $local_dir/$dirname/init.zsh(DN)
+ $local_dir/$dirname/*.zsh(DN) $local_dir/$dirname/*.sh(DN) $local_dir/$dirname/.zshrc(DN)
+ )
+ fi
- local -a list arr
- integer retval
- local teleid_clean=${ICE[teleid]%%\?*}
- [[ $teleid_clean == *://* ]] && \
- local sname=${(M)teleid_clean##*://[^/]##(/[^/]##)(#c0,4)} || \
- local sname=${${teleid_clean:h}:t}/${teleid_clean:t}
- [[ $sname = */trunk* ]] && sname=${${ICE[teleid]%%/trunk*}:t}/${ICE[teleid]:t}
- sname=${sname#./}
-
- if (( ${+ICE[svn]} )) {
- [[ $url = *(${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}}|robbyrussell*oh-my-zsh|ohmyzsh/ohmyzsh)* ]] && local ZSH=${ZI[SNIPPETS_DIR]}
- url=${url/(#s)(#m)(${(~kj.|.)ZI_1MAP})/$ZI_1MAP[$MATCH]}
- } else {
- url=${url/(#s)(#m)(${(~kj.|.)ZI_2MAP})/$ZI_2MAP[$MATCH]}
- if [[ $save_url == (${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}})* ]] {
- if [[ $url != *.zsh(|-theme) && $url != */_[^/]## ]] {
- if [[ $save_url == OMZT::* ]] {
- url+=.zsh-theme
- } else {
- url+=/${${url#*::}:t}.plugin.zsh
- }
- }
- } elif [[ $save_url = (${(~kj.|.)${(kM)ZI_1MAP:#PZT*}})* ]] {
- if [[ $url != *.zsh && $url != */_[^/]## ]] {
- url+=/init.zsh
+ if [[ -e ${list[1]} && ${list[1]} != */dev/null && \
+ -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} && \
+ ${+ICE[nocompile]} -eq 0
+ ]] {
+ () {
+ builtin emulate -LR zsh -o extendedglob
+ zcompile -U "${list[1]}" &>/dev/null || \
+ +zi-message "{u-warn}Warning{b-warn}:{rst} couldn't compile {apo}\`{file}${list[1]}{apo}\`{rst}."
+ }
}
- }
- }
-
- # Change the url to point to raw github content if it isn't like that
- if [[ "$url" = *github.com* && ! "$url" = */raw/* && "${+ICE[svn]}" = "0" ]] {
- url="${${url/\/blob\///raw/}/\/tree\///raw/}"
- }
+ fi
- command rm -f ${TMPDIR:-/tmp}/zi-execs.$$.lst ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst \
- ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst ${TMPDIR:-/tmp}/zi.compiled.$$.lst
+ return $ZI[annex-multi-flag:pull-active]
+ } else {
+ command mkdir -p "$local_dir/$dirname"
- if [[ ! -d $local_dir/$dirname ]]; then
- local id_msg_part="{…} (at label{ehi}:{rst} {id-as}$id_as{rst})"
- [[ $update != -u ]] && +zi-message "{nl}{info}Setting up snippet:" \
- "{url}$sname{rst}${ICE[id-as]:+$id_msg_part}"
- command mkdir -p "$local_dir"
- fi
+ if (( !OPTS[opt_-f,--force] )) {
+ .zi-get-url-mtime "$url"
+ } else {
+ REPLY=$EPOCHSECONDS
+ }
- if [[ $update = -u && ${OPTS[opt_-q,--quiet]} != 1 ]]; then
- local id_msg_part="{…} (identified as{ehi}:{rst} {id-as}$id_as{rst})"
- +zi-message "{nl}{info2}Updating snippet: {url}$sname{rst}${ICE[id-as]:+$id_msg_part}"
- fi
+ # Returned is: modification time of the remote file.
+ # Thus, EPOCHSECONDS - REPLY is: allowed window for the
+ # local file to be modified in. ms-$secs is: files accessed
+ # within last $secs seconds. Thus, if there's no match, the
+ # local file is out of date.
+
+ local secs=$(( EPOCHSECONDS - REPLY ))
+ # Guard so that it's positive
+ (( $secs >= 0 )) || secs=0
+ integer skip_dl
+ local -a matched
+ matched=( $local_dir/$dirname/$filename(DNms-$secs) )
+ if (( ${#matched} )) {
+ +zi-message "{info}Already up to date.{rst}"
+ # Empty-update return-short path – it also decides the
+ # pull-active flag after the return from this sub-shell
+ (( ${+ICE[run-atpull]} || OPTS[opt_-u,--urge] )) && skip_dl=1 || return 0
+ }
- # A flag for the annexes. 0 – no new commits, 1 - run-atpull mode,
- # 2 – full update/there are new commits to download, 3 - full but
- # a forced download (i.e.: the medium doesn't allow to peek update)
- #
- # The below inherits the flag if it's an update call (i.e.: -u given),
- # otherwise it sets it to 2 – a new download is treated like a full
- # update.
- ZI[annex-multi-flag:pull-active]=${${${(M)update:#-u}:+${ZI[annex-multi-flag:pull-active]}}:-2}
+ if [[ ! -f $local_dir/$dirname/$filename ]] {
+ ZI[annex-multi-flag:pull-active]=2
+ } else {
+ # secs > 1 → the file is outdated, then:
+ # - if true, then the mode is 2 minus run-atpull-activation,
+ # - if false, then mode is 3 → a forced download (no remote mtime found).
+ ZI[annex-multi-flag:pull-active]=$(( secs > 1 ? (2 - skip_dl) : 3 ))
+ }
- (
- if [[ $url = (http|https|ftp|ftps|scp)://* ]] {
- # URL
- (
- () { setopt localoptions noautopushd; builtin cd -q "$local_dir"; } || return 4
-
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "Downloading {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" (with Subversion)"}:-" (with curl, wget, lftp)"}{…}"
-
- if (( ${+ICE[svn]} )) {
- if [[ $update = -u ]] {
- # Test if update available
- if ! .zi-mirror-using-svn "$url" "-t" "$dirname"; then
- if (( ${+ICE[run-atpull]} || OPTS[opt_-u,--urge] )) {
- ZI[annex-multi-flag:pull-active]=1
- } else { return 0; } # Will return when no updates so atpull''
- # code below doesn't need any checks.
- # This return 0 statement also sets the
- # pull-active flag outside this subshell.
- else
- ZI[annex-multi-flag:pull-active]=2
- fi
-
- # Run annexes' atpull hooks (the before atpull-ice ones).
- # The SVN block.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
- ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:svn
- done
-
- if (( ZI[annex-multi-flag:pull-active] == 2 )) {
- # Do the update
- # The condition is reversed on purpose – to show only
- # the messages on an actual update
- if (( OPTS[opt_-q,--quiet] )); then
- local id_msg_part="{…} (identified as{ehi}: {id-as}$id_as{rst})"
- +zi-message "{nl}{info2}Updating snippet {url}${sname}{rst}${ICE[id-as]:+$id_msg_part}"
- +zi-message "Downloading {apo}\`{rst}$sname{apo}\`{rst} (with Subversion){…}"
- fi
- .zi-mirror-using-svn "$url" "-u" "$dirname" || return 4
- }
- } else {
- .zi-mirror-using-svn "$url" "" "$dirname" || return 4
- }
-
- # Redundant code, just to compile SVN snippet
- if [[ ${ICE[as]} != command ]]; then
- if [[ -n ${ICE[pick]} ]]; then
- list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
- elif [[ -z ${ICE[pick]} ]]; then
- list=(
- $local_dir/$dirname/*.plugin.zsh(DN) $local_dir/$dirname/*.zsh-theme(DN) $local_dir/$dirname/init.zsh(DN)
- $local_dir/$dirname/*.zsh(DN) $local_dir/$dirname/*.sh(DN) $local_dir/$dirname/.zshrc(DN)
- )
- fi
-
- if [[ -e ${list[1]} && ${list[1]} != */dev/null && \
- -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} && \
- ${+ICE[nocompile]} -eq 0
- ]] {
- () {
- builtin emulate -LR zsh -o extendedglob
- zcompile -U "${list[1]}" &>/dev/null || \
- +zi-message "{u-warn}Warning{b-warn}:{rst} couldn't compile {apo}\`{file}${list[1]}{apo}\`{rst}."
- }
- }
- fi
-
- return $ZI[annex-multi-flag:pull-active]
- } else {
- command mkdir -p "$local_dir/$dirname"
-
- if (( !OPTS[opt_-f,--force] )) {
- .zi-get-url-mtime "$url"
- } else {
- REPLY=$EPOCHSECONDS
- }
-
- # Returned is: modification time of the remote file.
- # Thus, EPOCHSECONDS - REPLY is: allowed window for the
- # local file to be modified in. ms-$secs is: files accessed
- # within last $secs seconds. Thus, if there's no match, the
- # local file is out of date.
-
- local secs=$(( EPOCHSECONDS - REPLY ))
- # Guard so that it's positive
- (( $secs >= 0 )) || secs=0
- integer skip_dl
- local -a matched
- matched=( $local_dir/$dirname/$filename(DNms-$secs) )
- if (( ${#matched} )) {
- +zi-message "{info}Already up to date.{rst}"
- # Empty-update return-short path – it also decides the
- # pull-active flag after the return from this sub-shell
- (( ${+ICE[run-atpull]} || OPTS[opt_-u,--urge] )) && skip_dl=1 || return 0
- }
-
- if [[ ! -f $local_dir/$dirname/$filename ]] {
- ZI[annex-multi-flag:pull-active]=2
- } else {
- # secs > 1 → the file is outdated, then:
- # - if true, then the mode is 2 minus run-atpull-activation,
- # - if false, then mode is 3 → a forced download (no remote mtime found).
- ZI[annex-multi-flag:pull-active]=$(( secs > 1 ? (2 - skip_dl) : 3 ))
- }
-
- # Run annexes' atpull hooks (the before atpull-ice ones).
- # The URL-snippet block.
- if [[ $update = -u && $ZI[annex-multi-flag:pull-active] -ge 1 ]] {
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
- ${${ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:url
- done
- }
-
- if (( !skip_dl )) {
- if { ! .zi-download-file-stdout "$url" 0 1 >! "$dirname/$filename" } {
- if { ! .zi-download-file-stdout "$url" 1 1 >! "$dirname/$filename" } {
- command rm -f "$dirname/$filename"
- +zi-message "{u-warn}ERROR{b-warn}:{rst} Download failed."
- return 4
- }
- }
- }
- return $ZI[annex-multi-flag:pull-active]
- }
+ # Run annexes' atpull hooks (the before atpull-ice ones).
+ # The URL-snippet block.
+ if [[ $update = -u && $ZI[annex-multi-flag:pull-active] -ge 1 ]] {
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
+ ${${ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
)
- retval=$?
-
- # Overestimate the pull-level to 2 also in error situations
- # – no hooks will be run anyway because of the error
- ZI[annex-multi-flag:pull-active]=$retval
-
- if [[ $ICE[as] != command && ${+ICE[svn]} -eq 0 ]] {
- local file_path=$local_dir/$dirname/$filename
- if [[ -n ${ICE[pick]} ]]; then
- list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
- file_path=${list[1]}
- fi
- if [[ -e $file_path && -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} && \
- $file_path != */dev/null && ${+ICE[nocompile]} -eq 0
- ]] {
- () {
- builtin emulate -LR zsh -o extendedglob
- if ! zcompile -U "$file_path" 2>/dev/null; then
- builtin print -r "Couldn't compile \`${file_path:t}', it MIGHT be wrongly downloaded"
- builtin print -r "(snippet URL points to a directory instead of a file?"
- builtin print -r "to download directory, use preceding: zi ice svn)."
- retval=4
- fi
- }
- }
- }
- } else { # Local-file snippet branch
- # Local files are (yet…) forcefully copied.
- ZI[annex-multi-flag:pull-active]=3 retval=3
- # Run annexes' atpull hooks (the before atpull-ice ones).
- # The local-file snippets block.
- if [[ $update = -u ]] {
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
- ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
- ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:file
- done
- }
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:url
+ hook_rc="$?"
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
+ }
- command mkdir -p "$local_dir/$dirname"
- if [[ ! -e $url ]] {
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{ehi}ERROR:{error} The source file {file}$url{error} doesn't exist.{rst}"
- retval=4
- }
- if [[ -e $url && ! -f $url && $url != /dev/null ]] {
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{ehi}ERROR:{error} The source {file}$url{error} isn't a regular file.{rst}"
- retval=4
- }
- if [[ -e $url && ! -r $url && $url != /dev/null ]] {
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{ehi}ERROR:{error} The source {file}$url{error} isn't" \
- "accessible (wrong permissions).{rst}"
- retval=4
- }
- if (( !OPTS[opt_-q,--quiet] )) && [[ $url != /dev/null ]] {
- +zi-message "{msg}Copying {file}$filename{msg}{…}{rst}"
- command cp -vf "$url" "$local_dir/$dirname/$filename" || \
- { +zi-message "{ehi}ERROR:{error} The file copying has been unsuccessful.{rst}"; retval=4; }
- } else {
- command cp -f "$url" "$local_dir/$dirname/$filename" &>/dev/null || \
- { +zi-message "{ehi}ERROR:{error} The copying of {file}$filename{error} has been unsuccessful"\
-"${${(M)OPTS[opt_-q,--quiet]:#1}:+, skip the -q/--quiet option for more information}.{rst}"; retval=4; }
+ if (( !skip_dl )) {
+ if { ! .zi-download-file-stdout "$url" 0 1 >! "$dirname/$filename" } {
+ if { ! .zi-download-file-stdout "$url" 1 1 >! "$dirname/$filename" } {
+ command rm -f "$dirname/$filename"
+ +zi-message "{u-warn}ERROR{b-warn}:{rst} Download failed."
+ return 4
+ }
}
+ }
+ return $ZI[annex-multi-flag:pull-active]
}
+ )
+ retval=$?
- (( retval == 4 )) && { command rmdir "$local_dir/$dirname" 2>/dev/null; return $retval; }
+ # Overestimate the pull-level to 2 also in error situations
+ # – no hooks will be run anyway because of the error
+ ZI[annex-multi-flag:pull-active]=$retval
- if [[ ${${:-$local_dir/$dirname}%%/##} != ${ZI[SNIPPETS_DIR]} ]] {
- # Store ices at "clone" and update of snippet, SVN and single-file
- local pfx=$local_dir/$dirname/._zi
- .zi-store-ices "$pfx" ICE url_rsvd "" "$save_url" "${+ICE[svn]}"
- } elif [[ -n $id_as ]] {
- +zi-message "{u-warn}Warning{b-warn}:{rst} the snippet {url}$id_as{rst} isn't" \
- "fully downloaded – you should remove it with {apo}\`{cmd}zi delete $id_as{apo}\`{rst}."
+ if [[ $ICE[as] != command && ${+ICE[svn]} -eq 0 ]] {
+ local file_path=$local_dir/$dirname/$filename
+ if [[ -n ${ICE[pick]} ]]; then
+ list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
+ file_path=${list[1]}
+ fi
+ if [[ -e $file_path && -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} && \
+ $file_path != */dev/null && ${+ICE[nocompile]} -eq 0
+ ]] {
+ () {
+ builtin emulate -LR zsh -o extendedglob
+ if ! zcompile -U "$file_path" 2>/dev/null; then
+ builtin print -r "Couldn't compile \`${file_path:t}', it MIGHT be wrongly downloaded"
+ builtin print -r "(snippet URL points to a directory instead of a file?"
+ builtin print -r "to download directory, use preceding: zi ice svn)."
+ retval=4
+ fi
+ }
}
+ }
+ } else { # Local-file snippet branch
+ # Local files are (yet…) forcefully copied.
+ ZI[annex-multi-flag:pull-active]=3 retval=3
+ # Run annexes' atpull hooks (the before atpull-ice ones).
+ # The local-file snippets block.
+ if [[ $update = -u ]] {
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-pre <->]}
+ ${${(M)ICE[atpull]#\!}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
+ ${(on)ZI_EXTS2[(I)zi hook:e-\\\!atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:file
+ hook_rc="$?"
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
+ }
- # Empty update short-path
- if (( ZI[annex-multi-flag:pull-active] == 0 )) {
- # Run annexes' atpull hooks (the `always' after atpull-ice ones)
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:%atpull-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:%atpull-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:%atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:0
- done
+ command mkdir -p "$local_dir/$dirname"
+ if [[ ! -e $url ]] {
+ (( !OPTS[opt_-q,--quiet] )) && +zi-message "{ehi}ERROR:{error} The source file {file}$url{error} doesn't exist.{rst}"
+ retval=4
+ }
+ if [[ -e $url && ! -f $url && $url != /dev/null ]] {
+ (( !OPTS[opt_-q,--quiet] )) && +zi-message "{ehi}ERROR:{error} The source {file}$url{error} isn't a regular file.{rst}"
+ retval=4
+ }
+ if [[ -e $url && ! -r $url && $url != /dev/null ]] {
+ (( !OPTS[opt_-q,--quiet] )) && +zi-message "{ehi}ERROR:{error} The source {file}$url{error} isn't" \
+ "accessible (wrong permissions).{rst}"
+ retval=4
+ }
+ if (( !OPTS[opt_-q,--quiet] )) && [[ $url != /dev/null ]] {
+ +zi-message "{msg}Copying {file}$filename{msg}{…}{rst}"
+ command cp -vf "$url" "$local_dir/$dirname/$filename" || \
+ { +zi-message "{ehi}ERROR:{error} The file copying has been unsuccessful.{rst}"; retval=4; }
+ } else {
+ command cp -f "$url" "$local_dir/$dirname/$filename" &>/dev/null || \
+ { +zi-message "{ehi}ERROR:{error} The copying of {file}$filename{error} has been unsuccessful"\
+"${${(M)OPTS[opt_-q,--quiet]:#1}:+, skip the -q/--quiet option for more information}.{rst}"; retval=4; }
+ }
+ }
- return 0;
- }
+ (( retval == 4 )) && { command rmdir "$local_dir/$dirname" 2>/dev/null; return $retval; }
- if [[ $update = -u ]] {
- # Run annexes' atpull hooks (the before atpull-ice ones).
- # The block is common to all 3 snippet types.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-pre <->]}
- ${${ICE[atpull]:#\!*}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
- ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update
- done
- } else {
- # Run annexes' atclone hooks (the before atclone-ice ones)
- # The block is common to all 3 snippet types.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:\\\!atclone-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" load
- done
+ if [[ ${${:-$local_dir/$dirname}%%/##} != ${ZI[SNIPPETS_DIR]} ]] {
+ # Store ices at "clone" and update of snippet, SVN and single-file
+ local pfx=$local_dir/$dirname/._zi
+ .zi-store-ices "$pfx" ICE url_rsvd "" "$save_url" "${+ICE[svn]}"
+ } elif [[ -n $id_as ]] {
+ +zi-message "{u-warn}Warning{b-warn}:{rst} the snippet {url}$id_as{rst} isn't" \
+ "fully downloaded – you should remove it with {apo}\`{cmd}zi delete $id_as{apo}\`{rst}."
+ }
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:atclone-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:atclone-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:atclone-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" load
- done
+ # Empty update short-path
+ if (( ZI[annex-multi-flag:pull-active] == 0 )) {
+ # Run annexes' atpull hooks (the `always' after atpull-ice ones)
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:%atpull-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:%atpull-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:%atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:0
+ hook_rc="$?"
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
}
+ done
- # Run annexes' atpull hooks (the after atpull-ice ones)
- # The block is common to all 3 snippet types.
- if [[ $update = -u ]] {
- if (( ZI[annex-multi-flag:pull-active] > 0 )) {
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:atpull-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:atpull-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update
- done
- }
+ return $retval;
+ }
- # Run annexes' atpull hooks (the `always' after atpull-ice ones)
- # The block is common to all 3 snippet types.
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:%atpull-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:%atpull-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:%atpull-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:$ZI[annex-multi-flag:pull-active]
- done
+ if [[ $update = -u ]] {
+ # Run annexes' atpull hooks (the before atpull-ice ones).
+ # The block is common to all 3 snippet types.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-pre <->]}
+ ${${ICE[atpull]:#\!*}:+${(on)ZI_EXTS[(I)z-annex hook:\\\!atpull-<-> <->]}}
+ ${(on)ZI_EXTS2[(I)zi hook:no-e-\\\!atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
+ } else {
+ # Run annexes' atclone hooks (the before atclone-ice ones)
+ # The block is common to all 3 snippet types.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:\\\!atclone-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:\\\!atclone-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" load
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
}
- ((1))
- ) || return $?
-
- typeset -ga INSTALLED_EXECS
- { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-/tmp}/zi-execs.$$.lst)}" ) } 2>/dev/null
-
- # After additional executions like atclone'' - install completions (2 - snippets)
- local -A OPTS
- OPTS[opt_-q,--quiet]=1
- [[ 0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0 ]] && \
- .zi-install-completions "%" "$local_dir/$dirname" 0
-
- if [[ -e ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst || -e ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst ]] {
- typeset -ga INSTALLED_COMPS SKIPPED_COMPS
- { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.installed_comps.$$.lst)}" ) } 2>/dev/null
- { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst)}" ) } 2>/dev/null
+ done
+
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:atclone-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:atclone-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:atclone-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" load
+ done
}
- if [[ -e ${TMPDIR:-/tmp}/zi.compiled.$$.lst ]] {
- typeset -ga ADD_COMPILED
- { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-/tmp}/zi.compiled.$$.lst)}" ) } 2>/dev/null
+ # Run annexes' atpull hooks (the after atpull-ice ones)
+ # The block is common to all 3 snippet types.
+ if [[ $update = -u ]] {
+ if (( ZI[annex-multi-flag:pull-active] > 0 )) {
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:atpull-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:atpull-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update
+ done
+ }
+ # Run annexes' atpull hooks (the `always' after atpull-ice ones)
+ # The block is common to all 3 snippet types.
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:%atpull-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:%atpull-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:%atpull-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" update:$ZI[annex-multi-flag:pull-active]
+ hook_rc=$?
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ builtin print -Pr -- "${ZI[col-warn]}Warning:%f%b ${ZI[col-obj]}${arr[5]}${ZI[col-warn]} hook returned with ${ZI[col-obj]}${hook_rc}${ZI[col-rst]}"
+ }
+ done
}
-
- # After any download – rehash the command table
- # This will however miss the as"program" binaries
- # as their PATH gets extended - and it is done
- # later. It will however work for sbin'' ice.
- (( !OPTS[opt_-p,--parallel] )) && rehash
-
- return $retval
+ ) || return $?
+ typeset -ga INSTALLED_EXECS
+ { INSTALLED_EXECS=( "${(@f)$(<${TMPDIR:-/tmp}/zi-execs.$$.lst)}" ) } 2>/dev/null
+ # After additional executions like atclone'' - install completions (2 - snippets)
+ local -A OPTS
+ OPTS[opt_-q,--quiet]=1
+ [[ 0 = ${+ICE[nocompletions]} && ${ICE[as]} != null && ${+ICE[null]} -eq 0 ]] && \
+ .zi-install-completions "%" "$local_dir/$dirname" 0
+ if [[ -e ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst || -e ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst ]] {
+ typeset -ga INSTALLED_COMPS SKIPPED_COMPS
+ { INSTALLED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.installed_comps.$$.lst)}" ) } 2>/dev/null
+ { SKIPPED_COMPS=( "${(@f)$(<${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst)}" ) } 2>/dev/null
+ }
+ if [[ -e ${TMPDIR:-/tmp}/zi.compiled.$$.lst ]] {
+ typeset -ga ADD_COMPILED
+ { ADD_COMPILED=( "${(@f)$(<${TMPDIR:-/tmp}/zi.compiled.$$.lst)}" ) } 2>/dev/null
+ }
+
+ # After any download – rehash the command table
+ # This will however miss the as"program" binaries
+ # as their PATH gets extended - and it is done
+ # later. It will however work for sbin'' ice.
+ (( !OPTS[opt_-p,--parallel] )) && rehash
+
+ return $retval
}
# ]]]
# FUNCTION: .zi-update-snippet [[[
.zi-update-snippet() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
-
- local -a tmp opts
- local url=$1
- integer correct=0
- [[ -o ksharrays ]] && correct=1
- opts=( -u ) # for z-a-readurl
-
- # Create a local copy of OPTS, basically
- # for z-a-readurl annex
- local -A ice_opts
- ice_opts=( "${(kv)OPTS[@]}" )
- local -A OPTS
- OPTS=( "${(kv)ice_opts[@]}" )
-
- ZI[annex-multi-flag:pull-active]=0 ZI[-r/--reset-opt-hook-has-been-run]=0
-
- # Remove leading whitespace and trailing /
- url=${${url#${url%%[! $'\t']*}}%/}
- ICE[teleid]=${ICE[teleid]:-$url}
- [[ ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ]] && \
- ICE[pick]=${ICE[pick]:-/dev/null}
-
- local local_dir dirname filename save_url=$url \
- id_as=${ICE[id-as]:-$url}
-
- .zi-pack-ice "$id_as" ""
-
- # Allow things like $OSTYPE in the URL
- eval "url=\"$url\""
-
- # - case A: called from `update --all', ICE empty, static ice will win
- # - case B: called from `update', ICE packed, so it will win
- tmp=( "${(Q@)${(z@)ZI_SICE[$id_as]}}" )
- if (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) {
- ICE=( "${(kv)ICE[@]}" "${tmp[@]}" )
- } elif [[ -n ${ZI_SICE[$id_as]} ]] {
- +zi-message "{error}WARNING:{msg2} Inconsistency #3" \
- "occurred, please report the string: \`{obj}${ZI_SICE[$id_as]}{msg2}' to the" \
- "GitHub issues page: {obj}https://github.com/z-shell/zi/issues/{msg2}.{rst}"
- }
- id_as=${ICE[id-as]:-$id_as}
-
- # Oh-My-Zsh, Prezto and manual shorthands
- if (( ${+ICE[svn]} )) {
- [[ $url = *(${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}}|robbyrussell*oh-my-zsh|ohmyzsh/ohmyzsh)* ]] && local ZSH=${ZI[SNIPPETS_DIR]}
- url=${url/(#s)(#m)(${(~kj.|.)ZI_1MAP})/$ZI_1MAP[$MATCH]}
- } else {
- url=${url/(#s)(#m)(${(~kj.|.)ZI_2MAP})/$ZI_2MAP[$MATCH]}
- if [[ $save_url == (${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}})* ]] {
- if [[ $url != *.zsh(|-theme) && $url != */_[^/]## ]] {
- if [[ $save_url == OMZT::* ]] {
- url+=.zsh-theme
- } else {
- url+=/${${url#*::}:t}.plugin.zsh
- }
- }
- } elif [[ $save_url = (${(~kj.|.)${(kM)ZI_1MAP:#PZT*}})* ]] {
- if [[ $url != *.zsh ]] {
- url+=/init.zsh
- }
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
+
+ local -a tmp opts
+ local url=$1
+ integer correct=0
+ [[ -o ksharrays ]] && correct=1
+ opts=( -u ) # for z-a-readurl
+
+ # Create a local copy of OPTS, basically
+ # for z-a-readurl annex
+ local -A ice_opts
+ ice_opts=( "${(kv)OPTS[@]}" )
+ local -A OPTS
+ OPTS=( "${(kv)ice_opts[@]}" )
+
+ ZI[annex-multi-flag:pull-active]=0 ZI[-r/--reset-opt-hook-has-been-run]=0
+
+ # Remove leading whitespace and trailing /
+ url=${${url#${url%%[! $'\t']*}}%/}
+ ICE[teleid]=${ICE[teleid]:-$url}
+ [[ ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ]] && \
+ ICE[pick]=${ICE[pick]:-/dev/null}
+
+ local local_dir dirname filename save_url=$url \
+ id_as=${ICE[id-as]:-$url}
+
+ .zi-pack-ice "$id_as" ""
+
+ # Allow things like $OSTYPE in the URL
+ eval "url=\"$url\""
+
+ # - case A: called from `update --all', ICE empty, static ice will win
+ # - case B: called from `update', ICE packed, so it will win
+ tmp=( "${(Q@)${(z@)ZI_SICE[$id_as]}}" )
+ if (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) {
+ ICE=( "${(kv)ICE[@]}" "${tmp[@]}" )
+ } elif [[ -n ${ZI_SICE[$id_as]} ]] {
+ +zi-message "{error}WARNING:{msg2} Inconsistency #3" \
+ "occurred, please report the string: \`{obj}${ZI_SICE[$id_as]}{msg2}' to the" \
+ "GitHub issues page: {obj}https://github.com/z-shell/zi/issues/{msg2}.{rst}"
+ }
+ id_as=${ICE[id-as]:-$id_as}
+
+ # Oh-My-Zsh, Prezto and manual shorthands
+ if (( ${+ICE[svn]} )) {
+ [[ $url = *(${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}}|robbyrussell*oh-my-zsh|ohmyzsh/ohmyzsh)* ]] && local ZSH=${ZI[SNIPPETS_DIR]}
+ url=${url/(#s)(#m)(${(~kj.|.)ZI_1MAP})/$ZI_1MAP[$MATCH]}
+ } else {
+ url=${url/(#s)(#m)(${(~kj.|.)ZI_2MAP})/$ZI_2MAP[$MATCH]}
+ if [[ $save_url == (${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}})* ]] {
+ if [[ $url != *.zsh(|-theme) && $url != */_[^/]## ]] {
+ if [[ $save_url == OMZT::* ]] {
+ url+=.zsh-theme
+ } else {
+ url+=/${${url#*::}:t}.plugin.zsh
}
+ }
+ } elif [[ $save_url = (${(~kj.|.)${(kM)ZI_1MAP:#PZT*}})* ]] {
+ if [[ $url != *.zsh ]] {
+ url+=/init.zsh
+ }
}
-
- if { ! .zi-get-object-path snippet "$id_as" } {
- +zi-message "{msg2}Error: the snippet \`{obj}$id_as{msg2}'" \
- "doesn't exist, aborting the update.{rst}"
- return 1
- }
- filename=$reply[-2] dirname=$reply[-2] local_dir=$reply[-3]
-
- local -a arr
- local key
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
- )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" ${${key##(zi|z-annex) hook:}%% <->} update || \
- return $(( 10 - $? ))
- done
-
- # Download or copy the file
- [[ $url = *github.com* && $url != */raw/* ]] && url=${url/\/(blob|tree)\///raw/}
- .zi-download-snippet "$save_url" "$url" "$id_as" "$local_dir" "$dirname" "$filename" "-u"
-
- return $?
+ }
+
+ if { ! .zi-get-object-path snippet "$id_as" } {
+ +zi-message "{msg2}Error: the snippet \`{obj}$id_as{msg2}'" \
+ "doesn't exist, aborting the update.{rst}"
+ return 1
+ }
+ filename=$reply[-2] dirname=$reply[-2] local_dir=$reply[-3]
+
+ local -a arr
+ local key
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" ${${key##(zi|z-annex) hook:}%% <->} update || \
+ return $(( 10 - $? ))
+ done
+
+ # Download or copy the file
+ [[ $url = *github.com* && $url != */raw/* ]] && url=${url/\/(blob|tree)\///raw/}
+ .zi-download-snippet "$save_url" "$url" "$id_as" "$local_dir" "$dirname" "$filename" "-u"
+
+ return $?
}
# ]]]
# FUNCTION: .zi-get-latest-gh-r-url-part [[[
# Gets version string of latest release of given Github
# package. Connects to Github releases page.
.zi-get-latest-gh-r-url-part() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops
-
- REPLY=
- local user=$1 plugin=$2 urlpart=$3
-
- if [[ -z $urlpart ]] {
- local url=https://github.com/$user/$plugin/releases/$ICE[ver]
- } else {
- local url=https://$urlpart
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops
+
+ REPLY=
+ local user=$1 plugin=$2 urlpart=$3
+
+ if [[ -z $urlpart ]] {
+ local url=https://github.com/$user/$plugin/releases/$ICE[ver]
+ } else {
+ local url=https://$urlpart
+ }
+
+ local -A matchstr
+ matchstr=(
+ i386 "((386|686|linux32|x86*(#e))~*x86_64*)"
+ i686 "((386|686|linux32|x86*(#e))~*x86_64*)"
+ x86_64 "(x86_64|amd64|intel|linux64)"
+ amd64 "(x86_64|amd64|intel|linux64)"
+ aarch64 "aarch64"
+ aarch64-2 "arm"
+ linux "(linux|linux-gnu)"
+ darwin "(darwin|mac|macos|osx|os-x)"
+ cygwin "(windows|cygwin|[-_]win|win64|win32)"
+ windows "(windows|cygwin|[-_]win|win64|win32)"
+ msys "(windows|msys|cygwin|[-_]win|win64|win32)"
+ armv7l "(arm7|armv7)"
+ armv7l-2 "arm7"
+ armv6l "(arm6|armv6)"
+ armv6l-2 "arm"
+ armv5l "(arm5|armv5)"
+ armv5l-2 "arm"
+ )
+
+ local -a list init_list
+
+ init_list=( ${(@f)"$( { .zi-download-file-stdout $url || .zi-download-file-stdout $url 1; } 2>/dev/null | \
+ command grep -o 'href=./'$user'/'$plugin'/releases/download/[^"]\+')"} )
+ init_list=( ${init_list[@]#href=?} )
+
+ local -a list2 bpicks
+ bpicks=( ${(s.;.)ICE[bpick]} )
+ [[ -z $bpicks ]] && bpicks=( "" )
+ local bpick
+
+ reply=()
+ for bpick ( "${bpicks[@]}" ) {
+ list=( $init_list )
+
+ if [[ -n $bpick ]] {
+ list=( ${(M)list[@]:#(#i)*/$~bpick} )
}
- local -A matchstr
- matchstr=(
- i386 "((386|686|linux32|x86*(#e))~*x86_64*)"
- i686 "((386|686|linux32|x86*(#e))~*x86_64*)"
- x86_64 "(x86_64|amd64|intel|linux64)"
- amd64 "(x86_64|amd64|intel|linux64)"
- aarch64 "aarch64"
- aarch64-2 "arm"
- linux "(linux|linux-gnu)"
- darwin "(darwin|mac|macos|osx|os-x)"
- cygwin "(windows|cygwin|[-_]win|win64|win32)"
- windows "(windows|cygwin|[-_]win|win64|win32)"
- msys "(windows|msys|cygwin|[-_]win|win64|win32)"
- armv7l "(arm7|armv7)"
- armv7l-2 "arm7"
- armv6l "(arm6|armv6)"
- armv6l-2 "arm"
- armv5l "(arm5|armv5)"
- armv5l-2 "arm"
- )
-
- local -a list init_list
-
- init_list=( ${(@f)"$( { .zi-download-file-stdout $url || .zi-download-file-stdout $url 1; } 2>/dev/null | \
- command grep -o 'href=./'$user'/'$plugin'/releases/download/[^"]\+')"} )
- init_list=( ${init_list[@]#href=?} )
-
- local -a list2 bpicks
- bpicks=( ${(s.;.)ICE[bpick]} )
- [[ -z $bpicks ]] && bpicks=( "" )
- local bpick
-
- reply=()
- for bpick ( "${bpicks[@]}" ) {
- list=( $init_list )
-
- if [[ -n $bpick ]] {
- list=( ${(M)list[@]:#(#i)*/$~bpick} )
- }
-
- if (( $#list > 1 )) {
- list2=( ${(M)list[@]:#(#i)*${~matchstr[$MACHTYPE]:-${MACHTYPE#(#i)(i|amd)}}*} )
- (( $#list2 > 0 )) && list=( ${list2[@]} )
- }
-
- if (( ${#list} > 1 && ${#matchstr[${MACHTYPE}-2]} )) {
- list2=( ${(M)list[@]:#(#i)*${~matchstr[${MACHTYPE}-2]:-${MACHTYPE#(#i)(i|amd)}}*} )
- (( $#list2 > 0 )) && list=( ${list2[@]} )
- }
+ if (( $#list > 1 )) {
+ list2=( ${(M)list[@]:#(#i)*${~matchstr[$MACHTYPE]:-${MACHTYPE#(#i)(i|amd)}}*} )
+ (( $#list2 > 0 )) && list=( ${list2[@]} )
+ }
- if (( $#list > 1 )) {
- list2=( ${(M)list[@]:#(#i)*${~matchstr[$CPUTYPE]:-${CPUTYPE#(#i)(i|amd)}}*} )
- (( $#list2 > 0 )) && list=( ${list2[@]} )
- }
+ if (( ${#list} > 1 && ${#matchstr[${MACHTYPE}-2]} )) {
+ list2=( ${(M)list[@]:#(#i)*${~matchstr[${MACHTYPE}-2]:-${MACHTYPE#(#i)(i|amd)}}*} )
+ (( $#list2 > 0 )) && list=( ${list2[@]} )
+ }
- if (( $#list > 1 )) {
- list2=( ${(M)list[@]:#(#i)*${~matchstr[${${OSTYPE%(#i)-(gnu|musl)}%%(-|)[0-9.]##}]:-${${OSTYPE%(#i)-(gnu|musl)}%%(-|)[0-9.]##}}*} )
- (( $#list2 > 0 )) && list=( ${list2[@]} )
- }
+ if (( $#list > 1 )) {
+ list2=( ${(M)list[@]:#(#i)*${~matchstr[$CPUTYPE]:-${CPUTYPE#(#i)(i|amd)}}*} )
+ (( $#list2 > 0 )) && list=( ${list2[@]} )
+ }
- if (( $#list > 1 )) {
- list2=( ${list[@]:#(#i)*.(sha[[:digit:]]#|asc)} )
- (( $#list2 > 0 )) && list=( ${list2[@]} )
- }
+ if (( $#list > 1 )) {
+ list2=( ${(M)list[@]:#(#i)*${~matchstr[${${OSTYPE%(#i)-(gnu|musl)}%%(-|)[0-9.]##}]:-${${OSTYPE%(#i)-(gnu|musl)}%%(-|)[0-9.]##}}*} )
+ (( $#list2 > 0 )) && list=( ${list2[@]} )
+ }
- if (( $#list > 1 && $+commands[dpkg-deb] )) {
- list2=( ${list[@]:#*.deb} )
- (( $#list2 > 0 )) && list=( ${list2[@]} )
- }
+ if (( $#list > 1 )) {
+ list2=( ${list[@]:#(#i)*.(sha[[:digit:]]#|asc)} )
+ (( $#list2 > 0 )) && list=( ${list2[@]} )
+ }
- if (( $#list > 1 && $+commands[rpm] )) {
- list2=( ${list[@]:#*.rpm} )
- (( $#list2 > 0 )) && list=( ${list2[@]} )
- }
+ if (( $#list > 1 && $+commands[dpkg-deb] )) {
+ list2=( ${list[@]:#*.deb} )
+ (( $#list2 > 0 )) && list=( ${list2[@]} )
+ }
- if (( !$#list )) {
- +zi-message -n "{error}Didn't find correct Github" \
- "release-file to download"
- if [[ -n $bpick ]] {
- +zi-message -n ", try adapting {obj}bpick{error}-ICE" \
- "(the current bpick is{error}: {file}${bpick}{error})."
- } else {
- +zi-message -n .
- }
- +zi-message '{rst}'
- return 1
- }
+ if (( $#list > 1 && $+commands[rpm] )) {
+ list2=( ${list[@]:#*.rpm} )
+ (( $#list2 > 0 )) && list=( ${list2[@]} )
+ }
- reply+=( $list[1] )
+ if (( !$#list )) {
+ +zi-message -n "{error}Didn't find correct Github" \
+ "release-file to download"
+ if [[ -n $bpick ]] {
+ +zi-message -n ", try adapting {obj}bpick{error}-ICE" \
+ "(the current bpick is{error}: {file}${bpick}{error})."
+ } else {
+ +zi-message -n .
+ }
+ +zi-message '{rst}'
+ return 1
}
- [[ -n $reply ]] # testable
+
+ reply+=( $list[1] )
+ }
+ [[ -n $reply ]] # testable
}
# ]]]
# FUNCTION: ziextract [[[
@@ -1524,345 +1545,345 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
# $1 - url
# $2 - file
ziextract() {
- emulate -LR zsh
- setopt extendedglob typesetsilent noshortloops # warncreateglobal
-
- local -a opt_move opt_move2 opt_norm opt_auto opt_nobkp
- zparseopts -D -E -move=opt_move -move2=opt_move2 -norm=opt_norm \
- -auto=opt_auto -nobkp=opt_nobkp || \
- { +zi-message "{error}ziextract:{msg2} Incorrect options given to" \
- "\`{pre}ziextract{msg2}' (available are: {meta}--auto{msg2}," \
- "{meta}--move{msg2}, {meta}--move2{msg2}, {meta}--norm{msg2}," \
- "{meta}--nobkp{msg2}).{rst}"; return 1; }
-
- local file="$1" ext="$2"
- integer move=${${${(M)${#opt_move}:#0}:+0}:-1} \
- move2=${${${(M)${#opt_move2}:#0}:+0}:-1} \
- norm=${${${(M)${#opt_norm}:#0}:+0}:-1} \
- auto=${${${(M)${#opt_auto}:#0}:+0}:-1} \
- nobkp=${${${(M)${#opt_nobkp}:#0}:+0}:-1}
-
- if (( auto )) {
- # First try known file extensions
- local -a files
- integer ret_val
- files=( (#i)**/*.(zip|rar|7z|tgz|tbz2|tar.gz|tar.bz2|tar.7z|txz|tar.xz|gz|xz|tar|dmg|exe)~(*/*|.(_backup|git))/*(-.DN) )
- for file ( $files ) {
- ziextract "$file" $opt_move $opt_move2 $opt_norm $opt_nobkp ${${${#files}:#1}:+--nobkp}
- ret_val+=$?
- }
- # Second, try to find the archive via `file' tool
- if (( !${#files} )) {
- local -aU output infiles stage2_processed archives
- infiles=( **/*~(._zi*|._backup|.git)(|/*)~*/*/*(-.DN) )
- output=( ${(@f)"$(command file -- $infiles 2>&1)"} )
- archives=( ${(M)output[@]:#(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) *} )
- for file ( $archives ) {
- local fname=${(M)file#(${(~j:|:)infiles}): } desc=${file#(${(~j:|:)infiles}): } type
- fname=${fname%%??}
- [[ -z $fname || -n ${stage2_processed[(r)$fname]} ]] && continue
- type=${(L)desc/(#b)(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) */$match[2]}
- if [[ $type = (zip|rar|xz|7-zip|gzip|bzip2|tar|exe|pe32) ]] {
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message "{pre}ziextract:{info2} Note:{rst}" \
- "detected a {meta}$type{rst} archive in the file" \
- "{file}$fname{rst}."
- ziextract "$fname" "$type" $opt_move $opt_move2 $opt_norm --norm ${${${#archives}:#1}:+--nobkp}
- integer iret_val=$?
- ret_val+=iret_val
-
- (( iret_val )) && continue
-
- # Support nested tar.(bz2|gz|…) archives
- local infname=$fname
- [[ -f $fname.out ]] && fname=$fname.out
- files=( *.tar(ND) )
- if [[ -f $fname || -f ${fname:r} ]] {
- local -aU output2 archives2
- output2=( ${(@f)"$(command file -- "$fname"(N) "${fname:r}"(N) $files[1](N) 2>&1)"} )
- archives2=( ${(M)output2[@]:#(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) *} )
- local file2
- for file2 ( $archives2 ) {
- fname=${file2%:*} desc=${file2##*:}
- local type2=${(L)desc/(#b)(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) */$match[2]}
- if [[ $type != $type2 && \
- $type2 = (zip|rar|xz|7-zip|gzip|bzip2|tar)
- ]] {
- # TODO: if multiple archives are really in the archive,
- # this might delete too soon… However, it's unusual case.
- [[ $fname != $infname && $norm -eq 0 ]] && command rm -f "$infname"
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message "{pre}ziextract:{info2} Note:{rst}" \
- "detected a {obj}${type2}{rst} archive in the" \
- " file {file}${fname}{rst}."
- ziextract "$fname" "$type2" $opt_move $opt_move2 $opt_norm ${${${#archives}:#1}:+--nobkp}
- ret_val+=$?
- stage2_processed+=( $fname )
- if [[ $fname == *.out ]] {
- [[ -f $fname ]] && command mv -f "$fname" "${fname%.out}"
- stage2_processed+=( ${fname%.out} )
- }
- }
- }
- }
+ emulate -LR zsh
+ setopt extendedglob typesetsilent noshortloops # warncreateglobal
+
+ local -a opt_move opt_move2 opt_norm opt_auto opt_nobkp
+ zparseopts -D -E -move=opt_move -move2=opt_move2 -norm=opt_norm \
+ -auto=opt_auto -nobkp=opt_nobkp || \
+ { +zi-message "{error}ziextract:{msg2} Incorrect options given to" \
+ "\`{pre}ziextract{msg2}' (available are: {meta}--auto{msg2}," \
+ "{meta}--move{msg2}, {meta}--move2{msg2}, {meta}--norm{msg2}," \
+ "{meta}--nobkp{msg2}).{rst}"; return 1; }
+
+ local file="$1" ext="$2"
+ integer move=${${${(M)${#opt_move}:#0}:+0}:-1} \
+ move2=${${${(M)${#opt_move2}:#0}:+0}:-1} \
+ norm=${${${(M)${#opt_norm}:#0}:+0}:-1} \
+ auto=${${${(M)${#opt_auto}:#0}:+0}:-1} \
+ nobkp=${${${(M)${#opt_nobkp}:#0}:+0}:-1}
+
+ if (( auto )) {
+ # First try known file extensions
+ local -a files
+ integer ret_val
+ files=( (#i)**/*.(zip|rar|7z|tgz|tbz2|tar.gz|tar.bz2|tar.7z|txz|tar.xz|gz|xz|tar|dmg|exe)~(*/*|.(_backup|git))/*(-.DN) )
+ for file ( $files ) {
+ ziextract "$file" $opt_move $opt_move2 $opt_norm $opt_nobkp ${${${#files}:#1}:+--nobkp}
+ ret_val+=$?
+ }
+ # Second, try to find the archive via `file' tool
+ if (( !${#files} )) {
+ local -aU output infiles stage2_processed archives
+ infiles=( **/*~(._zi*|._backup|.git)(|/*)~*/*/*(-.DN) )
+ output=( ${(@f)"$(command file -- $infiles 2>&1)"} )
+ archives=( ${(M)output[@]:#(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) *} )
+ for file ( $archives ) {
+ local fname=${(M)file#(${(~j:|:)infiles}): } desc=${file#(${(~j:|:)infiles}): } type
+ fname=${fname%%??}
+ [[ -z $fname || -n ${stage2_processed[(r)$fname]} ]] && continue
+ type=${(L)desc/(#b)(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) */$match[2]}
+ if [[ $type = (zip|rar|xz|7-zip|gzip|bzip2|tar|exe|pe32) ]] {
+ (( !OPTS[opt_-q,--quiet] )) && \
+ +zi-message "{pre}ziextract:{info2} Note:{rst}" \
+ "detected a {meta}$type{rst} archive in the file" \
+ "{file}$fname{rst}."
+ ziextract "$fname" "$type" $opt_move $opt_move2 $opt_norm --norm ${${${#archives}:#1}:+--nobkp}
+ integer iret_val=$?
+ ret_val+=iret_val
+
+ (( iret_val )) && continue
+
+ # Support nested tar.(bz2|gz|…) archives
+ local infname=$fname
+ [[ -f $fname.out ]] && fname=$fname.out
+ files=( *.tar(ND) )
+ if [[ -f $fname || -f ${fname:r} ]] {
+ local -aU output2 archives2
+ output2=( ${(@f)"$(command file -- "$fname"(N) "${fname:r}"(N) $files[1](N) 2>&1)"} )
+ archives2=( ${(M)output2[@]:#(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) *} )
+ local file2
+ for file2 ( $archives2 ) {
+ fname=${file2%:*} desc=${file2##*:}
+ local type2=${(L)desc/(#b)(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) */$match[2]}
+ if [[ $type != $type2 && \
+ $type2 = (zip|rar|xz|7-zip|gzip|bzip2|tar)
+ ]] {
+ # TODO: if multiple archives are really in the archive,
+ # this might delete too soon… However, it's unusual case.
+ [[ $fname != $infname && $norm -eq 0 ]] && command rm -f "$infname"
+ (( !OPTS[opt_-q,--quiet] )) && \
+ +zi-message "{pre}ziextract:{info2} Note:{rst}" \
+ "detected a {obj}${type2}{rst} archive in the" \
+ " file {file}${fname}{rst}."
+ ziextract "$fname" "$type2" $opt_move $opt_move2 $opt_norm ${${${#archives}:#1}:+--nobkp}
+ ret_val+=$?
+ stage2_processed+=( $fname )
+ if [[ $fname == *.out ]] {
+ [[ -f $fname ]] && command mv -f "$fname" "${fname%.out}"
+ stage2_processed+=( ${fname%.out} )
}
+ }
}
+ }
}
- return $ret_val
- }
-
- if [[ -z $file ]] {
- +zi-message "{error}ziextract:{msg2} ERROR:{msg} argument" \
- "needed (the file to extract) or the {meta}--auto{msg} option."
- return 1
- }
- if [[ ! -e $file ]] {
- +zi-message "{error}ziextract:{msg2} ERROR:{msg}" \
- "the file \`{meta}${file}{msg}' doesn't exist.{rst}"
- return 1
+ }
}
- if (( !nobkp )) {
- command mkdir -p ._backup
- command rm -rf ._backup/*(DN)
- command mv -f *~(._zi*|._backup|.git|.svn|.hg|$file)(DN) ._backup 2>/dev/null
+ return $ret_val
+ }
+
+ if [[ -z $file ]] {
+ +zi-message "{error}ziextract:{msg2} ERROR:{msg} argument" \
+ "needed (the file to extract) or the {meta}--auto{msg} option."
+ return 1
+ }
+ if [[ ! -e $file ]] {
+ +zi-message "{error}ziextract:{msg2} ERROR:{msg}" \
+ "the file \`{meta}${file}{msg}' doesn't exist.{rst}"
+ return 1
+ }
+ if (( !nobkp )) {
+ command mkdir -p ._backup
+ command rm -rf ._backup/*(DN)
+ command mv -f *~(._zi*|._backup|.git|.svn|.hg|$file)(DN) ._backup 2>/dev/null
+ }
+
+ .zi-extract-wrapper() {
+ local file="$1" fun="$2" retval
+ (( !OPTS[opt_-q,--quiet] )) && \
+ +zi-message "{pre}ziextract:{msg} Unpacking the files from: \`{obj}$file{msg}'{…}{rst}"
+ $fun; retval=$?
+ if (( retval == 0 )) {
+ local -a files
+ files=( *~(._zi*|._backup|.git|.svn|.hg|$file)(DN) )
+ (( ${#files} && !norm )) && command rm -f "$file"
}
+ return $retval
+ }
+
+ →zi-check() { (( ${+commands[$1]} )) || \
+ +zi-message "{error}ziextract:{msg2} Error:{msg} No command {data}$1{msg}," \
+ "it is required to unpack {file}$2{rst}."
+ }
+
+ case "${${ext:+.$ext}:-$file}" in
+ ((#i)*.zip)
+ →zi-extract() { →zi-check unzip "$file" || return 1; command unzip -o "$file"; }
+ ;;
+ ((#i)*.rar)
+ →zi-extract() { →zi-check unrar "$file" || return 1; command unrar x "$file"; }
+ ;;
+ ((#i)*.tar.bz2|(#i)*.tbz2)
+ →zi-extract() { →zi-check bzip2 "$file" || return 1; command bzip2 -dc "$file" | command tar -xf -; }
+ ;;
+ ((#i)*.tar.gz|(#i)*.tgz)
+ →zi-extract() { →zi-check gzip "$file" || return 1; command gzip -dc "$file" | command tar -xf -; }
+ ;;
+ ((#i)*.tar.xz|(#i)*.txz)
+ →zi-extract() { →zi-check xz "$file" || return 1; command xz -dc "$file" | command tar -xf -; }
+ ;;
+ ((#i)*.tar.7z|(#i)*.t7z)
+ →zi-extract() { →zi-check 7z "$file" || return 1; command 7z x -so "$file" | command tar -xf -; }
+ ;;
+ ((#i)*.tar)
+ →zi-extract() { →zi-check tar "$file" || return 1; command tar -xf "$file"; }
+ ;;
+ ((#i)*.gz|(#i)*.gzip)
+ if [[ $file != (#i)*.gz ]] {
+ command mv $file $file.gz
+ file=$file.gz
+ integer zi_was_renamed=1
+ }
+ →zi-extract() {
+ →zi-check gunzip "$file" || return 1
+ .zi-get-mtime-into "$file" 'ZI[tmp]'
+ command gunzip "$file" |& command egrep -v '.out$'
+ integer ret=$pipestatus[1]
+ command touch -t "$(strftime %Y%m%d%H%M.%S $ZI[tmp])" "$file"
+ return ret
+ }
+ ;;
+ ((#i)*.bz2|(#i)*.bzip2)
+ # Rename file if its extension does not match "bz2". bunzip2 refuses to operate on files that are not named correctly.
+ if [[ $file != (#i)*.bz2 ]] {
+ command mv $file $file.bz2
+ file=$file.bz2
+ }
+ →zi-extract() { →zi-check bunzip2 "$file" || return 1
+ .zi-get-mtime-into "$file" 'ZI[tmp]'
+ command bunzip2 "$file" |& command egrep -v '.out$'
+ integer ret=$pipestatus[1]
+ command touch -t "$(strftime %Y%m%d%H%M.%S $ZI[tmp])" "$file"
+ return ret
+ }
+ ;;
+ ((#i)*.xz)
+ if [[ $file != (#i)*.xz ]] {
+ command mv $file $file.xz
+ file=$file.xz
+ }
+ →zi-extract() { →zi-check xz "$file" || return 1
+ .zi-get-mtime-into "$file" 'ZI[tmp]'
+ command xz -d "$file"
+ integer ret=$?
+ command touch -t "$(strftime %Y%m%d%H%M.%S $ZI[tmp])" "$file"
+ return ret
+ }
+ ;;
+ ((#i)*.7z|(#i)*.7-zip)
+ →zi-extract() { →zi-check 7z "$file" || return 1; command 7z x "$file" >/dev/null; }
+ ;;
+ ((#i)*.dmg)
+ →zi-extract() {
+ local prog
+ for prog ( hdiutil cp ) { →zi-check $prog "$file" || return 1; }
- .zi-extract-wrapper() {
- local file="$1" fun="$2" retval
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message "{pre}ziextract:{msg} Unpacking the files from: \`{obj}$file{msg}'{…}{rst}"
- $fun; retval=$?
- if (( retval == 0 )) {
- local -a files
- files=( *~(._zi*|._backup|.git|.svn|.hg|$file)(DN) )
- (( ${#files} && !norm )) && command rm -f "$file"
- }
- return $retval
- }
+ integer retval
+ local attached_vol="$( command hdiutil attach "$file" | \
+ command tail -n1 | command cut -f 3 )"
- →zi-check() { (( ${+commands[$1]} )) || \
- +zi-message "{error}ziextract:{msg2} Error:{msg} No command {data}$1{msg}," \
- "it is required to unpack {file}$2{rst}."
- }
+ command cp -Rf ${attached_vol:-${TMPDIR:-/tmp}/acb321GEF}/*(D) .
+ retval=$?
+ command hdiutil detach $attached_vol
- case "${${ext:+.$ext}:-$file}" in
- ((#i)*.zip)
- →zi-extract() { →zi-check unzip "$file" || return 1; command unzip -o "$file"; }
- ;;
- ((#i)*.rar)
- →zi-extract() { →zi-check unrar "$file" || return 1; command unrar x "$file"; }
- ;;
- ((#i)*.tar.bz2|(#i)*.tbz2)
- →zi-extract() { →zi-check bzip2 "$file" || return 1; command bzip2 -dc "$file" | command tar -xf -; }
- ;;
- ((#i)*.tar.gz|(#i)*.tgz)
- →zi-extract() { →zi-check gzip "$file" || return 1; command gzip -dc "$file" | command tar -xf -; }
- ;;
- ((#i)*.tar.xz|(#i)*.txz)
- →zi-extract() { →zi-check xz "$file" || return 1; command xz -dc "$file" | command tar -xf -; }
- ;;
- ((#i)*.tar.7z|(#i)*.t7z)
- →zi-extract() { →zi-check 7z "$file" || return 1; command 7z x -so "$file" | command tar -xf -; }
- ;;
- ((#i)*.tar)
- →zi-extract() { →zi-check tar "$file" || return 1; command tar -xf "$file"; }
- ;;
- ((#i)*.gz|(#i)*.gzip)
- if [[ $file != (#i)*.gz ]] {
- command mv $file $file.gz
- file=$file.gz
- integer zi_was_renamed=1
- }
- →zi-extract() {
- →zi-check gunzip "$file" || return 1
- .zi-get-mtime-into "$file" 'ZI[tmp]'
- command gunzip "$file" |& command egrep -v '.out$'
- integer ret=$pipestatus[1]
- command touch -t "$(strftime %Y%m%d%H%M.%S $ZI[tmp])" "$file"
- return ret
- }
- ;;
- ((#i)*.bz2|(#i)*.bzip2)
- # Rename file if its extension does not match "bz2". bunzip2 refuses to operate on files that are not named correctly.
- if [[ $file != (#i)*.bz2 ]] {
- command mv $file $file.bz2
- file=$file.bz2
- }
- →zi-extract() { →zi-check bunzip2 "$file" || return 1
- .zi-get-mtime-into "$file" 'ZI[tmp]'
- command bunzip2 "$file" |& command egrep -v '.out$'
- integer ret=$pipestatus[1]
- command touch -t "$(strftime %Y%m%d%H%M.%S $ZI[tmp])" "$file"
- return ret
- }
- ;;
- ((#i)*.xz)
- if [[ $file != (#i)*.xz ]] {
- command mv $file $file.xz
- file=$file.xz
- }
- →zi-extract() { →zi-check xz "$file" || return 1
- .zi-get-mtime-into "$file" 'ZI[tmp]'
- command xz -d "$file"
- integer ret=$?
- command touch -t "$(strftime %Y%m%d%H%M.%S $ZI[tmp])" "$file"
- return ret
- }
- ;;
- ((#i)*.7z|(#i)*.7-zip)
- →zi-extract() { →zi-check 7z "$file" || return 1; command 7z x "$file" >/dev/null; }
- ;;
- ((#i)*.dmg)
- →zi-extract() {
- local prog
- for prog ( hdiutil cp ) { →zi-check $prog "$file" || return 1; }
-
- integer retval
- local attached_vol="$( command hdiutil attach "$file" | \
- command tail -n1 | command cut -f 3 )"
-
- command cp -Rf ${attached_vol:-${TMPDIR:-/tmp}/acb321GEF}/*(D) .
- retval=$?
- command hdiutil detach $attached_vol
-
- if (( retval )) {
- +zi-message "{error}ziextract:{msg2} WARNING:{msg}" \
- "problem occurred when attempted to copy the files" \
- "from the mounted image: \`{obj}${file}{msg}'.{rst}"
- }
- return $retval
- }
- ;;
- ((#i)*.deb)
- →zi-extract() { →zi-check dpkg-deb "$file" || return 1; command dpkg-deb -R "$file" .; }
- ;;
- ((#i)*.rpm)
- →zi-extract() { →zi-check cpio "$file" || return 1; $ZI[BIN_DIR]/lib/zsh/rpm2cpio.zsh "$file" | command cpio -imd --no-absolute-filenames; }
- ;;
- ((#i)*.exe|(#i)*.pe32)
- →zi-extract() {
- command chmod a+x -- ./$file
- ./$file /S /D="`cygpath -w $PWD`"
- }
- ;;
- esac
-
- if [[ $(typeset -f + →zi-extract) == "→zi-extract" ]] {
- .zi-extract-wrapper "$file" →zi-extract || {
- +zi-message -n "{error}ziextract:{msg2} WARNING:{msg}" \
- "extraction of the archive \`{file}${file}{msg}' had problems"
- local -a bfiles
- bfiles=( ._backup/*(DN) )
- if (( ${#bfiles} && !nobkp )) {
- +zi-message -n ", restoring the previous version of the plugin/snippet"
- command mv ._backup/*(DN) . 2>/dev/null
- }
- +zi-message ".{rst}"
- unfunction -- →zi-extract →zi-check 2>/dev/null
- return 1
+ if (( retval )) {
+ +zi-message "{error}ziextract:{msg2} WARNING:{msg}" \
+ "problem occurred when attempted to copy the files" \
+ "from the mounted image: \`{obj}${file}{msg}'.{rst}"
}
- unfunction -- →zi-extract →zi-check
- } else {
- integer warning=1
- }
- unfunction -- .zi-extract-wrapper
-
- local -a execs
- execs=( **/*~(._zi(|/*)|.git(|/*)|.svn(|/*)|.hg(|/*)|._backup(|/*))(DN-.) )
- if [[ ${#execs} -gt 0 && -n $execs ]] {
- execs=( ${(@f)"$( file ${execs[@]} )"} )
- execs=( "${(M)execs[@]:#[^:]##:*executable*}" )
- execs=( "${execs[@]/(#b)([^:]##):*/${match[1]}}" )
+ return $retval
+ }
+ ;;
+ ((#i)*.deb)
+ →zi-extract() { →zi-check dpkg-deb "$file" || return 1; command dpkg-deb -R "$file" .; }
+ ;;
+ ((#i)*.rpm)
+ →zi-extract() { →zi-check cpio "$file" || return 1; $ZI[BIN_DIR]/lib/zsh/rpm2cpio.zsh "$file" | command cpio -imd --no-absolute-filenames; }
+ ;;
+ ((#i)*.exe|(#i)*.pe32)
+ →zi-extract() {
+ command chmod a+x -- ./$file
+ ./$file /S /D="`cygpath -w $PWD`"
+ }
+ ;;
+ esac
+
+ if [[ $(typeset -f + →zi-extract) == "→zi-extract" ]] {
+ .zi-extract-wrapper "$file" →zi-extract || {
+ +zi-message -n "{error}ziextract:{msg2} WARNING:{msg}" \
+ "extraction of the archive \`{file}${file}{msg}' had problems"
+ local -a bfiles
+ bfiles=( ._backup/*(DN) )
+ if (( ${#bfiles} && !nobkp )) {
+ +zi-message -n ", restoring the previous version of the plugin/snippet"
+ command mv ._backup/*(DN) . 2>/dev/null
+ }
+ +zi-message ".{rst}"
+ unfunction -- →zi-extract →zi-check 2>/dev/null
+ return 1
}
-
- builtin print -rl -- ${execs[@]} >! ${TMPDIR:-/tmp}/zi-execs.$$.lst
- if [[ ${#execs} -gt 0 ]] {
- command chmod a+x "${execs[@]}"
- if (( !OPTS[opt_-q,--quiet] )) {
- if (( ${#execs} == 1 )); then
- +zi-message "{pre}ziextract:{rst}" \
- "Successfully extracted and assigned +x chmod to the file:" \
- "\`{obj}${execs[1]}{rst}'."
- else
- local sep="$ZI[col-rst],$ZI[col-obj] "
- if (( ${#execs} > 7 )) {
- +zi-message "{pre}ziextract:{rst} Successfully" \
- "extracted and marked executable the appropriate files" \
- "({obj}${(pj:$sep:)${(@)execs[1,5]:t}},…{rst}) contained" \
- "in \`{file}$file{rst}'. All the extracted" \
- "{obj}${#execs}{rst} executables are" \
- "available in the {msg2}INSTALLED_EXECS{rst}" \
- "array."
- } else {
- +zi-message "{pre}ziextract:{rst} Successfully" \
- "extracted and marked executable the appropriate files" \
- "({obj}${(pj:$sep:)${execs[@]:t}}{rst}) contained" \
- "in \`{file}$file{rst}'."
- }
- fi
+ unfunction -- →zi-extract →zi-check
+ } else {
+ integer warning=1
+ }
+ unfunction -- .zi-extract-wrapper
+
+ local -a execs
+ execs=( **/*~(._zi(|/*)|.git(|/*)|.svn(|/*)|.hg(|/*)|._backup(|/*))(DN-.) )
+ if [[ ${#execs} -gt 0 && -n $execs ]] {
+ execs=( ${(@f)"$( file ${execs[@]} )"} )
+ execs=( "${(M)execs[@]:#[^:]##:*executable*}" )
+ execs=( "${execs[@]/(#b)([^:]##):*/${match[1]}}" )
+ }
+
+ builtin print -rl -- ${execs[@]} >! ${TMPDIR:-/tmp}/zi-execs.$$.lst
+ if [[ ${#execs} -gt 0 ]] {
+ command chmod a+x "${execs[@]}"
+ if (( !OPTS[opt_-q,--quiet] )) {
+ if (( ${#execs} == 1 )); then
+ +zi-message "{pre}ziextract:{rst}" \
+ "Successfully extracted and assigned +x chmod to the file:" \
+ "\`{obj}${execs[1]}{rst}'."
+ else
+ local sep="$ZI[col-rst],$ZI[col-obj] "
+ if (( ${#execs} > 7 )) {
+ +zi-message "{pre}ziextract:{rst} Successfully" \
+ "extracted and marked executable the appropriate files" \
+ "({obj}${(pj:$sep:)${(@)execs[1,5]:t}},…{rst}) contained" \
+ "in \`{file}$file{rst}'. All the extracted" \
+ "{obj}${#execs}{rst} executables are" \
+ "available in the {msg2}INSTALLED_EXECS{rst}" \
+ "array."
+ } else {
+ +zi-message "{pre}ziextract:{rst} Successfully" \
+ "extracted and marked executable the appropriate files" \
+ "({obj}${(pj:$sep:)${execs[@]:t}}{rst}) contained" \
+ "in \`{file}$file{rst}'."
}
- } elif (( warning )) {
- +zi-message "{pre}ziextract:" \
- "{error}WARNING: {msg}didn't recognize the archive" \
- "type of \`{obj}${file}{msg}'" \
- "${ext:+/ {obj2}${ext}{msg} }"\
-"(no extraction has been done).%f%b"
+ fi
}
+ } elif (( warning )) {
+ +zi-message "{pre}ziextract:" \
+ "{error}WARNING: {msg}didn't recognize the archive" \
+ "type of \`{obj}${file}{msg}'" \
+ "${ext:+/ {obj2}${ext}{msg} }"\
+"(no extraction has been done).%f%b"
+ }
+
+ if (( move | move2 )) {
+ local -a files
+ files=( *~(._zi|.git|._backup|.tmp231ABC)(DN/) )
+ if (( ${#files} )) {
+ command mkdir -p .tmp231ABC
+ command mv -f *~(._zi|.git|._backup|.tmp231ABC)(D) .tmp231ABC
+ if (( !move2 )) {
+ command mv -f **/*~(*/*~*/*/*|*/*/*/*|^*/*|._zi(|/*)|.git(|/*)|._backup(|/*))(DN) .
+ } else {
+ command mv -f **/*~(*/*~*/*/*/*|*/*/*/*/*|^*/*|._zi(|/*)|.git(|/*)|._backup(|/*))(DN) .
+ }
- if (( move | move2 )) {
- local -a files
- files=( *~(._zi|.git|._backup|.tmp231ABC)(DN/) )
- if (( ${#files} )) {
- command mkdir -p .tmp231ABC
- command mv -f *~(._zi|.git|._backup|.tmp231ABC)(D) .tmp231ABC
- if (( !move2 )) {
- command mv -f **/*~(*/*~*/*/*|*/*/*/*|^*/*|._zi(|/*)|.git(|/*)|._backup(|/*))(DN) .
- } else {
- command mv -f **/*~(*/*~*/*/*/*|*/*/*/*/*|^*/*|._zi(|/*)|.git(|/*)|._backup(|/*))(DN) .
- }
-
- command mv .tmp231ABC/$file . &>/dev/null
- command rm -rf .tmp231ABC
- }
- REPLY="${${execs[1]:h}:h}/${execs[1]:t}"
- } else {
- REPLY="${execs[1]}"
+ command mv .tmp231ABC/$file . &>/dev/null
+ command rm -rf .tmp231ABC
}
- return 0
+ REPLY="${${execs[1]:h}:h}/${execs[1]:t}"
+ } else {
+ REPLY="${execs[1]}"
+ }
+ return 0
}
# ]]]
# FUNCTION: .zi-extract() [[[
.zi-extract() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent
- local tpe=$1 extract=$2 local_dir=$3
- (
- builtin cd -q "$local_dir" || \
- { +zi-message "{error}ERROR:{msg2} The path of the $tpe" \
- "(\`{file}$local_dir{msg2}') isn't accessible.{rst}"
- return 1
- }
- local -a files
- files=( ${(@)${(@s: :)${extract##(\!-|-\!|\!|-)}}//(#b)(((#s)|([^\\])[\\]([\\][\\])#)|((#s)|([^\\])([\\][\\])#)) /${match[2]:+$match[3]$match[4] }${match[5]:+$match[6]${(l:${#match[7]}/2::\\:):-} }} )
- if [[ ${#files} -eq 0 && -n ${extract##(\!-|-\!|\!|-)} ]] {
- +zi-message "{error}ERROR:{msg2} The files" \
- "(\`{file}${extract##(\!-|-\!|\!|-)}{msg2}')" \
- "not found, cannot extract.{rst}"
- return 1
- } else {
- (( !${#files} )) && files=( "" )
- }
- local file
- for file ( "${files[@]}" ) {
- [[ -z $extract ]] && local auto2=--auto
- ziextract ${${(M)extract:#(\!|-)##}:+--auto} \
- $auto2 $file \
- ${${(MS)extract[1,2]##-}:+--norm} \
- ${${(MS)extract[1,2]##\!}:+--move} \
- ${${(MS)extract[1,2]##\!\!}:+--move2} \
- ${${${#files}:#1}:+--nobkp}
- }
- )
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent
+ local tpe=$1 extract=$2 local_dir=$3
+ (
+ builtin cd -q "$local_dir" || \
+ { +zi-message "{error}ERROR:{msg2} The path of the $tpe" \
+ "(\`{file}$local_dir{msg2}') isn't accessible.{rst}"
+ return 1
+ }
+ local -a files
+ files=( ${(@)${(@s: :)${extract##(\!-|-\!|\!|-)}}//(#b)(((#s)|([^\\])[\\]([\\][\\])#)|((#s)|([^\\])([\\][\\])#)) /${match[2]:+$match[3]$match[4] }${match[5]:+$match[6]${(l:${#match[7]}/2::\\:):-} }} )
+ if [[ ${#files} -eq 0 && -n ${extract##(\!-|-\!|\!|-)} ]] {
+ +zi-message "{error}ERROR:{msg2} The files" \
+ "(\`{file}${extract##(\!-|-\!|\!|-)}{msg2}')" \
+ "not found, cannot extract.{rst}"
+ return 1
+ } else {
+ (( !${#files} )) && files=( "" )
+ }
+ local file
+ for file ( "${files[@]}" ) {
+ [[ -z $extract ]] && local auto2=--auto
+ ziextract ${${(M)extract:#(\!|-)##}:+--auto} \
+ $auto2 $file \
+ ${${(MS)extract[1,2]##-}:+--norm} \
+ ${${(MS)extract[1,2]##\!}:+--move} \
+ ${${(MS)extract[1,2]##\!\!}:+--move2} \
+ ${${${#files}:#1}:+--nobkp}
+ }
+ )
}
# ]]]
# FUNCTION: zpextract [[[
@@ -1870,408 +1891,445 @@ zpextract() { ziextract "$@"; }
# ]]]
# FUNCTION: .zi-at-eval [[[
.zi-at-eval() {
- local atclone="$2" atpull="$1"
- integer retval
- @zi-substitute atclone atpull
- [[ $atpull = "%atclone" ]] && { eval "$atclone"; retval=$?; } || { eval "$atpull"; retval=$?; }
- return $retval
+ local atpull="$1" atclone="$2"
+ integer retval
+ @zi-substitute atclone atpull
+ local cmd="$atpull"
+ [[ $atpull == "%atclone" ]] && cmd="$atclone"
+ eval "$cmd"
+ return "$?"
}
# ]]]
# FUNCTION: .zi-get-cygwin-package [[[
.zi-get-cygwin-package() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
- REPLY=
+ REPLY=
- local pkg=$1 nl=$'\n'
- integer retry=3
+ local pkg=$1 nl=$'\n'
+ integer retry=3
- #
- # Download mirrors.lst
- #
+ #
+ # Download mirrors.lst
+ #
- +zi-message "{info}Downloading{ehi}: {obj}mirrors.lst{info}{…}{rst}"
- local mlst="$(mktemp)"
- while (( retry -- )) {
- if ! .zi-download-file-stdout https://cygwin.com/mirrors.lst 0 > $mlst; then
- .zi-download-file-stdout https://cygwin.com/mirrors.lst 1 > $mlst
- fi
+ +zi-message "{info}Downloading{ehi}: {obj}mirrors.lst{info}{…}{rst}"
+ local mlst="$(mktemp)"
+ while (( retry -- )) {
+ if ! .zi-download-file-stdout https://cygwin.com/mirrors.lst 0 > $mlst; then
+ .zi-download-file-stdout https://cygwin.com/mirrors.lst 1 > $mlst
+ fi
- local -a mlist
- mlist=( "${(@f)$(<$mlst)}" )
+ local -a mlist
+ mlist=( "${(@f)$(<$mlst)}" )
- local mirror=${${mlist[ RANDOM % (${#mlist} + 1) ]}%%;*}
- [[ -n $mirror ]] && break
- }
+ local mirror=${${mlist[ RANDOM % (${#mlist} + 1) ]}%%;*}
+ [[ -n $mirror ]] && break
+ }
- if [[ -z $mirror ]] {
- +zi-message "{error}Couldn't download{error}: {obj}mirrors.lst {error}."
- return 1
- }
+ if [[ -z $mirror ]] {
+ +zi-message "{error}Couldn't download{error}: {obj}mirrors.lst {error}."
+ return 1
+ }
- mirror=http://ftp.eq.uc.pt/software/pc/prog/cygwin/
+ mirror=http://ftp.eq.uc.pt/software/pc/prog/cygwin/
- #
- # Download setup.ini.bz2
- #
+ #
+ # Download setup.ini.bz2
+ #
- +zi-message "{info2}Selected mirror is{error}: {url}${mirror}{rst}"
- +zi-message "{info}Downloading{ehi}: {file}setup.ini.bz2{info}{…}{rst}"
- local setup="$(mktemp -u)"
- retry=3
- while (( retry -- )) {
- if ! .zi-download-file-stdout ${mirror}x86_64/setup.bz2 0 1 > $setup.bz2; then
- .zi-download-file-stdout ${mirror}x86_64/setup.bz2 1 1 > $setup.bz2
- fi
+ +zi-message "{info2}Selected mirror is{error}: {url}${mirror}{rst}"
+ +zi-message "{info}Downloading{ehi}: {file}setup.ini.bz2{info}{…}{rst}"
+ local setup="$(mktemp -u)"
+ retry=3
+ while (( retry -- )) {
+ if ! .zi-download-file-stdout ${mirror}x86_64/setup.bz2 0 1 > $setup.bz2; then
+ .zi-download-file-stdout ${mirror}x86_64/setup.bz2 1 1 > $setup.bz2
+ fi
- command bunzip2 "$setup.bz2" 2>/dev/null
- [[ -s $setup ]] && break
+ command bunzip2 "$setup.bz2" 2>/dev/null
+ [[ -s $setup ]] && break
+ mirror=${${mlist[ RANDOM % (${#mlist} + 1) ]}%%;*}
+ +zi-message "{pre}Retrying{error}: {meta}#{obj}$(( 3 - $retry ))/3, {pre}with mirror{error}: {url}${mirror}{rst}"
+ }
+ local setup_contents="$(command grep -A 26 "@ $pkg\$" "$setup")"
+ local urlpart=${${(S)setup_contents/(#b)*@ $pkg${nl}*install: (*)$nl*/$match[1]}%% *}
+ if [[ -z $urlpart ]] {
+ +zi-message "{error}Couldn't find package{error}: {data2}\`{data}${pkg}{data2}'{error}.{rst}"
+ return 2
+ }
+ local url=$mirror/$urlpart outfile=${TMPDIR:-${TMPDIR:-/tmp}}/${urlpart:t}
+
+ #
+ # Download the package
+ #
+
+ +zi-message "{info}Downloading{ehi}: {file}${url:t}{info}{…}{rst}"
+ retry=2
+ while (( retry -- )) {
+ integer retval=0
+ if ! .zi-download-file-stdout $url 0 1 > $outfile; then
+ if ! .zi-download-file-stdout $url 1 1 > $outfile; then
+ +zi-message "{error}Couldn't download{error}: {url}${url}{error}."
+ retval=1
mirror=${${mlist[ RANDOM % (${#mlist} + 1) ]}%%;*}
- +zi-message "{pre}Retrying{error}: {meta}#{obj}$(( 3 - $retry ))/3, {pre}with mirror{error}: {url}${mirror}{rst}"
- }
- local setup_contents="$(command grep -A 26 "@ $pkg\$" "$setup")"
- local urlpart=${${(S)setup_contents/(#b)*@ $pkg${nl}*install: (*)$nl*/$match[1]}%% *}
- if [[ -z $urlpart ]] {
- +zi-message "{error}Couldn't find package{error}: {data2}\`{data}${pkg}{data2}'{error}.{rst}"
- return 2
- }
- local url=$mirror/$urlpart outfile=${TMPDIR:-${TMPDIR:-/tmp}}/${urlpart:t}
-
- #
- # Download the package
- #
-
- +zi-message "{info}Downloading{ehi}: {file}${url:t}{info}{…}{rst}"
- retry=2
- while (( retry -- )) {
- integer retval=0
- if ! .zi-download-file-stdout $url 0 1 > $outfile; then
- if ! .zi-download-file-stdout $url 1 1 > $outfile; then
- +zi-message "{error}Couldn't download{error}: {url}${url}{error}."
- retval=1
- mirror=${${mlist[ RANDOM % (${#mlist} + 1) ]}%%;*}
- url=$mirror/$urlpart outfile=${TMPDIR:-${TMPDIR:-/tmp}}/${urlpart:t}
- if (( retry )) {
- +zi-message "{info2}Retrying, with mirror{error}: {url}${mirror}{info2}{…}{rst}"
- continue
- }
- fi
- fi
- break
- }
- REPLY=$outfile
+ url=$mirror/$urlpart outfile=${TMPDIR:-${TMPDIR:-/tmp}}/${urlpart:t}
+ if (( retry )) {
+ +zi-message "{info2}Retrying, with mirror{error}: {url}${mirror}{info2}{…}{rst}"
+ continue
+ }
+ fi
+ fi
+ break
+ }
+ REPLY=$outfile
}
# ]]]
# FUNCTION zicp [[[
zicp() {
- emulate -LR zsh
- setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
- local -a mbegin mend match
+ local -a mbegin mend match
- local cmd=cp
- if [[ $1 = (-m|--mv) ]] { cmd=mv; shift; }
+ local cmd=cp
+ if [[ $1 = (-m|--mv) ]] { cmd=mv; shift; }
- local dir
- if [[ $1 = (-d|--dir) ]] { dir=$2; shift 2; }
+ local dir
+ if [[ $1 = (-d|--dir) ]] { dir=$2; shift 2; }
- local arg
- arg=${${(j: :)@}//(#b)(([[:space:]]~ )#(([^[:space:]]| )##)([[:space:]]~ )#(#B)(->|=>|→)(#B)([[:space:]]~ )#(#b)(([^[:space:]]| )##)|(#B)([[:space:]]~ )#(#b)(([^[:space:]]| )##))/${match[3]:+$match[3] $match[6]\;}${match[8]:+$match[8] $match[8]\;}}
+ local arg
+ arg=${${(j: :)@}//(#b)(([[:space:]]~ )#(([^[:space:]]| )##)([[:space:]]~ )#(#B)(->|=>|→)(#B)([[:space:]]~ )#(#b)(([^[:space:]]| )##)|(#B)([[:space:]]~ )#(#b)(([^[:space:]]| )##))/${match[3]:+$match[3] $match[6]\;}${match[8]:+$match[8] $match[8]\;}}
- (
- if [[ -n $dir ]] { cd $dir || return 1; }
- local a b var
- integer retval
- for a b ( "${(s: :)${${(@s.;.)${arg%\;}}:-* .}}" ) {
- for var ( a b ) {
- : ${(P)var::=${(P)var//(#b)(((#s)|([^\\])[\\]([\\][\\])#)|((#s)|([^\\])([\\][\\])#)) /${match[2]:+$match[3]$match[4] }${match[5]:+$match[6]${(l:${#match[7]}/2::\\:):-} }}}
- }
- if [[ $a != *\** ]] { a=${a%%/##}"/*" }
- command mkdir -p ${~${(M)b:#/*}:-$ZPFX/$b}
- command $cmd -f ${${(M)cmd:#cp}:+-R} $~a ${~${(M)b:#/*}:-$ZPFX/$b}
- retval+=$?
- }
- return $retval
- )
- return
+ (
+ if [[ -n $dir ]] { cd $dir || return 1; }
+ local a b var
+ integer retval
+ for a b ( "${(s: :)${${(@s.;.)${arg%\;}}:-* .}}" ) {
+ for var ( a b ) {
+ : ${(P)var::=${(P)var//(#b)(((#s)|([^\\])[\\]([\\][\\])#)|((#s)|([^\\])([\\][\\])#)) /${match[2]:+$match[3]$match[4] }${match[5]:+$match[6]${(l:${#match[7]}/2::\\:):-} }}}
+ }
+ if [[ $a != *\** ]] { a=${a%%/##}"/*" }
+ command mkdir -p ${~${(M)b:#/*}:-$ZPFX/$b}
+ command $cmd -f ${${(M)cmd:#cp}:+-R} $~a ${~${(M)b:#/*}:-$ZPFX/$b}
+ retval+=$?
+ }
+ return $retval
+ )
+ return
}
# ]]]
# FUNCTION zimv [[[
zimv() {
- local dir
- if [[ $1 = (-d|--dir) ]] { dir=$2; shift 2; }
- zicp --mv ${dir:+--dir} $dir "$@"
+ local dir
+ if [[ $1 = (-d|--dir) ]] { dir=$2; shift 2; }
+ zicp --mv ${dir:+--dir} $dir "$@"
}
# ]]]
# FUNCTION: ∞zi-reset-opt-hook [[[
∞zi-reset-hook() {
- # File
- if [[ "$1" = plugin ]] {
- local type="$1" user="$2" plugin="$3" id_as="$4" dir="${5#%}" hook="$6"
+ # File
+ if [[ "$1" = plugin ]] {
+ local type="$1" user="$2" plugin="$3" id_as="$4" dir="${5#%}" hook="$6"
+ } else {
+ local type="$1" url="$2" id_as="$3" dir="${4#%}" hook="$5"
+ }
+ if (( ( OPTS[opt_-r,--reset] && ZI[-r/--reset-opt-hook-has-been-run] == 0 ) || \
+ ( ${+ICE[reset]} && ZI[-r/--reset-opt-hook-has-been-run] == 1 )
+ )) {
+ if (( ZI[-r/--reset-opt-hook-has-been-run] )) {
+ local msg_bit="{meta}reset{msg2} ice given{pre}" option=
} else {
- local type="$1" url="$2" id_as="$3" dir="${4#%}" hook="$5"
+ local msg_bit="{meta2}-r/--reset{msg2} given to \`{meta}update{pre}'" option=1
}
- if (( ( OPTS[opt_-r,--reset] && ZI[-r/--reset-opt-hook-has-been-run] == 0 ) || \
- ( ${+ICE[reset]} && ZI[-r/--reset-opt-hook-has-been-run] == 1 )
- )) {
- if (( ZI[-r/--reset-opt-hook-has-been-run] )) {
- local msg_bit="{meta}reset{msg2} ice given{pre}" option=
- } else {
- local msg_bit="{meta2}-r/--reset{msg2} given to \`{meta}update{pre}'" option=1
+ if [[ $type == snippet ]] {
+ if (( $+ICE[svn] )) {
+ if [[ $skip_pull -eq 0 && -d $filename/.svn ]] {
+ (( !OPTS[opt_-q,--quiet] )) && +zi-message "{pre}reset ($msg_bit): {msg2}Resetting the repository ($msg_bit) with command: {rst}svn revert --recursive {…}/{file}$filename/.{rst} {…}"
+ command svn revert --recursive $filename/.
}
- if [[ $type == snippet ]] {
- if (( $+ICE[svn] )) {
- if [[ $skip_pull -eq 0 && -d $filename/.svn ]] {
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{pre}reset ($msg_bit): {msg2}Resetting the repository ($msg_bit) with command: {rst}svn revert --recursive {…}/{file}$filename/.{rst} {…}"
- command svn revert --recursive $filename/.
- }
+ } else {
+ if (( ZI[annex-multi-flag:pull-active] >= 2 )) {
+ if (( !OPTS[opt_-q,--quiet] )) {
+ if [[ -f $local_dir/$dirname/$filename ]] {
+ if [[ -n $option || -z $ICE[reset] ]] {
+ +zi-message "{pre}reset ($msg_bit):{msg2} Removing the snippet-file: {file}$filename{msg2} {…}{rst}"
+ } else {
+ +zi-message "{pre}reset ($msg_bit):{msg2} Removing the snippet-file: {file}$filename{msg2}," \
+ "with the supplied code: {data2}$ICE[reset]{msg2} {…}{rst}"
+ }
+ if (( option )) {
+ command rm -f "$local_dir/$dirname/$filename"
+ } else {
+ eval "${ICE[reset]:-rm -f \"$local_dir/$dirname/$filename\"}"
+ }
} else {
- if (( ZI[annex-multi-flag:pull-active] >= 2 )) {
- if (( !OPTS[opt_-q,--quiet] )) {
- if [[ -f $local_dir/$dirname/$filename ]] {
- if [[ -n $option || -z $ICE[reset] ]] {
- +zi-message "{pre}reset ($msg_bit):{msg2} Removing the snippet-file: {file}$filename{msg2} {…}{rst}"
- } else {
- +zi-message "{pre}reset ($msg_bit):{msg2} Removing the snippet-file: {file}$filename{msg2}," \
- "with the supplied code: {data2}$ICE[reset]{msg2} {…}{rst}"
- }
- if (( option )) {
- command rm -f "$local_dir/$dirname/$filename"
- } else {
- eval "${ICE[reset]:-rm -f \"$local_dir/$dirname/$filename\"}"
- }
- } else {
- +zi-message "{pre}reset ($msg_bit):{msg2} The file {file}$filename{msg2} is already deleted {…}{rst}"
- if [[ -n $ICE[reset] && ! -n $option ]] {
- +zi-message "{pre}reset ($msg_bit):{msg2} (skipped running the provided reset-code:" \
- "{data2}$ICE[reset]{msg2}){rst}"
- }
- }
- }
- } else {
- [[ -f $local_dir/$dirname/$filename ]] && \
- +zi-message "{pre}reset ($msg_bit): {msg2}Skipping the removal of {file}$filename{msg2}" \
- "as there is no new copy scheduled for download.{rst}" || \
- +zi-message "{pre}reset ($msg_bit): {msg2}The file {file}$filename{msg2} is already deleted" \
- "and {ehi}no new download is being scheduled.{rst}"
- }
- }
- } elif [[ $type == plugin ]] {
- if (( is_release && !skip_pull )) {
- if (( option )) {
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{pre}reset ($msg_bit): {msg2}running: {rst}rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}/*"
- builtin eval command rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/"${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}"/*(ND)
- } else {
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{pre}reset ($msg_bit): {msg2}running: {rst}${ICE[reset]:-rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}/*}"
- builtin eval ${ICE[reset]:-command rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/"${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}"/*(ND)}
- }
- } elif (( !skip_pull )) {
- if (( option )) {
- +zi-message "{pre}reset ($msg_bit): {msg2}Resetting the repository with command:{rst} git reset --hard HEAD {…}"
- command git reset --hard HEAD
- } else {
- +zi-message "{pre}reset ($msg_bit): {msg2}Resetting the repository with command:{rst} ${ICE[reset]:-git reset --hard HEAD} {…}"
- builtin eval "${ICE[reset]:-git reset --hard HEAD}"
- }
+ +zi-message "{pre}reset ($msg_bit):{msg2} The file {file}$filename{msg2} is already deleted {…}{rst}"
+ if [[ -n $ICE[reset] && ! -n $option ]] {
+ +zi-message "{pre}reset ($msg_bit):{msg2} (skipped running the provided reset-code:" \
+ "{data2}$ICE[reset]{msg2}){rst}"
+ }
}
+ }
+ } else {
+ [[ -f $local_dir/$dirname/$filename ]] && \
+ +zi-message "{pre}reset ($msg_bit): {msg2}Skipping the removal of {file}$filename{msg2}" \
+ "as there is no new copy scheduled for download.{rst}" || \
+ +zi-message "{pre}reset ($msg_bit): {msg2}The file {file}$filename{msg2} is already deleted" \
+ "and {ehi}no new download is being scheduled.{rst}"
}
- }
-
- if (( OPTS[opt_-r,--reset] )) {
- if (( ZI[-r/--reset-opt-hook-has-been-run] == 1 )) {
- ZI[-r/--reset-opt-hook-has-been-run]=0
+ }
+ } elif [[ $type == plugin ]] {
+ if (( is_release && !skip_pull )) {
+ if (( option )) {
+ (( !OPTS[opt_-q,--quiet] )) && +zi-message "{pre}reset ($msg_bit): {msg2}running: {rst}rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}/*"
+ builtin eval command rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/"${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}"/*(ND)
+ } else {
+ (( !OPTS[opt_-q,--quiet] )) && +zi-message "{pre}reset ($msg_bit): {msg2}running: {rst}${ICE[reset]:-rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}/*}"
+ builtin eval ${ICE[reset]:-command rm -rf ${${ZI[PLUGINS_DIR]:#[/[:space:]]##}:-${TMPDIR:-/tmp}/xyzabc312}/"${${(M)${local_dir##${ZI[PLUGINS_DIR]}[/[:space:]]#}:#[^/]*}:-${TMPDIR:-/tmp}/xyzabc312-zi-protection-triggered}"/*(ND)}
+ }
+ } elif (( !skip_pull )) {
+ if (( option )) {
+ +zi-message "{pre}reset ($msg_bit): {msg2}Resetting the repository with command:{rst} git reset --hard HEAD {…}"
+ command git reset --hard HEAD
} else {
- ZI[-r/--reset-opt-hook-has-been-run]=1
+ +zi-message "{pre}reset ($msg_bit): {msg2}Resetting the repository with command:{rst} ${ICE[reset]:-git reset --hard HEAD} {…}"
+ builtin eval "${ICE[reset]:-git reset --hard HEAD}"
}
+ }
+ }
+ }
+
+ if (( OPTS[opt_-r,--reset] )) {
+ if (( ZI[-r/--reset-opt-hook-has-been-run] == 1 )) {
+ ZI[-r/--reset-opt-hook-has-been-run]=0
} else {
- # If there's no -r/--reset, pretend that it already has been served.
- ZI[-r/--reset-opt-hook-has-been-run]=1
+ ZI[-r/--reset-opt-hook-has-been-run]=1
}
+ } else {
+ # If there's no -r/--reset, pretend that it already has been served.
+ ZI[-r/--reset-opt-hook-has-been-run]=1
+ }
} # ]]]
# FUNCTION: ∞zi-make-ee-hook [[[
∞zi-make-ee-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- local make=${ICE[make]}
- @zi-substitute make
-
- # Git-plugin make'' at download
- [[ $make = "!!"* ]] && \
- .zi-countdown make && \
- command make -C "$dir" ${(@s; ;)${make#\!\!}}
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+
+ local make=${ICE[make]}
+ @zi-substitute make
+ (( ${+ICE[make]} )) || return 0
+ [[ $make = "!!"* ]] || return 0
+ # Git-plugin make'' at download
+ .zi-countdown make && \
+ command make -C "$dir" ${(@s; ;)${make#\!\!}}
} # ]]]
# FUNCTION: ∞zi-make-e-hook [[[
∞zi-make-e-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- local make=${ICE[make]}
- @zi-substitute make
-
- # Git-plugin make'' at download
- [[ $make = ("!"[^\!]*|"!") ]] && \
- .zi-countdown make && \
- command make -C "$dir" ${(@s; ;)${make#\!}}
-}
-# ]]]
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+
+ local make=${ICE[make]}
+ @zi-substitute make
+ (( ${+ICE[make]} )) || return 0
+ [[ $make = ("!"[^\!]*|"!") ]] || return 0
+ # Git-plugin make'' at download
+ [[ $make = ("!"[^\!]*|"!") ]] && \
+ .zi-countdown make && \
+ command make -C "$dir" ${(@s; ;)${make#\!}}
+} # ]]]
# FUNCTION: ∞zi-make-hook [[[
∞zi-make-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- local make=${ICE[make]}
- @zi-substitute make
-
- # Git-plugin make'' at download
- (( ${+ICE[make]} )) && \
- [[ $make != "!"* ]] && \
- .zi-countdown make && \
- command make -C "$dir" ${(@s; ;)make}
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+
+ local make=${ICE[make]}
+ @zi-substitute make
+ (( ${+ICE[make]} )) || return 0
+ [[ $make != "!"* ]] || return 0
+ # Git-plugin make'' at download
+ .zi-countdown make &&
+ command make -C "$dir" ${(@s; ;)make}
} # ]]]
# FUNCTION: ∞zi-atclone-hook [[[
∞zi-atclone-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- local atclone=${ICE[atclone]}
- @zi-substitute atclone
-
- [[ -n $atclone ]] && .zi-countdown atclone && { local ___oldcd=$PWD; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$dir"; } && eval "$atclone"; ((1)); } || eval "$atclone"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+ local atclone=${ICE[atclone]}
+ @zi-substitute atclone
+ (( ${+ICE[atclone]} )) || return 0
+ local rc=0
+ [[ -n $atclone ]] && .zi-countdown atclone && {
+ local ___oldcd=$PWD
+ (( ${+ICE[nocd]} == 0 )) && {
+ () {
+ setopt localoptions noautopushd
+ builtin cd -q "$dir"
+ }
+ }
+ eval "$atclone"
+ rc="$?"
+ () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }
+ }
+ return "$rc"
} # ]]]
# FUNCTION: ∞zi-extract-hook [[[
∞zi-extract-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- local extract=${ICE[extract]}
- @zi-substitute extract
-
- (( ${+ICE[extract]} )) && .zi-extract plugin "$extract" "$dir"
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+ local extract=${ICE[extract]}
+ @zi-substitute extract
+ (( ${+ICE[extract]} )) || return 0
+ .zi-extract plugin "$extract" "$dir"
} # ]]]
# FUNCTION: ∞zi-mv-hook [[[
∞zi-mv-hook() {
- [[ -z $ICE[mv] ]] && return
-
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- if [[ $ICE[mv] == *("->"|"→")* ]] {
- local from=${ICE[mv]%%[[:space:]]#(->|→)*} to=${ICE[mv]##*(->|→)[[:space:]]#} || \
- } else {
- local from=${ICE[mv]%%[[:space:]]##*} to=${ICE[mv]##*[[:space:]]##}
- }
-
- @zi-substitute from to
-
- local -a afr
- ( () { setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1
- afr=( ${~from}(DN) )
- if (( ${#afr} )) {
- if (( !OPTS[opt_-q,--quiet] )) {
- command mv -vf "${afr[1]}" "$to"
- command mv -vf "${afr[1]}".zwc "$to".zwc 2>/dev/null
- } else {
- command mv -f "${afr[1]}" "$to"
- command mv -f "${afr[1]}".zwc "$to".zwc 2>/dev/null
- }
+ [[ -z $ICE[mv] ]] && return
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+ if [[ $ICE[mv] == *("->"|"→")* ]] {
+ local from=${ICE[mv]%%[[:space:]]#(->|→)*} to=${ICE[mv]##*(->|→)[[:space:]]#} || \
+ } else {
+ local from=${ICE[mv]%%[[:space:]]##*} to=${ICE[mv]##*[[:space:]]##}
+ }
+
+ @zi-substitute from to
+
+ local -a afr
+ ( () { setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1
+ afr=( ${~from}(DN) )
+ if (( ${#afr} )) {
+ if (( !OPTS[opt_-q,--quiet] )) {
+ command mv -vf "${afr[1]}" "$to"
+ command mv -vf "${afr[1]}".zwc "$to".zwc 2>/dev/null
+ } else {
+ command mv -f "${afr[1]}" "$to"
+ command mv -f "${afr[1]}".zwc "$to".zwc 2>/dev/null
}
- )
+ }
+ )
} # ]]]
# FUNCTION: ∞zi-cp-hook [[[
∞zi-cp-hook() {
- [[ -z $ICE[cp] ]] && return
-
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- if [[ $ICE[cp] == *("->"|"→")* ]] {
- local from=${ICE[cp]%%[[:space:]]#(->|→)*} to=${ICE[cp]##*(->|→)[[:space:]]#} || \
- } else {
- local from=${ICE[cp]%%[[:space:]]##*} to=${ICE[cp]##*[[:space:]]##}
- }
-
- @zi-substitute from to
-
- local -a afr
- ( () { setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1
- afr=( ${~from}(DN) )
- if (( ${#afr} )) {
- if (( !OPTS[opt_-q,--quiet] )) {
- command cp -vf "${afr[1]}" "$to"
- command cp -vf "${afr[1]}".zwc "$to".zwc 2>/dev/null
- } else {
- command cp -f "${afr[1]}" "$to"
- command cp -f "${afr[1]}".zwc "$to".zwc 2>/dev/null
- }
+ [[ -z $ICE[cp] ]] && return
+
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+
+ if [[ $ICE[cp] == *("->"|"→")* ]] {
+ local from=${ICE[cp]%%[[:space:]]#(->|→)*} to=${ICE[cp]##*(->|→)[[:space:]]#} || \
+ } else {
+ local from=${ICE[cp]%%[[:space:]]##*} to=${ICE[cp]##*[[:space:]]##}
+ }
+
+ @zi-substitute from to
+
+ local -a afr
+ ( () { setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1
+ afr=( ${~from}(DN) )
+ if (( ${#afr} )) {
+ if (( !OPTS[opt_-q,--quiet] )) {
+ command cp -vf "${afr[1]}" "$to"
+ command cp -vf "${afr[1]}".zwc "$to".zwc 2>/dev/null
+ } else {
+ command cp -f "${afr[1]}" "$to"
+ command cp -f "${afr[1]}".zwc "$to".zwc 2>/dev/null
}
- )
+ }
+ )
} # ]]]
# FUNCTION: ∞zi-compile-plugin-hook [[[
∞zi-compile-plugin-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- if [[ ( $hook = *\!at(clone|pull)* && ${+ICE[nocompile]} -eq 0 ) || \
- ( $hook = at(clone|pull)* && $ICE[nocompile] = '!' )
- ]] {
- # Compile plugin
- if [[ -z $ICE[(i)(\!|)(sh|bash|ksh|csh)] ]] {
- () {
- emulate -LR zsh
- setopt extendedglob warncreateglobal
- if [[ $tpe == snippet ]] {
- .zi-compile-plugin "%$dir" ""
- } else {
- .zi-compile-plugin "$id_as" ""
- }
- }
- }
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+
+ if ! [[ ( $hook = *\!at(clone|pull)* && ${+ICE[nocompile]} -eq 0 ) || \
+ ( $hook = at(clone|pull)* && $ICE[nocompile] = '!' ) ]] {
+ return 0
+ }
+
+ # Compile plugin
+ if [[ -z $ICE[(i)(\!|)(sh|bash|ksh|csh)] ]] {
+ () {
+ emulate -LR zsh
+ setopt extendedglob warncreateglobal
+ if [[ $tpe == snippet ]] {
+ .zi-compile-plugin "%$dir" ""
+ } else {
+ .zi-compile-plugin "$id_as" ""
+ }
+
}
+ }
} # ]]]
# FUNCTION: ∞zi-atpull-e-hook [[[
∞zi-atpull-e-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- [[ $ICE[atpull] = "!"* ]] && .zi-countdown atpull && { local ___oldcd=$PWD; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$dir"; } && .zi-at-eval "${ICE[atpull]#\!}" "$ICE[atclone]"; ((1)); } || .zi-at-eval "${ICE[atpull]#\!}" "$ICE[atclone]"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; };}
+ (( ${+ICE[atpull]} )) || return 0
+ [[ -n ${ICE[atpull]} ]] || return 0
+ [[ $ICE[atpull] == "!"* ]] || return 0
+ [[ "$1" = plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+ local atpull=${ICE[atpull]#\!}
+ local rc=0
+ .zi-countdown atpull && {
+ local ___oldcd=$PWD
+ (( ${+ICE[nocd]} == 0 )) && {
+ () { setopt localoptions noautopushd; builtin cd -q "$dir"; }
+ }
+ .zi-at-eval "$atpull" "$ICE[atclone]"
+ rc="$?"
+ () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; };
+ }
+ return "$rc"
} # ]]]
# FUNCTION: ∞zi-atpull-hook [[[
∞zi-atpull-hook() {
- [[ "$1" = plugin ]] && \
- local dir="${5#%}" hook="$6" subtype="$7" || \
- local dir="${4#%}" hook="$5" subtype="$6"
-
- [[ -n $ICE[atpull] && $ICE[atpull] != "!"* ]] && .zi-countdown atpull && { local ___oldcd=$PWD; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$dir"; } && .zi-at-eval "$ICE[atpull]" "$ICE[atclone]"; ((1)); } || .zi-at-eval "${ICE[atpull]#!}" $ICE[atclone]; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; };}
+ (( ${+ICE[atpull]} )) || return 0
+ [[ -n ${ICE[atpull]} ]] || return 0
+ [[ $ICE[atpull] == "!"* ]] && return 0
+ [[ "$1" == plugin ]] && \
+ local dir="${5#%}" hook="$6" subtype="$7" || \
+ local dir="${4#%}" hook="$5" subtype="$6"
+ local atpull=${ICE[atpull]}
+ local rc=0
+ .zi-countdown atpull && {
+ local ___oldcd=$PWD
+ (( ${+ICE[nocd]} == 0 )) && {
+ () { setopt localoptions noautopushd; builtin cd -q "$dir"; }
+ }
+ .zi-at-eval "$atpull" $ICE[atclone]
+ rc="$?"
+ () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; };
+ }
+ return "$rc"
} # ]]]
# FUNCTION: ∞zi-ps-on-update-hook [[[
∞zi-ps-on-update-hook() {
- if [[ -z $ICE[ps-on-update] ]] { return 1; }
-
- [[ "$1" = plugin ]] && \
- local tpe="$1" dir="${5#%}" hook="$6" subtype="$7" || \
- local tpe="$1" dir="${4#%}" hook="$5" subtype="$6"
+[[ -z $ICE[ps-on-update] ]] && return 0
+ [[ "$1" = plugin ]] && \
+ local tpe="$1" dir="${5#%}" hook="$6" subtype="$7" || \
+ local tpe="$1" dir="${4#%}" hook="$5" subtype="$6"
- if (( !OPTS[opt_-q,--quiet] )) {
- +zi-message "Running $tpe's provided update code: {info}${ICE[ps-on-update][1,50]}${ICE[ps-on-update][51]:+…}{rst}"
- (
- builtin cd -q "$dir" || return 1
- eval "$ICE[ps-on-update]"
- )
- } else {
- (
- builtin cd -q "$dir" || return 1
- eval "$ICE[ps-on-update]" &> /dev/null
- )
- }
+ if (( !OPTS[opt_-q,--quiet] )) {
+ +zi-message "Running $tpe's provided update code: {info}${ICE[ps-on-update][1,50]}${ICE[ps-on-update][51]:+…}{rst}"
+ (
+ builtin cd -q "$dir" || return 1
+ eval "$ICE[ps-on-update]"
+ )
+ } else {
+ (
+ builtin cd -q "$dir" || return 1
+ eval "$ICE[ps-on-update]" &> /dev/null
+ )
+ }
} # ]]]
diff --git a/lib/zsh/side.zsh b/lib/zsh/side.zsh
index c6636e17..59eb6f7f 100755
--- a/lib/zsh/side.zsh
+++ b/lib/zsh/side.zsh
@@ -9,156 +9,137 @@
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-exists-physically() {
- .zi-any-to-user-plugin "$1" "$2"
- if [[ ${reply[-2]} = % ]]; then
- [[ -d ${reply[-1]} ]] && \
- return 0 || \
- return 1
- else
- [[ -d ${ZI[PLUGINS_DIR]}/${reply[-2]:+${reply[-2]}---}${reply[-1]//\//---} ]] && \
- return 0 || \
- return 1
- fi
+ .zi-any-to-user-plugin "$1" "$2"
+ if [[ ${reply[-2]} = % ]]; then
+ [[ -d ${reply[-1]} ]] && return 0 || return 1
+ else
+ [[ -d ${ZI[PLUGINS_DIR]}/${reply[-2]:+${reply[-2]}---}${reply[-1]//\//---} ]] && return 0 || return 1
+ fi
} # ]]]
# FUNCTION: .zi-exists-physically-message [[[
-# Checks if directory of given plugin exists in PLUGIN_DIR,
-# and outputs error message if it doesn't.
+# Checks if directory of given plugin exists in PLUGIN_DIR, and outputs error message if it doesn't.
#
# Testable.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-exists-physically-message() {
- builtin emulate -LR zsh
- builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
- if ! .zi-exists-physically "$1" "$2"; then
- .zi-any-to-user-plugin "$1" "$2"
- if [[ $reply[1] = % ]] {
- .zi-any-to-pid "$1" "$2"
- local spec1=$REPLY
- if [[ $1 = %* ]] {
- local spec2=%${1#%}${${1#%}:+${2:+/}}$2
- } elif [[ -z $1 || -z $2 ]] {
- local spec3=%${1#%}${2#%}
- }
- } else {
- integer nospec=1
- }
- .zi-any-colorify-as-uspl2 "$1" "$2"
+ builtin emulate -LR zsh
+ builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
+ if ! .zi-exists-physically "$1" "$2"; then
+ .zi-any-to-user-plugin "$1" "$2"
+ if [[ $reply[1] = % ]] {
+ .zi-any-to-pid "$1" "$2"
+ local spec1=$REPLY
+ if [[ $1 = %* ]] {
+ local spec2=%${1#%}${${1#%}:+${2:+/}}$2
+ } elif [[ -z $1 || -z $2 ]] {
+ local spec3=%${1#%}${2#%}
+ }
+ } else {
+ integer nospec=1
+ }
+ .zi-any-colorify-as-uspl2 "$1" "$2"
- +zi-message "{error}No such (plugin or snippet){rst}: $REPLY."
- [[ $nospec -eq 0 && $spec1 != $spec2 ]] && \
- +zi-message "(expands to: {file}${spec2#%}{rst})."
- return 1
- fi
- return 0
+ +zi-message "{error}No such (plugin or snippet){rst}: $REPLY."
+ [[ $nospec -eq 0 && $spec1 != $spec2 ]] && +zi-message "(expands to: {file}${spec2#%}{rst})."
+ return 1
+ fi
+ return 0
} # ]]]
# FUNCTION: .zi-first [[[
-# Finds the main file of plugin. There are multiple file name
-# formats, they are ordered in order starting from more correct
-# ones, and matched. .zi-load-plugin() has similar code parts
-# and doesn't call .zi-first() – for performance. Obscure matching
-# is done in .zi-find-other-matches, here and in .zi-load().
-# Obscure = non-standard main-file naming convention.
+# Finds the main file of plugin. There are multiple file name formats, they are ordered in order starting from more correct
+# ones, and matched. .zi-load-plugin() has similar code parts and doesn't call .zi-first() – for performance. Obscure matching
+# is done in .zi-find-other-matches, here and in .zi-load(). Obscure = non-standard main-file naming convention.
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
.zi-first() {
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}"
-
- .zi-any-to-pid "$1" "$2"
- .zi-get-object-path plugin "$REPLY"
- integer ret=$?
- local dname="$REPLY"
- (( ret )) && { reply=( "$dname" "" ); return 1; }
-
- # Look for file to compile. First look for the most common one
- # (optimization) then for other possibilities
- if [[ -e "$dname/$plugin.plugin.zsh" ]]; then
- reply=( "$dname/$plugin.plugin.zsh" )
- else
- .zi-find-other-matches "$dname" "$plugin"
- fi
-
- if [[ "${#reply}" -eq "0" ]]; then
- reply=( "$dname" "" )
- return 1
- fi
-
- # Take first entry (ksharrays resilience)
- reply=( "$dname" "${reply[-${#reply}]}" )
- return 0
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}"
+
+ .zi-any-to-pid "$1" "$2"
+ .zi-get-object-path plugin "$REPLY"
+ integer ret=$?
+ local dname="$REPLY"
+ (( ret )) && { reply=( "$dname" "" ); return 1; }
+ # Look for file to compile. First look for the most common one
+ # (optimization) then for other possibilities
+ if [[ -e "$dname/$plugin.plugin.zsh" ]]; then
+ reply=( "$dname/$plugin.plugin.zsh" )
+ else
+ .zi-find-other-matches "$dname" "$plugin"
+ fi
+ if [[ "${#reply}" -eq "0" ]]; then
+ reply=( "$dname" "" )
+ return 1
+ fi
+ # Take first entry (ksharrays resilience)
+ reply=( "$dname" "${reply[-${#reply}]}" )
+ return 0
} # ]]]
# FUNCTION: .zi-any-colorify-as-uspl2 [[[
-# Returns ANSI-colorified "user/plugin" string, from any supported
-# plugin spec (user---plugin, user/plugin, user plugin, plugin).
+# Returns ANSI-colorified "user/plugin" string, from any supported plugin spec (user---plugin, user/plugin, user plugin, plugin).
#
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given)
# $REPLY = ANSI-colorified "user/plugin" string
.zi-any-colorify-as-uspl2() {
- .zi-any-to-user-plugin "$1" "$2"
- local user="${reply[-2]}" plugin="${reply[-1]}"
- if [[ "$user" = "%" ]] {
- .zi-any-to-pid "" $plugin
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--plugins--/OMZP::}"
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--plugins/OMZP}"
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--lib--/OMZL::}"
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--lib/OMZL}"
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--themes--/OMZT::}"
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--themes/OMZT}"
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--/OMZ::}"
- REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk/OMZ}"
- REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--modules--/PZTM::}"
- REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--modules/PZTM}"
- REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--/PZT::}"
- REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk/PZT}"
- REPLY="${REPLY/(#b)%([A-Z]##)(#c0,1)(*)/%$ZI[col-uname]$match[1]$ZI[col-pname]$match[2]$ZI[col-rst]}"
- } elif [[ $user == http(|s): ]] {
- REPLY="${ZI[col-ice]}${user}/${plugin}${ZI[col-rst]}"
- } else {
- REPLY="${user:+${ZI[col-uname]}${user}${ZI[col-rst]}/}${ZI[col-pname]}${plugin}${ZI[col-rst]}"
- }
+ .zi-any-to-user-plugin "$1" "$2"
+ local user="${reply[-2]}" plugin="${reply[-1]}"
+ if [[ "$user" = "%" ]] {
+ .zi-any-to-pid "" $plugin
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--plugins--/OMZP::}"
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--plugins/OMZP}"
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--lib--/OMZL::}"
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--lib/OMZL}"
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--themes--/OMZT::}"
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--themes/OMZT}"
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk--/OMZ::}"
+ REPLY="${REPLY/https--github.com--(robbyrussell--oh-my-zsh|ohmyzsh--ohmyzsh)--trunk/OMZ}"
+ REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--modules--/PZTM::}"
+ REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--modules/PZTM}"
+ REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk--/PZT::}"
+ REPLY="${REPLY/https--github.com--sorin-ionescu--prezto--trunk/PZT}"
+ REPLY="${REPLY/(#b)%([A-Z]##)(#c0,1)(*)/%$ZI[col-uname]$match[1]$ZI[col-pname]$match[2]$ZI[col-rst]}"
+ } elif [[ $user == http(|s): ]] {
+ REPLY="${ZI[col-ice]}${user}/${plugin}${ZI[col-rst]}"
+ } else {
+ REPLY="${user:+${ZI[col-uname]}${user}${ZI[col-rst]}/}${ZI[col-pname]}${plugin}${ZI[col-rst]}"
+ }
} # ]]]
# FUNCTION: .zi-two-paths [[[
-# Obtains a snippet URL without specification if it is an SVN URL (points to
-# directory) or regular URL (points to file), returns 2 possible paths for
-# further examination
+# Obtains a snippet URL without specification if it is an SVN URL (points to directory) or regular URL (points to file),
+# returns 2 possible paths for further examination
.zi-two-paths() {
- emulate -LR zsh
- setopt extendedglob typesetsilent warncreateglobal noshortloops
-
- local url=$1 url1 url2 local_dirA dirnameA svn_dirA \
- local_dirB dirnameB
- local -a fileB_there
-
- # Remove leading whitespace and trailing /
- url="${${url#"${url%%[! $'\t']*}"}%/}"
- url1=$url url2=$url
-
- .zi-get-object-path snippet "$url1"
- local_dirA=$reply[-3] dirnameA=$reply[-2]
- [[ -d "$local_dirA/$dirnameA/.svn" ]] && {
- svn_dirA=".svn"
- if { .zi-first % "$local_dirA/$dirnameA"; } {
- fileB_there=( ${reply[-1]} )
- }
+ emulate -LR zsh
+ setopt extendedglob typesetsilent warncreateglobal noshortloops
+
+ local url=$1 url1 url2 local_dirA dirnameA svn_dirA local_dirB dirnameB
+ local -a fileB_there
+ # Remove leading whitespace and trailing /
+ url="${${url#"${url%%[! $'\t']*}"}%/}"
+ url1=$url url2=$url
+
+ .zi-get-object-path snippet "$url1"
+ local_dirA=$reply[-3] dirnameA=$reply[-2]
+ [[ -d "$local_dirA/$dirnameA/.svn" ]] && {
+ svn_dirA=".svn"
+ if { .zi-first % "$local_dirA/$dirnameA"; } {
+ fileB_there=( ${reply[-1]} )
}
+ }
- .zi-get-object-path snippet "$url2"
- local_dirB=$reply[-3] dirnameB=$reply[-2]
- [[ -z $svn_dirA ]] && \
- fileB_there=( "$local_dirB/$dirnameB"/*~*.(zwc|md|js|html)(.-DOnN[1]) )
-
- reply=( "$local_dirA/$dirnameA" "$svn_dirA" "$local_dirB/$dirnameB" "${fileB_there[1]##$local_dirB/$dirnameB/#}" )
-}
-# ]]]
+ .zi-get-object-path snippet "$url2"
+ local_dirB=$reply[-3] dirnameB=$reply[-2]
+ [[ -z $svn_dirA ]] && \
+ fileB_there=( "$local_dirB/$dirnameB"/*~*.(zwc|md|js|html)(.-DOnN[1]) )
+ reply=( "$local_dirA/$dirnameA" "$svn_dirA" "$local_dirB/$dirnameB" "${fileB_there[1]##$local_dirB/$dirnameB/#}" )
+} # ]]]
# FUNCTION: .zi-compute-ice [[[
-# Computes ICE array (default, it can be specified via $3) from a) input
-# ICE, b) static ice, c) saved ice, taking priorities into account. Also
-# returns path to snippet directory and optional name of snippet file (only
-# valid if ICE[svn] is not set).
+# Computes ICE array (default, it can be specified via $3) from a) input ICE, b) static ice, c) saved ice,
+# taking priorities into account. Also returns path to snippet directory and optional name of snippet file
+# (only valid if ICE[svn] is not set).
#
# Can also pack resulting ices into ZI_SICE (see $2).
#
@@ -171,168 +152,144 @@
# $5 - name of output string parameter, to hold filename ("filename")
# $6 - name of output string parameter, to hold is-snippet 0/1-bool ("is_snippet")
.zi-compute-ice() {
- emulate -LR zsh
- setopt extendedglob typesetsilent warncreateglobal noshortloops
-
- local ___URL="${1%/}" ___pack="$2" ___is_snippet=0
- local ___var_name1="${3:-ZI_ICE}" ___var_name2="${4:-local_dir}" \
- ___var_name3="${5:-filename}" ___var_name4="${6:-is_snippet}"
-
- # Copy from .zi-recall
- local -a ice_order nval_ices
- ice_order=(
- ${(s.|.)ZI[ice-list]}
-
- # Include all additional ices – after
- # stripping them from the possible: ''
- ${(@)${(@Akons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
- )
- nval_ices=(
- ${(s.|.)ZI[nval-ice-list]}
-
- # Include only those additional ices,
- # don't have the '' in their name, i.e.
- # aren't designed to hold value
- ${(@)${(@)${(@Akons:|:)ZI_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/}
-
- # Must be last
- svn
- )
-
- # Remove whitespace from beginning of URL
- ___URL="${${___URL#"${___URL%%[! $'\t']*}"}%/}"
-
- # Snippet?
- .zi-two-paths "$___URL"
- local ___s_path="${reply[-4]}" ___s_svn="${reply[-3]}" ___path="${reply[-2]}" ___filename="${reply[-1]}" ___local_dir
- if [[ -d "$___s_path" || -d "$___path" ]]; then
- ___is_snippet=1
- else
- # Plugin
- .zi-any-to-user-plugin "$___URL" ""
- local ___user="${reply[-2]}" ___plugin="${reply[-1]}"
- ___s_path="" ___filename=""
- [[ "$___user" = "%" ]] && ___path="$___plugin" || ___path="${ZI[PLUGINS_DIR]}/${___user:+${___user}---}${___plugin//\//---}"
- .zi-exists-physically-message "$___user" "$___plugin" || return 1
+ emulate -LR zsh
+ setopt extendedglob typesetsilent warncreateglobal noshortloops
+
+ local ___URL="${1%/}" ___pack="$2" ___is_snippet=0
+ local ___var_name1="${3:-ZI_ICE}" ___var_name2="${4:-local_dir}" ___var_name3="${5:-filename}" ___var_name4="${6:-is_snippet}"
+ # Copy from .zi-recall
+ local -a ice_order nval_ices
+ ice_order=(
+ ${(s.|.)ZI[ice-list]}
+ # Include all additional ices – after stripping them from the possible: ''
+ ${(@)${(@Akons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
+ )
+ nval_ices=(
+ ${(s.|.)ZI[nval-ice-list]}
+ # Include only those additional ices, don't have the '' in their name, i.e aren't designed to hold value
+ ${(@)${(@)${(@Akons:|:)ZI_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/}
+ # Must be last
+ svn
+ )
+ # Remove whitespace from beginning of URL
+ ___URL="${${___URL#"${___URL%%[! $'\t']*}"}%/}"
+ # Snippet?
+ .zi-two-paths "$___URL"
+ local ___s_path="${reply[-4]}" ___s_svn="${reply[-3]}" ___path="${reply[-2]}" ___filename="${reply[-1]}" ___local_dir
+ if [[ -d "$___s_path" || -d "$___path" ]]; then
+ ___is_snippet=1
+ else
+ # Plugin
+ .zi-any-to-user-plugin "$___URL" ""
+ local ___user="${reply[-2]}" ___plugin="${reply[-1]}"
+ ___s_path="" ___filename=""
+ [[ "$___user" = "%" ]] && ___path="$___plugin" || ___path="${ZI[PLUGINS_DIR]}/${___user:+${___user}---}${___plugin//\//---}"
+ .zi-exists-physically-message "$___user" "$___plugin" || return 1
+ fi
+ [[ $___pack = pack* ]] && (( ${#ICE} > 0 )) && .zi-pack-ice "${___user-$___URL}" "$___plugin"
+ local -A ___sice
+ local -a ___tmp
+ ___tmp=( "${(z@)ZI_SICE[${___user-$___URL}${${___user:#(%|/)*}:+/}$___plugin]}" )
+ (( ${#___tmp[@]} > 1 && ${#___tmp[@]} % 2 == 0 )) && ___sice=( "${(Q)___tmp[@]}" )
+
+ if [[ "${+___sice[svn]}" = "1" || -n "$___s_svn" ]]; then
+ if (( !___is_snippet && ${+___sice[svn]} == 1 )); then
+ builtin print -r -- "The \`svn' ice is given, but the argument ($___URL) is a plugin"
+ builtin print -r -- "(\`svn' can be used only with snippets)"
+ return 1
+ elif (( !___is_snippet )); then
+ builtin print -r -- "Undefined behavior #1 occurred, please report at https://github.com/z-shell/zi/issues"
+ return 1
fi
-
- [[ $___pack = pack* ]] && (( ${#ICE} > 0 )) && \
- .zi-pack-ice "${___user-$___URL}" "$___plugin"
-
- local -A ___sice
- local -a ___tmp
- ___tmp=( "${(z@)ZI_SICE[${___user-$___URL}${${___user:#(%|/)*}:+/}$___plugin]}" )
- (( ${#___tmp[@]} > 1 && ${#___tmp[@]} % 2 == 0 )) && ___sice=( "${(Q)___tmp[@]}" )
-
- if [[ "${+___sice[svn]}" = "1" || -n "$___s_svn" ]]; then
- if (( !___is_snippet && ${+___sice[svn]} == 1 )); then
- builtin print -r -- "The \`svn' ice is given, but the argument ($___URL) is a plugin"
- builtin print -r -- "(\`svn' can be used only with snippets)"
- return 1
- elif (( !___is_snippet )); then
- builtin print -r -- "Undefined behavior #1 occurred, please report at https://github.com/z-shell/zi/issues"
- return 1
- fi
- if [[ -e "$___s_path" && -n "$___s_svn" ]]; then
- ___sice[svn]=""
- ___local_dir="$___s_path"
- else
- [[ ! -e "$___path" ]] && { builtin print -r -- "No such snippet, looked at paths (1): $___s_path, and: $___path"; return 1; }
- unset '___sice[svn]'
- ___local_dir="$___path"
- fi
+ if [[ -e "$___s_path" && -n "$___s_svn" ]]; then
+ ___sice[svn]=""
+ ___local_dir="$___s_path"
else
- if [[ -e "$___path" ]]; then
- unset '___sice[svn]'
- ___local_dir="$___path"
- else
- builtin print -r -- "No such snippet, looked at paths (2): $___s_path, and: $___path"
- return 1
- fi
+ [[ ! -e "$___path" ]] && { builtin print -r -- "No such snippet, looked at paths (1): $___s_path, and: $___path"; return 1; }
+ unset '___sice[svn]'
+ ___local_dir="$___path"
fi
-
- local ___zi_path="$___local_dir/._zi"
-
- # Rename Zplugin > ZI
- if [[ ! -d $___zi_path && -d $___local_dir/._zplugin ]]; then
- (
- builtin print -Pr -- "${ZI[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" \
- "FOR THE ZPLUGIN -> ZI RENAME…%f"
- builtin cd -q ${ZI[PLUGINS_DIR]} || return 1
- autoload -Uz zmv
- ( zmv -W '**/._zplugin' '**/._zi' ) &>/dev/null
- builtin cd -q ${ZI[SNIPPETS_DIR]} || return 1
- ( zmv -W '**/._zplugin' '**/._zi' ) &>/dev/null
- builtin print -Pr -- "${ZI[col-obj]}THE UPGRADE SUCCEDED!%f"
- ) || builtin print -Pr -- "${ZI[col-error]}THE UPGRADE FAILED!%f"
+ else
+ if [[ -e "$___path" ]]; then
+ unset '___sice[svn]'
+ ___local_dir="$___path"
+ else
+ builtin print -r -- "No such snippet, looked at paths (2): $___s_path, and: $___path"
+ return 1
fi
-
- # Rename Zinit > ZI
- if [[ ! -d $___zi_path && -d $___local_dir/._zinit ]]; then
- (
- builtin print -Pr -- "${ZI[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" \
- "FOR THE ZI -> ZI RENAME…%f"
- builtin cd -q ${ZI[PLUGINS_DIR]} || return 1
- autoload -Uz zmv
- ( zmv -W '**/.zinit' '**/._zi' ) &>/dev/null
- builtin cd -q ${ZI[SNIPPETS_DIR]} || return 1
- ( zmv -W '**/._zinit' '**/._zi' ) &>/dev/null
- builtin print -Pr -- "${ZI[col-obj]}THE UPGRADE SUCCEDED!%f"
- ) || builtin print -Pr -- "${ZI[col-error]}THE UPGRADE FAILED!%f"
+ fi
+
+ local ___zi_path="$___local_dir/._zi"
+
+ # Rename Zplugin > ZI
+ if [[ ! -d $___zi_path && -d $___local_dir/._zplugin ]]; then
+ (
+ builtin print -Pr -- "${ZI[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" "FOR THE ZPLUGIN -> ZI RENAME…%f"
+ builtin cd -q ${ZI[PLUGINS_DIR]} || return 1
+ autoload -Uz zmv
+ ( zmv -W '**/._zplugin' '**/._zi' ) &>/dev/null
+ builtin cd -q ${ZI[SNIPPETS_DIR]} || return 1
+ ( zmv -W '**/._zplugin' '**/._zi' ) &>/dev/null
+ builtin print -Pr -- "${ZI[col-obj]}THE UPGRADE SUCCEDED!%f"
+ ) || builtin print -Pr -- "${ZI[col-error]}THE UPGRADE FAILED!%f"
+ fi
+
+ # Rename Zinit > ZI
+ if [[ ! -d $___zi_path && -d $___local_dir/._zinit ]]; then
+ (
+ builtin print -Pr -- "${ZI[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" "FOR THE ZI -> ZI RENAME…%f"
+ builtin cd -q ${ZI[PLUGINS_DIR]} || return 1
+ autoload -Uz zmv
+ ( zmv -W '**/.zinit' '**/._zi' ) &>/dev/null
+ builtin cd -q ${ZI[SNIPPETS_DIR]} || return 1
+ ( zmv -W '**/._zinit' '**/._zi' ) &>/dev/null
+ builtin print -Pr -- "${ZI[col-obj]}THE UPGRADE SUCCEDED!%f"
+ ) || builtin print -Pr -- "${ZI[col-error]}THE UPGRADE FAILED!%f"
+ fi
+
+ # Read disk-Ice
+ local -A ___mdata
+ local ___key
+ { for ___key in mode url is_release is_release{2..5} ${ice_order[@]}; do
+ [[ -f "$___zi_path/$___key" ]] && ___mdata[$___key]="$(<$___zi_path/$___key)"
+ done
+ [[ "${___mdata[mode]}" = "1" ]] && ___mdata[svn]=""
+ } 2>/dev/null
+ # Handle flag-Ices; svn must be last
+ for ___key in ${ice_order[@]}; do
+ [[ $___key == (no|)compile ]] && continue
+ (( 0 == ${+ICE[no$___key]} && 0 == ${+___sice[no$___key]} )) && continue
+ # "If there is such ice currently, and there's no no* ice given, and there's the no* ice in the static ice" – skip, don't unset.
+ # With conjunction with the previous line this has the proper meaning: uset if at least in one – current or static – ice
+ # there's the no* ice, but not if it's only in the static ice (unless there's on such ice "anyway").
+ (( 1 == ${+ICE[$___key]} && 0 == ${+ICE[no$___key]} && 1 == ${+___sice[no$___key]} )) && continue
+ if [[ "$___key" = "svn" ]]; then
+ command builtin print -r -- "0" >! "$___zi_path/mode"
+ ___mdata[mode]=0
+ else
+ command rm -f -- "$___zi_path/$___key"
fi
-
- # Read disk-Ice
- local -A ___mdata
- local ___key
- { for ___key in mode url is_release is_release{2..5} ${ice_order[@]}; do
- [[ -f "$___zi_path/$___key" ]] && ___mdata[$___key]="$(<$___zi_path/$___key)"
- done
- [[ "${___mdata[mode]}" = "1" ]] && ___mdata[svn]=""
- } 2>/dev/null
-
- # Handle flag-Ices; svn must be last
- for ___key in ${ice_order[@]}; do
- [[ $___key == (no|)compile ]] && continue
- (( 0 == ${+ICE[no$___key]} && 0 == ${+___sice[no$___key]} )) && continue
- # "If there is such ice currently, and there's no no* ice given,
- # and there's the no* ice in the static ice" – skip, don't unset.
- # With conjunction with the previous line this has the proper
- # meaning: uset if at least in one – current or static – ice
- # there's the no* ice, but not if it's only in the static ice
- # (unless there's on such ice "anyway").
- (( 1 == ${+ICE[$___key]} && 0 == ${+ICE[no$___key]} && \
- 1 == ${+___sice[no$___key]} )) && continue
-
- if [[ "$___key" = "svn" ]]; then
- command builtin print -r -- "0" >! "$___zi_path/mode"
- ___mdata[mode]=0
- else
- command rm -f -- "$___zi_path/$___key"
- fi
- unset "___mdata[$___key]" "___sice[$___key]" "ICE[$___key]"
- done
-
- # Final decision, static ice vs. saved ice
- local -A ___MY_ICE
- for ___key in mode url is_release is_release{2..5} ${ice_order[@]}; do
- # The second sum is: if the pack is *not* pack-nf, then depending
- # on the disk availability, otherwise: no disk ice
- (( ${+___sice[$___key]} + ${${${___pack:#pack-nf*}:+${+___mdata[$___key]}}:-0} )) && ___MY_ICE[$___key]="${___sice[$___key]-${___mdata[$___key]}}"
- done
- # One more round for the special case – update, which ALWAYS
- # needs the teleid from the disk or static ice
- ___key=teleid; [[ "$___pack" = pack-nftid ]] && {
- (( ${+___sice[$___key]} + ${+___mdata[$___key]} )) && ___MY_ICE[$___key]="${___sice[$___key]-${___mdata[$___key]}}"
- }
-
- : ${(PA)___var_name1::="${(kv)___MY_ICE[@]}"}
- : ${(P)___var_name2::=$___local_dir}
- : ${(P)___var_name3::=$___filename}
- : ${(P)___var_name4::=$___is_snippet}
-
- return 0
-}
-# ]]]
+ unset "___mdata[$___key]" "___sice[$___key]" "ICE[$___key]"
+ done
+
+ # Final decision, static ice vs. saved ice
+ local -A ___MY_ICE
+ for ___key in mode url is_release is_release{2..5} ${ice_order[@]}; do
+ # The second sum is: if the pack is *not* pack-nf, then depending on the disk availability, otherwise: no disk ice
+ (( ${+___sice[$___key]} + ${${${___pack:#pack-nf*}:+${+___mdata[$___key]}}:-0} )) && ___MY_ICE[$___key]="${___sice[$___key]-${___mdata[$___key]}}"
+ done
+ # One more round for the special case – update, which ALWAYS needs the teleid from the disk or static ice
+ ___key=teleid; [[ "$___pack" = pack-nftid ]] && {
+ (( ${+___sice[$___key]} + ${+___mdata[$___key]} )) && ___MY_ICE[$___key]="${___sice[$___key]-${___mdata[$___key]}}"
+ }
+
+ : ${(PA)___var_name1::="${(kv)___MY_ICE[@]}"}
+ : ${(P)___var_name2::=$___local_dir}
+ : ${(P)___var_name3::=$___filename}
+ : ${(P)___var_name4::=$___is_snippet}
+
+ return 0
+} # ]]]
# FUNCTION: .zi-store-ices [[[
# Saves ice mods in given hash onto disk.
#
@@ -343,73 +300,58 @@
# $5 – the URL, if applicable
# $6 – the mode (1 - svn, 0 - single file), if applicable
.zi-store-ices() {
- local ___pfx="$1" ___ice_var="$2" \
- ___add_ices="$3" ___add_ices2="$4" \
- url="$5" mode="$6"
-
- # Copy from .zi-recall
- local -a ice_order nval_ices
- ice_order=(
- ${(s.|.)ZI[ice-list]}
-
- # Include all additional ices – after
- # stripping them from the possible: ''
- ${(@)${(@Akons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
- )
- nval_ices=(
- ${(s.|.)ZI[nval-ice-list]}
-
- # Include only those additional ices,
- # don't have the '' in their name, i.e.
- # aren't designed to hold value
- ${(@)${(@)${(@Akons:|:)ZI_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/}
-
- # Must be last
- svn
- )
-
- command mkdir -p "$___pfx"
- local ___key ___var_name
- # No nval_ices here
- for ___key in ${ice_order[@]:#(${(~j:|:)nval_ices[@]})} ${(s: :)___add_ices[@]}; do
- ___var_name="${___ice_var}[$___key]"
- (( ${(P)+___var_name} )) && \
- builtin print -r -- "${(P)___var_name}" >! "$___pfx"/"$___key"
- done
-
- # Ices that even empty mean something
- for ___key in ${nval_ices[@]} ${(s: :)___add_ices2[@]}; do
- ___var_name="${___ice_var}[$___key]"
- if (( ${(P)+___var_name} )) {
- builtin print -r -- "${(P)___var_name}" >! "$___pfx"/"$___key"
- } else {
- command rm -f "$___pfx"/"$___key"
- }
- done
-
- # url and mode are declared at the beginning of the body
- for ___key in url mode; do
- [[ -n "${(P)___key}" ]] && builtin print -r -- "${(P)___key}" >! "$___pfx"/"$___key"
- done
-}
-# ]]]
+ local ___pfx="$1" ___ice_var="$2" ___add_ices="$3" ___add_ices2="$4" url="$5" mode="$6"
+ # Copy from .zi-recall
+ local -a ice_order nval_ices
+ ice_order=(
+ ${(s.|.)ZI[ice-list]}
+ # Include all additional ices – after stripping them from the possible: ''
+ ${(@)${(@Akons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
+ )
+ nval_ices=(
+ ${(s.|.)ZI[nval-ice-list]}
+ # Include only those additional ices, don't have the '' in their name, i.e. aren't designed to hold value
+ ${(@)${(@)${(@Akons:|:)ZI_EXTS[ice-mods]}:#*\'\'*}/(#s)<->-/}
+ # Must be last
+ svn
+ )
+ command mkdir -p "$___pfx"
+ local ___key ___var_name
+ # No nval_ices here
+ for ___key in ${ice_order[@]:#(${(~j:|:)nval_ices[@]})} ${(s: :)___add_ices[@]}; do
+ ___var_name="${___ice_var}[$___key]"
+ (( ${(P)+___var_name} )) && builtin print -r -- "${(P)___var_name}" >! "$___pfx"/"$___key"
+ done
+ # Ices that even empty mean something
+ for ___key in ${nval_ices[@]} ${(s: :)___add_ices2[@]}; do
+ ___var_name="${___ice_var}[$___key]"
+ if (( ${(P)+___var_name} )) {
+ builtin print -r -- "${(P)___var_name}" >! "$___pfx"/"$___key"
+ } else {
+ command rm -f "$___pfx"/"$___key"
+ }
+ done
+ # url and mode are declared at the beginning of the body
+ for ___key in url mode; do
+ [[ -n "${(P)___key}" ]] && builtin print -r -- "${(P)___key}" >! "$___pfx"/"$___key"
+ done
+} # ]]]
# FUNCTION: .zi-countdown [[[
# Displays a countdown 5...4... etc. and returns 0 if it
# sucessfully reaches 0, or 1 if Ctrl-C will be pressed.
.zi-countdown() {
- (( !${+ICE[countdown]} )) && return 0
-
- emulate -L zsh -o extendedglob
- trap "+zi-message \"{ehi}ABORTING, the ice {ice}$ice{ehi} not ran{rst}\"; return 1" INT
- local count=5 tpe="$1" ice
- ice="${ICE[$tpe]}"
- [[ $tpe = "atpull" && $ice = "%atclone" ]] && ice="${ICE[atclone]}"
- ice="{b}{ice}$tpe{ehi}:{rst}${ice//(#b)(\{[a-z0-9…–_-]##\})/\\$match[1]}"
- +zi-message -n "{hi}Running $ice{rst}{hi} ice in...{rst} "
- while (( -- count + 1 )) {
- +zi-message -n -- "{b}{error}"$(( count + 1 ))"{rst}{…}"
- sleep 1
- }
- +zi-message -r -- "{b}{error}0 {rst}{…}"
- return 0
+ (( !${+ICE[countdown]} )) && return 0
+ emulate -L zsh -o extendedglob
+ trap "+zi-message \"{ehi}ABORTING, the ice {ice}$ice{ehi} not ran{rst}\"; return 1" INT
+ local count=5 tpe="$1" ice
+ ice="${ICE[$tpe]}"
+ [[ $tpe = "atpull" && $ice = "%atclone" ]] && ice="${ICE[atclone]}"
+ ice="{b}{ice}$tpe{ehi}:{rst}${ice//(#b)(\{[a-z0-9…–_-]##\})/\\$match[1]}"
+ +zi-message -n "{hi}Running $ice{rst}{hi} ice in...{rst} "
+ while (( -- count + 1 )) {
+ +zi-message -n -- "{b}{error}"$(( count + 1 ))"{rst}{…}"
+ sleep 1
+ }
+ +zi-message -r -- "{b}{error}0 {rst}{…}"
+ return 0
} # ]]]
diff --git a/lib/zsh/single-line.zsh b/lib/zsh/single-line.zsh
index 15a06486..e752acc9 100755
--- a/lib/zsh/single-line.zsh
+++ b/lib/zsh/single-line.zsh
@@ -4,16 +4,13 @@ emulate -R zsh
setopt extendedglob warncreateglobal typesetsilent rcquotes noshortloops
local zero=$'\0' r=$'\r' n=$'\n' IFS=
-{ command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r\n/\n\0/' || \
-gstdbuf -o0 gtr '\r\n' '\n\0' || \
-stdbuf -o0 tr '\r\n' '\n\0'; print } 2>/dev/null | \
- while read -r line; do
- if [[ $line == *$zero* ]]; then
- # Unused by cURL (there's no newline after the previous progress bar)
- #print -nr -- $r${(l:COLUMNS:: :):-}$r${line##*$zero}
- print -nr -- $r${(l:COLUMNS:: :):-}$r${line%$zero}
- else
- print -nr -- $r${(l:COLUMNS:: :):-}$r${${line//[$r$n]/}%\%*}${${(M)line%\%}:+%}
- fi
- done
+{ command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r\n/\n\0/' || gstdbuf -o0 gtr '\r\n' '\n\0' || \
+stdbuf -o0 tr '\r\n' '\n\0'; print } 2>/dev/null | while read -r line; do
+ if [[ $line == *$zero* ]]; then
+ # Unused by cURL (there's no newline after the previous progress bar) print -nr -- $r${(l:COLUMNS:: :):-}$r${line##*$zero}
+ print -nr -- $r${(l:COLUMNS:: :):-}$r${line%$zero}
+ else
+ print -nr -- $r${(l:COLUMNS:: :):-}$r${${line//[$r$n]/}%\%*}${${(M)line%\%}:+%}
+ fi
+ done
print
diff --git a/lib/zsh/ztransform b/lib/zsh/ztransform
deleted file mode 100755
index cf4b5b78..00000000
--- a/lib/zsh/ztransform
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/zsh
-# vim:ft=zsh
-
-setopt extendedglob
-
-fpath+=( "${0%/*}" )
-autoload zplg-process-buffer
-
-local name="$1"
-local doc="$(<$name)" token prev_token="" spaces prev_spaces="" next_token next_spaces
-
-local preamble="" fun_name=""
-local -A funs
-
-integer next_fun=0 cur_fun=0 prev_fun=0
-integer depth=0 prev_depth=0 fun_depth=-1 anon_depth=-1 descentff=0 descentfa=0
-
-zplg-process-buffer "$doc" 1
-integer i size="${#ZPLG_PB_WORDS}"
-
-for (( i=1; i<=size; ++ i )); do
- token="${ZPLG_PB_WORDS[i]}"
- spaces="${ZPLG_PB_SPACES[i]}"
- next_token="${ZPLG_PB_WORDS[i+1]}"
- next_spaces="${ZPLG_PB_SPACES[i+1]}"
- cur_fun=0 prev_fun=0 descentff=0 descentfa=0
-
- (( next_fun )) && { next_fun=0 cur_fun=1 prev_fun=0 anon_depth=-1 }
-
- # Explicit future function
- if [[ "$token" = "function" ]]; then
- next_fun=1 cur_fun=0 prev_fun=0 anon_depth=-1
- # Detect function if not already in function
- elif [[ "$token" = "()" && ( "$fun_depth" -lt 0 ) && ( $anon_depth -lt 0 ) ]]; then
- if [[ "$spaces" = *$'\n'* || -z "$prev_token" ]]; then
- next_fun=0 cur_fun=0 prev_fun=0 anon_depth=$depth
- else
- next_fun=0 cur_fun=0 prev_fun=1 anon_depth=-1
- fi
- elif [[ "$token" = "{" ]]; then
- (( ++ depth ))
- elif [[ "$token" = "}" ]]; then
- (( -- depth ))
- fi
-
- if (( cur_fun )); then
- fun_name="$token"
- fun_depth="$depth"
- elif (( prev_fun )); then
- fun_name="$prev_token"
- fun_depth="$depth"
- fi
-
- # Ascent to function - skip '{'
- if (( fun_depth >= 0 && depth == (fun_depth + 1) )) && [[ "$token" = "{" ]]; then
- :
- # In-function
- elif (( fun_depth >= 0 && depth > fun_depth )); then
- if [[ "$token" != [[:space:]]#\#* ]]; then
- funs[$fun_name]+="${spaces}${token}"
- fi
- # Descent from function - skip '}'
- elif (( fun_depth >= 0 && depth == fun_depth && prev_depth == fun_depth + 1 )); then
- descentff=1
- # Descent from anon
- elif (( anon_depth >= 0 && depth == anon_depth && prev_depth == anon_depth + 1 )); then
- descentfa=1
- fi
-
- # Anon function in top-level
- if (( anon_depth >= 0 && fun_depth < 0 )); then
- [[ "$token" != [[:space:]]#\#* ]] && preamble+="${spaces}${token}"
- fi
-
- # Late disable of (anon)
- if (( descentfa )); then
- anon_depth=-1
- elif (( descentff )); then
- fun_name=""
- fun_depth=-1
- # No-function printing
- elif (( next_fun == 0 && cur_fun == 0 && prev_fun == 0 && anon_depth < 0 && fun_depth < 0 )); then
- if [[ "$next_token" != "()" || "$next_spaces" = *$'\n'* ]]; then
- [[ "$token" != [[:space:]]#\#* ]] && preamble+="${spaces}${token}"
- fi
- fi
-
- prev_depth="$depth"
- prev_token="$token"
- prev_spaces="$spaces"
-done
-
-print -r -- "$preamble" >| "preamble.zini"
-
-for fun_name in "${(ko@)funs}"; do
- print -r -- "[${fun_name}"$'\C-A'"fun]"
- print -r -- "${funs[$fun_name]}"
- print -r -- "PLG_END_F"
- print
-done >| "functions.zini"
diff --git a/zi.zsh b/zi.zsh
index f941d970..82c6f350 100755
--- a/zi.zsh
+++ b/zi.zsh
@@ -1,9 +1,6 @@
# Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors.
# Copyright (c) 2021 Salvydas Lukosius and Z-Shell ZI contributors.
-# Adjust the shellcheck fot Zsh compatibility.
-# shellcheck shell=sh disable=SC1073,1072,1050
-
#
# Main state variables.
#
@@ -14,7 +11,6 @@ if (( !${#ZI_TASKS} )) { ZI_TASKS=( "" ); }
# Rename snippets URL -> NAME.
typeset -gAH ZI ZI_SNIPPETS ZI_REPORTS ZI_ICES ZI_SICE ZI_CUR_BIND_MAP ZI_EXTS ZI_EXTS2
typeset -gaH ZI_COMPDEF_REPLAY
-# Compatibility for previous versions.
typeset -gAH ZINIT
ZI=( "${(kv)ZINIT[@]}" "${(kv)ZI[@]}" )
unset ZINIT
@@ -24,71 +20,57 @@ unset ZINIT
#
[[ ! -e ${ZI[BIN_DIR]}/zi.zsh ]] && ZI[BIN_DIR]=
-
-# Respect the plugin standard too.
+# Respect the plugin standard.
ZI[ZERO]="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
[[ ! -o functionargzero || ${options[posixargzero]} = on || ${ZI[ZERO]} != */* ]] && ZI[ZERO]="${(%):-%N}"
-
: ${ZI[BIN_DIR]:="${ZI[ZERO]:h}"}
[[ ${ZI[BIN_DIR]} = \~* ]] && ZI[BIN_DIR]=${~ZI[BIN_DIR]}
-
# Make ZI[BIN_DIR] path absolute.
ZI[BIN_DIR]="${${(M)ZI[BIN_DIR]:#/*}:-$PWD/${ZI[BIN_DIR]}}"
-
# Final test of ZI[BIN_DIR].
if [[ ! -e ${ZI[BIN_DIR]}/zi.zsh ]]; then
- builtin print -P "%F{196}Could not establish ZI[BIN_DIR] hash field. It should point where ZI's Git repository is.%f"
- return 1
+ builtin print -P "%F{196}Could not establish ZI[BIN_DIR] hash field. It should point where ❮ ZI ❯ Git repository is.%f"
+ return 1
fi
-# Allow to override ZI[HOME_DIR].
-if [[ -d $HOME/.zi ]]; then
- ZI[HOME_DIR]="$HOME/.zi"
-elif [[ -d ${ZDOTDIR:-$HOME}/.zi ]]; then
- ZI[HOME_DIR]="${ZDOTDIR:-$HOME}/.zi"
-elif [[ -d $HOME/.zinit ]]; then
- ZI[HOME_DIR]="$HOME/.zinit"
-elif [[ -d ${ZDOTDIR:-$HOME}/.zinit ]]; then
- ZI[HOME_DIR]="${ZDOTDIR:-$HOME}/.zinit"
-elif [[ -d $HOME/.zplugin ]]; then
- ZI[HOME_DIR]="$HOME/.zplugin"
-elif [[ -d ${ZDOTDIR:-$HOME}/.zplugin ]]; then
- ZI[HOME_DIR]="${ZDOTDIR:-$HOME}/.zplugin"
- else
- ZI[HOME_DIR]="${ZDOTDIR:-$HOME}/.zi"
+if [[ -z ${ZI[HOME_DIR]} ]]; then
+ if [[ -d ${HOME}/.zi ]]; then
+ ZI[HOME_DIR]="${HOME}/.zi"
+ elif [[ -d ${ZDOTDIR:-$HOME}/.zi ]]; then
+ ZI[HOME_DIR]="${ZDOTDIR:-$HOME}/.zi"
+ elif [[ -d ${XDG_DATA_HOME:-$HOME}/.zi ]]; then
+ ZI[HOME_DIR]="${XDG_DATA_HOME:-$HOME}/.zi"
+ else
+ ZI[HOME_DIR]="${XDG_DATA_HOME:-$HOME}/.zi"
+ fi
fi
-ZI[ice-list]="svn|proto|from|teleid|bindmap|cloneopts|id-as|depth|if|wait|load|\
-unload|blockf|pick|bpick|src|as|ver|silent|lucid|notify|mv|cp|\
-atinit|atclone|atload|atpull|nocd|run-atpull|has|cloneonly|make|\
-service|trackbinds|multisrc|compile|nocompile|nocompletions|\
-reset-prompt|wrap|reset|sh|\!sh|bash|\!bash|ksh|\!ksh|csh|\
-\!csh|aliases|countdown|ps-on-unload|ps-on-update|trigger-load|\
-light-mode|is-snippet|atdelete|pack|git|verbose|on-update-of|\
-subscribe|extract|param|opts|autoload|subst|install|pullopts|\
-debug|null|binary"
-ZI[nval-ice-list]="blockf|silent|lucid|trackbinds|cloneonly|nocd|run-atpull|\
-nocompletions|sh|\!sh|bash|\!bash|ksh|\!ksh|csh|\!csh|\
-aliases|countdown|light-mode|is-snippet|git|verbose|cloneopts|\
-pullopts|debug|null|binary|make|nocompile|notify|reset"
+ZI[ice-list]="svn|proto|from|teleid|bindmap|cloneopts|id-as|depth|if|wait|load|unload|blockf|pick|bpick|src|as|\
+ver|silent|lucid|notify|mv|cp|atinit|atclone|atload|atpull|nocd|run-atpull|has|cloneonly|make|service|trackbinds|\
+multisrc|compile|nocompile|nocompletions|reset-prompt|wrap|reset|sh|\!sh|bash|\!bash|ksh|\!ksh|csh|\!csh|aliases|\
+countdown|ps-on-unload|ps-on-update|trigger-load|light-mode|is-snippet|atdelete|pack|git|verbose|on-update-of|\
+subscribe|extract|param|opts|autoload|subst|install|pullopts|debug|null|binary"
+ZI[nval-ice-list]="blockf|silent|lucid|trackbinds|cloneonly|nocd|run-atpull|nocompletions|sh|\!sh|bash|\!bash|\
+ksh|\!ksh|csh|\!csh|aliases|countdown|light-mode|is-snippet|git|verbose|cloneopts|pullopts|debug|null|binary|make|\
+nocompile|notify|reset"
# Allow overwrite.
: ${ZI[PLUGINS_DIR]:=${ZI[HOME_DIR]}/plugins}
-: ${ZI[COMPLETIONS_DIR]:=${ZI[HOME_DIR]}/completions}
: ${ZI[SNIPPETS_DIR]:=${ZI[HOME_DIR]}/snippets}
: ${ZI[SERVICES_DIR]:=${ZI[HOME_DIR]}/services}
: ${ZI[ZMODULES_DIR]:=${ZI[HOME_DIR]}/zmodules}
+: ${ZI[COMPLETIONS_DIR]:=${ZI[HOME_DIR]}/completions}
typeset -g ZPFX
: ${ZPFX:=${ZI[HOME_DIR]}/polaris}
-: ${ZI[ALIASES_OPT]::=${${options[aliases]:#off}:+1}}
: ${ZI[MAN_DIR]:=${ZPFX}/man}
+: ${ZI[ALIASES_OPT]::=${${options[aliases]:#off}:+1}}
ZI[PLUGINS_DIR]=${~ZI[PLUGINS_DIR]} ZI[COMPLETIONS_DIR]=${~ZI[COMPLETIONS_DIR]} ZI[SNIPPETS_DIR]=${~ZI[SNIPPETS_DIR]}
ZI[SERVICES_DIR]=${~ZI[SERVICES_DIR]} ZI[ZMODULES_DIR]=${~ZI[ZMODULES_DIR]}
+
export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/zi}" PMSPEC=0uUpiPsf
[[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" )
[[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" )
-# Add completions directory to fpath.
[[ -z ${fpath[(re)${ZI[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZI[COMPLETIONS_DIR]}" "${fpath[@]}" )
[[ ! -d $ZSH_CACHE_DIR ]] && command mkdir -p "$ZSH_CACHE_DIR"
[[ -n ${ZI[ZCOMPDUMP_PATH]} ]] && ZI[ZCOMPDUMP_PATH]=${~ZI[ZCOMPDUMP_PATH]}
@@ -109,89 +91,74 @@ ZI[TMP_SUBST]=inactive ZI[DTRACE]=0 ZI[CUR_PLUGIN]=
# Parameters - ICE. [[[
declare -gA ZI_1MAP ZI_2MAP
ZI_1MAP=(
- ZZI:: https://github.com/z-shell/zzi/trunk/
- ZZIL:: https://github.com/z-shell/zzi/trunk/lib/
- ZZIP:: https://github.com/z-shell/zzi/trunk/plugins/
- ZZIT:: https://github.com/z-shell/zzi/trunk/themes/
- OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
- ZZI:: https://github.com/z-shell/zzi/trunk/
- ZZIP:: https://github.com/z-shell/zzi/trunk/plugins/
- OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
- OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
- OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
- PZT:: https://github.com/sorin-ionescu/prezto/trunk/
- PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
+ OMZ:: https://github.com/ohmyzsh/ohmyzsh/trunk/
+ OMZP:: https://github.com/ohmyzsh/ohmyzsh/trunk/plugins/
+ OMZT:: https://github.com/ohmyzsh/ohmyzsh/trunk/themes/
+ OMZL:: https://github.com/ohmyzsh/ohmyzsh/trunk/lib/
+ PZT:: https://github.com/sorin-ionescu/prezto/trunk/
+ PZTM:: https://github.com/sorin-ionescu/prezto/trunk/modules/
)
ZI_2MAP=(
- ZZI:: https://github.com/z-shell/zzi/main/
- ZZIL:: https://github.com/z-shell/zzi/main/lib/
- ZZIP:: https://github.com/z-shell/zzi/main/plugins/
- ZZIT:: https://github.com/z-shell/zzi/main/themes/
- OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
- OMZP:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/
- OMZT:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/
- OMZL:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/
- PZT:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/
- PZTM:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/modules/
+ OMZ:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/
+ OMZP:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/
+ OMZT:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/themes/
+ OMZL:: https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/lib/
+ PZT:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/
+ PZTM:: https://raw.githubusercontent.com/sorin-ionescu/prezto/master/modules/
)
# ]]]
# Init. [[[
-zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting ZI set up.%f"; return 1; }
-zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting ZI set up.%f"; return 1; }
+zmodload zsh/zutil || { builtin print -P "%F{196}zsh/zutil module is required, aborting ❮ ZI ❯ set up.%f"; return 1; }
+zmodload zsh/parameter || { builtin print -P "%F{196}zsh/parameter module is required, aborting ❮ ZI ❯ set up.%f"; return 1; }
zmodload zsh/terminfo 2>/dev/null
zmodload zsh/termcap 2>/dev/null
-if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || \
- ( ${+termcap} -eq 1 && -n ${termcap[Co]} )
-]] {
- ZI+=(
- col-pname $'\e[1;4m\e[32m' col-uname $'\e[1;4m\e[35m' col-keyword $'\e[32m'
- col-note $'\e[38;5;148m' col-error $'\e[1m\e[38;5;204m' col-p $'\e[38;5;81m'
- col-info $'\e[38;5;82m' col-info2 $'\e[38;5;227m' col-profile $'\e[38;5;148m'
- col-uninst $'\e[38;5;118m' col-info3 $'\e[1m\e[38;5;227m' col-slight $'\e[38;5;230m'
- col-failure $'\e[38;5;204m' col-happy $'\e[1m\e[38;5;82m' col-annex $'\e[38;5;165m'
- col-id-as $'\e[4;38;5;220m' col-version $'\e[3;38;5;46m'
- # The more recent, fresh ones:
- col-pre $'\e[38;5;135m' col-msg $'\e[0m' col-msg2 $'\e[38;5;172m'
- col-obj $'\e[38;5;218m' col-obj2 $'\e[38;5;118m' col-file $'\e[3;38;5;117m'
- col-dir $'\e[3;38;5;153m' col-func $'\e[38;5;219m'
- col-url $'\e[38;5;75m' col-meta $'\e[38;5;57m' col-meta2 $'\e[38;5;147m'
- col-data $'\e[38;5;82m' col-data2 $'\e[38;5;117m' col-hi $'\e[1m\e[38;5;183m'
- col-var $'\e[38;5;81m' col-glob $'\e[38;5;227m' col-ehi $'\e[1m\e[38;5;210m'
- col-cmd $'\e[38;5;82m' col-ice $'\e[38;5;39m' col-nl $'\n'
- col-txt $'\e[38;5;254m' col-num $'\e[3;38;5;155m' col-term $'\e[38;5;185m'
- col-warn $'\e[38;5;214m' col-apo $'\e[1;38;5;220m' col-ok $'\e[38;5;220m'
- col-faint $'\e[38;5;238m' col-opt $'\e[38;5;219m' col-lhi $'\e[38;5;81m'
- col-tab $' \t ' col-msg3 $'\e[38;5;238m' col-b-lhi $'\e[1m\e[38;5;75m'
- col-bar $'\e[38;5;82m' col-th-bar $'\e[38;5;82m'
- col-… "${${${(M)LANG:#*UTF-8*}:+…}:-...}" col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}"
- col-mdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m'
- col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m'
- col--… "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}" col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}"
- col-↔ ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'}
- col-rst $'\e[0m' col-b $'\e[1m' col-nb $'\e[22m'
- col-u $'\e[4m' col-it $'\e[3m' col-st $'\e[9m'
- col-nu $'\e[24m' col-nit $'\e[23m' col-nst $'\e[29m'
- col-bspc $'\b' col-b-warn $'\e[1;38;5;214m' col-u-warn $'\e[4;38;5;214m'
- )
- if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || \
- ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 )
- ]] {
- ZI+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname $'\e[1;4m\e[38;5;207m' )
- }
+if [[ -z $SOURCED && ( ${+terminfo} -eq 1 && -n ${terminfo[colors]} ) || ( ${+termcap} -eq 1 && -n ${termcap[Co]} ) ]] {
+ ZI+=(
+ col-pname $'\e[1;4m\e[32m' col-uname $'\e[1;4m\e[35m' col-keyword $'\e[32m'
+ col-note $'\e[38;5;148m' col-error $'\e[1m\e[38;5;204m' col-p $'\e[38;5;81m'
+ col-info $'\e[38;5;82m' col-info2 $'\e[38;5;227m' col-profile $'\e[38;5;148m'
+ col-uninst $'\e[38;5;118m' col-info3 $'\e[1m\e[38;5;227m' col-slight $'\e[38;5;230m'
+ col-failure $'\e[38;5;204m' col-happy $'\e[1m\e[38;5;82m' col-annex $'\e[38;5;165m'
+ col-id-as $'\e[4;38;5;220m' col-version $'\e[3;38;5;46m'
+ col-pre $'\e[38;5;135m' col-msg $'\e[0m' col-msg2 $'\e[38;5;172m'
+ col-obj $'\e[38;5;218m' col-obj2 $'\e[38;5;118m' col-file $'\e[3;38;5;117m'
+ col-dir $'\e[3;38;5;153m' col-func $'\e[38;5;219m'
+ col-url $'\e[38;5;75m' col-meta $'\e[38;5;57m' col-meta2 $'\e[38;5;147m'
+ col-data $'\e[38;5;82m' col-data2 $'\e[38;5;117m' col-hi $'\e[1m\e[38;5;183m'
+ col-var $'\e[38;5;81m' col-glob $'\e[38;5;227m' col-ehi $'\e[1m\e[38;5;210m'
+ col-cmd $'\e[38;5;82m' col-ice $'\e[38;5;39m' col-nl $'\n'
+ col-txt $'\e[38;5;254m' col-num $'\e[3;38;5;155m' col-term $'\e[38;5;185m'
+ col-warn $'\e[38;5;214m' col-apo $'\e[1;38;5;220m' col-ok $'\e[38;5;220m'
+ col-faint $'\e[38;5;238m' col-opt $'\e[38;5;219m' col-lhi $'\e[38;5;81m'
+ col-tab $' \t ' col-msg3 $'\e[38;5;238m' col-b-lhi $'\e[1m\e[38;5;75m'
+ col-bar $'\e[38;5;82m' col-th-bar $'\e[38;5;82m'
+ col-… "${${${(M)LANG:#*UTF-8*}:+…}:-...}" col-ndsh "${${${(M)LANG:#*UTF-8*}:+–}:-}"
+ col-mdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+–}:--}"$'\e[0m'
+ col-mmdsh $'\e[1;38;5;220m'"${${${(M)LANG:#*UTF-8*}:+――}:--}"$'\e[0m'
+ col--… "${${${(M)LANG:#*UTF-8*}:+⋯⋯}:-···}" col-lr "${${${(M)LANG:#*UTF-8*}:+↔}:-"«-»"}"
+ col-↔ ${${${(M)LANG:#*UTF-8*}:+$'\e[38;5;82m↔\e[0m'}:-$'\e[38;5;82m«-»\e[0m'}
+ col-rst $'\e[0m' col-b $'\e[1m' col-nb $'\e[22m'
+ col-u $'\e[4m' col-it $'\e[3m' col-st $'\e[9m'
+ col-nu $'\e[24m' col-nit $'\e[23m' col-nst $'\e[29m'
+ col-bspc $'\b' col-b-warn $'\e[1;38;5;214m' col-u-warn $'\e[4;38;5;214m'
+ )
+ if [[ ( ${+terminfo} -eq 1 && ${terminfo[colors]} -ge 256 ) || ( ${+termcap} -eq 1 && ${termcap[Co]} -ge 256 ) ]] {
+ ZI+=( col-pname $'\e[1;4m\e[38;5;39m' col-uname $'\e[1;4m\e[38;5;207m' )
+ }
}
# List of hooks.
typeset -gAH ZI_ZLE_HOOKS_LIST
ZI_ZLE_HOOKS_LIST=(
- zle-isearch-exit 1
- zle-isearch-update 1
- zle-line-pre-redraw 1
- zle-line-init 1
- zle-line-finish 1
- zle-history-line-set 1
- zle-keymap-select 1
- paste-insert 1
+ zle-isearch-exit 1
+ zle-isearch-update 1
+ zle-line-pre-redraw 1
+ zle-line-init 1
+ zle-line-finish 1
+ zle-history-line-set 1
+ zle-keymap-select 1
+ paste-insert 1
)
builtin setopt noaliases
@@ -203,13 +170,11 @@ builtin setopt noaliases
#
# FUNCTION: :zi-reload-and-run. [[[
-# Marks given function ($3) for autoloading, and executes it triggering the
-# load. $1 is the fpath dedicated to the function, $2 are autoload options.
-# This function replaces "autoload -X", because using that on older Zsh
-# versions causes problems with traps.
+# Marks given function ($3) for autoloading, and executes it triggering the load.
+# $1 is the fpath dedicated to the function, $2 are autoload options. This function replaces "autoload -X",
+# because using that on older Zsh versions causes problems with traps.
#
-# So basically one creates function stub that calls :zi-reload-and-run()
-# instead of "autoload -X".
+# So basically one creates function stub that calls :zi-reload-and-run() instead of "autoload -X".
#
# $1 - FPATH dedicated to function
# $2 - autoload options
@@ -217,23 +182,19 @@ builtin setopt noaliases
#
# Author: Bart Schaefer
:zi-reload-and-run () {
- local fpath_prefix="$1" autoload_opts="$2" func="$3"
- shift 3
-
- # Unfunction caller function (its name is given).
- unfunction -- "$func"
-
- local -a ___fpath
- ___fpath=( ${fpath[@]} )
- local -a +h fpath
- [[ $FPATH != *${${(@0)fpath_prefix}[1]}* ]] && \
- fpath=( ${(@0)fpath_prefix} ${___fpath[@]} )
-
- # After this the function exists again.
- builtin autoload ${(s: :)autoload_opts} -- "$func"
-
- # User wanted to call the function, not only load it.
- "$func" "$@"
+ local fpath_prefix="$1" autoload_opts="$2" func="$3"
+ shift 3
+ # Unfunction caller function (its name is given).
+ unfunction -- "$func"
+ local -a ___fpath
+ ___fpath=( ${fpath[@]} )
+ local -a +h fpath
+ [[ $FPATH != *${${(@0)fpath_prefix}[1]}* ]] && \
+ fpath=( ${(@0)fpath_prefix} ${___fpath[@]} )
+ # After this the function exists again.
+ builtin autoload ${(s: :)autoload_opts} -- "$func"
+ # User wanted to call the function, not only load it.
+ "$func" "$@"
} # ]]]
# FUNCTION: :zi-tmp-subst-autoload. [[[
# Function defined to hijack plugin's calls to the `autoload' builtin.
@@ -241,444 +202,430 @@ builtin setopt noaliases
# The hijacking is not only to gather report data, but also to.
# run custom `autoload' function, that doesn't need FPATH.
:zi-tmp-subst-autoload () {
- emulate -LR zsh
- builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
- local -a opts opts2 custom reply
- local func
-
- zparseopts -D -E -M -a opts ${(s::):-RTUXdkmrtWzwC} I+=opts2 S+:=custom
-
- builtin set -- ${@:#--}
-
- # Process the id-as''/teleid'' to get the plugin dir.
- .zi-any-to-user-plugin $ZI[CUR_USPL2]
- [[ $reply[1] = % ]] && \
- local PLUGIN_DIR="$reply[2]" || \
- local PLUGIN_DIR="$ZI[PLUGINS_DIR]/${reply[1]:+$reply[1]---}${reply[2]//\//---}"
-
-
- # "Fpath elements" - ie those elements that are inside the plug-in directory.
- # The name comes from the fact that they are the selected fpath elements → so just
- # "items".
- local -a fpath_elements
- fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )
-
- # Add a function subdirectory to items, if any (this action is
- # according to the Plug Standard version 1.07 and later).
- [[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )
-
- if (( ${+opts[(r)-X]} )); then
- .zi-add-report "${ZI[CUR_USPL2]}" "Warning: Failed autoload ${(j: :)opts[@]} $*"
- +zi-message -u2 "{error}builtin autoload required for {obj}${(j: :)opts[@]}{error} option(s)"
- return 1
- fi
- if (( ${+opts[(r)-w]} )); then
- .zi-add-report "${ZI[CUR_USPL2]}" "-w-Autoload ${(j: :)opts[@]} ${(j: :)@}"
- fpath+=( $PLUGIN_DIR )
- builtin autoload ${opts[@]} "$@"
- return $?
- fi
- if [[ -n ${(M)@:#+X} ]]; then
- .zi-add-report "${ZI[CUR_USPL2]}" "Autoload +X ${opts:+${(j: :)opts[@]} }${(j: :)${@:#+X}}"
- local +h FPATH=$PLUGINS_DIR${fpath_elements:+:${(j.:.)fpath_elements[@]}}:$FPATH
- local +h -a fpath
- fpath=( $PLUGIN_DIR $fpath_elements $fpath )
- builtin autoload +X ${opts[@]} "${@:#+X}"
+ emulate -LR zsh
+ builtin setopt extendedglob warncreateglobal typesetsilent rcquotes
+ local -a opts opts2 custom reply
+ local func
+
+ zparseopts -D -E -M -a opts ${(s::):-RTUXdkmrtWzwC} I+=opts2 S+:=custom
+
+ builtin set -- ${@:#--}
+
+ # Process the id-as''/teleid'' to get the plugin dir.
+ .zi-any-to-user-plugin $ZI[CUR_USPL2]
+ [[ $reply[1] = % ]] && local PLUGIN_DIR="$reply[2]" || \
+ local PLUGIN_DIR="$ZI[PLUGINS_DIR]/${reply[1]:+$reply[1]---}${reply[2]//\//---}"
+ # "Fpath elements" - ie those elements that are inside the plug-in directory.
+ # The name comes from the fact that they are the selected fpath elements → so just "items".
+ local -a fpath_elements
+ fpath_elements=( ${fpath[(r)$PLUGIN_DIR/*]} )
+ # Add a function subdirectory to items, if any (this action is
+ # according to the Plug Standard version 1.07 and later).
+ [[ -d $PLUGIN_DIR/functions ]] && fpath_elements+=( "$PLUGIN_DIR"/functions )
+
+ if (( ${+opts[(r)-X]} )); then
+ .zi-add-report "${ZI[CUR_USPL2]}" "Warning: Failed autoload ${(j: :)opts[@]} $*"
+ +zi-message -u2 "{error}builtin autoload required for {obj}${(j: :)opts[@]}{error} option(s)"
+ return 1
+ fi
+ if (( ${+opts[(r)-w]} )); then
+ .zi-add-report "${ZI[CUR_USPL2]}" "-w-Autoload ${(j: :)opts[@]} ${(j: :)@}"
+ fpath+=( $PLUGIN_DIR )
+ builtin autoload ${opts[@]} "$@"
+ return $?
+ fi
+ if [[ -n ${(M)@:#+X} ]]; then
+ .zi-add-report "${ZI[CUR_USPL2]}" "Autoload +X ${opts:+${(j: :)opts[@]} }${(j: :)${@:#+X}}"
+ local +h FPATH=$PLUGINS_DIR${fpath_elements:+:${(j.:.)fpath_elements[@]}}:$FPATH
+ local +h -a fpath
+ fpath=( $PLUGIN_DIR $fpath_elements $fpath )
+ builtin autoload +X ${opts[@]} "${@:#+X}"
+ return $?
+ fi
+
+ for func; do
+ .zi-add-report "${ZI[CUR_USPL2]}" "Autoload $func${opts:+ with options ${(j: :)opts[@]}}"
+ done
+
+ integer count retval
+ for func; do
+ # Real autoload doesn't touch function if it already exists.
+ # Author of the idea of FPATH-clean autoloading: Bart Schaefer.
+ if (( ${+functions[$func]} != 1 )) {
+ builtin setopt noaliases
+ if [[ $func == /* ]] && is-at-least 5.4; then
+ builtin autoload ${opts[@]} $func
return $?
- fi
-
- for func; do
- .zi-add-report "${ZI[CUR_USPL2]}" "Autoload $func${opts:+ with options ${(j: :)opts[@]}}"
- done
-
- integer count retval
- for func; do
- # Real autoload doesn't touch function if it already exists.
- # Author of the idea of FPATH-clean autoloading: Bart Schaefer.
- if (( ${+functions[$func]} != 1 )) {
- builtin setopt noaliases
- if [[ $func == /* ]] && is-at-least 5.4; then
- builtin autoload ${opts[@]} $func
- return $?
- elif [[ $func == /* ]]; then
- if [[ $ZI[MUTE_WARNINGS] != (1|true|on|yes) && \
- -z $ZI[WARN_SHOWN_FOR_$ZI[CUR_USPL2]] ]]; then
- +zi-message "{u-warn}Warning{b-warn}: {rst}the plugin {pid}$ZI[CUR_USPL2]" \
- "{rst}is using autoload functions specified by their absolute path," \
- "which is not supported by this Zsh version ({↔} {version}$ZSH_VERSION{rst}," \
- "required is Zsh >= {version}5.4{rst})." \
- "{nl}A fallback mechanism has been applied, which works well only" \
- "for functions in the plugin {u}{slight}main{rst} directory." \
- "{nl}(To mute this message, set" \
- "{var}\$ZI[MUTE_WARNINGS]{rst} to a truth value.)"
- ZI[WARN_SHOWN_FOR_$ZI[CUR_USPL2]]=1
- fi
-
- # Apply workaround
- func=$func:t
- fi
- if [[ ${ZI[NEW_AUTOLOAD]} = 2 ]]; then
- builtin autoload ${opts[@]} "$PLUGIN_DIR/$func"
- retval=$?
- elif [[ ${ZI[NEW_AUTOLOAD]} = 1 ]]; then
- if (( ${+opts[(r)-C]} )) {
- local pth nl=$'\n' sel=""
- for pth ( $PLUGIN_DIR $fpath_elements $fpath ) {
- [[ -f $pth/$func ]] && { sel=$pth; break; }
- }
- if [[ -z $sel ]] {
- +zi-message '{u-warn}zi{b-warn}:{error} Couldn''t find autoload function{ehi}:' \
- "{apo}\`{file}${func}{apo}\`{error} anywhere in {var}\$fpath{error}."
- retval=1
- } else {
- eval "function ${(q)${custom[++count*2]}:-$func} {
- local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2
- () { setopt localoptions extendedglob
- body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\"
- [[ \$body2 != \$body ]] && \
- body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\"
- }
-
- functions[${${(q)custom[count*2]}:-$func}]=\"\$body2\"
- ${(q)${custom[count*2]}:-$func} \"\$@\"
- }"
- retval=$?
- }
- } else {
- eval "function ${(q)func} {
- local -a fpath
- fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} )
- builtin autoload -X ${(j: :)${(q-)opts[@]}}
- }"
- retval=$?
- }
- else
- eval "function ${(q)func} {
- :zi-reload-and-run ${(qqq)PLUGIN_DIR}"$'\0'"${(pj,\0,)${(qqq)fpath_elements[@]}} ${(qq)opts[*]} ${(q)func} "'"$@"
- }'
- retval=$?
- fi
- (( ZI[ALIASES_OPT] )) && builtin setopt aliases
- }
- if (( ${+opts2[(r)-I]} )) {
- ${custom[count*2]:-$func}
+ elif [[ $func == /* ]]; then
+ if [[ $ZI[MUTE_WARNINGS] != (1|true|on|yes) && -z $ZI[WARN_SHOWN_FOR_$ZI[CUR_USPL2]] ]]; then
+ +zi-message "{u-warn}Warning{b-warn}: {rst}the plugin {pid}$ZI[CUR_USPL2]" \
+ "{rst}is using autoload functions specified by their absolute path," \
+ "which is not supported by this Zsh version ({↔} {version}$ZSH_VERSION{rst}," \
+ "required is Zsh >= {version}5.4{rst})." \
+ "{nl}A fallback mechanism has been applied, which works well only" \
+ "for functions in the plugin {u}{slight}main{rst} directory." \
+ "{nl}(To mute this message, set" \
+ "{var}\$ZI[MUTE_WARNINGS]{rst} to a truth value.)"
+ ZI[WARN_SHOWN_FOR_$ZI[CUR_USPL2]]=1
+ fi
+ # Apply workaround
+ func=$func:t
+ fi
+ if [[ ${ZI[NEW_AUTOLOAD]} = 2 ]]; then
+ builtin autoload ${opts[@]} "$PLUGIN_DIR/$func"
+ retval=$?
+ elif [[ ${ZI[NEW_AUTOLOAD]} = 1 ]]; then
+ if (( ${+opts[(r)-C]} )) {
+ local pth nl=$'\n' sel=""
+ for pth ( $PLUGIN_DIR $fpath_elements $fpath ) {
+ [[ -f $pth/$func ]] && { sel=$pth; break; }
+ }
+ if [[ -z $sel ]] {
+ +zi-message '{u-warn}zi{b-warn}:{error} Couldn''t find autoload function{ehi}:' \
+ "{apo}\`{file}${func}{apo}\`{error} anywhere in {var}\$fpath{error}."
+ retval=1
+ } else {
+ eval "function ${(q)${custom[++count*2]}:-$func} {
+ local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2
+ () { setopt localoptions extendedglob
+ body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\"
+ [[ \$body2 != \$body ]] && \
+ body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\"
+ }
+ functions[${${(q)custom[count*2]}:-$func}]=\"\$body2\"
+ ${(q)${custom[count*2]}:-$func} \"\$@\"
+ }"
retval=$?
+ }
+ } else {
+ eval "function ${(q)func} {
+ local -a fpath
+ fpath=( ${(qqq)PLUGIN_DIR} ${(qqq@)fpath_elements} ${(qqq@)fpath} )
+ builtin autoload -X ${(j: :)${(q-)opts[@]}}
+ }"
+ retval=$?
}
- done
+ else
+ eval "function ${(q)func} {
+ :zi-reload-and-run ${(qqq)PLUGIN_DIR}"$'\0'"${(pj,\0,)${(qqq)fpath_elements[@]}} ${(qq)opts[*]} ${(q)func} "'"$@"
+ }'
+ retval=$?
+ fi
+ (( ZI[ALIASES_OPT] )) && builtin setopt aliases
+ }
+ if (( ${+opts2[(r)-I]} )) {
+ ${custom[count*2]:-$func}
+ retval=$?
+ }
+ done
- return $retval
+ return $retval
} # ]]]
# FUNCTION: :zi-tmp-subst-bindkey. [[[
# Function defined to hijack plugin's calls to the `bindkey' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zi-tmp-subst-bindkey() {
- emulate -LR zsh
- builtin setopt extendedglob warncreateglobal typesetsilent noshortloops
-
- is-at-least 5.3 && \
- .zi-add-report "${ZI[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || \
- .zi-add-report "${ZI[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}"
-
- # Remember to perform the actual bindkey call.
- typeset -a pos
- pos=( "$@" )
-
- # Check if we have regular bindkey call, i.e.
- # with no options or with -s, plus possible -M
- # option.
- local -A opts
- zparseopts -A opts -D ${(s::):-lLdDAmrsevaR} M: N:
-
- if (( ${#opts} == 0 ||
- ( ${#opts} == 1 && ${+opts[-M]} ) ||
- ( ${#opts} == 1 && ${+opts[-R]} ) ||
- ( ${#opts} == 1 && ${+opts[-s]} ) ||
- ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-s]} ) ||
- ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-R]} )
- )); then
- local string="${(q)1}" widget="${(q)2}"
- local quoted
-
- if [[ -n ${ICE[bindmap]} && ${ZI_CUR_BIND_MAP[empty]} -eq 1 ]]; then
- local -a pairs
- pairs=( "${(@s,;,)ICE[bindmap]}" )
- if [[ -n ${(M)pairs:#*\\(#e)} ]] {
- local prev
- pairs=( ${pairs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${prev:+$prev\;}}${match[3]}${${prev::=${match[2]:+${prev:+$prev\;}}${match[2]}}:+}} )
- }
- pairs=( "${(@)${(@)${(@s:->:)pairs}##[[:space:]]##}%%[[:space:]]##}" )
- ZI_CUR_BIND_MAP=( empty 0 )
- (( ${#pairs} > 1 && ${#pairs[@]} % 2 == 0 )) && ZI_CUR_BIND_MAP+=( "${pairs[@]}" )
- fi
-
- local bmap_val="${ZI_CUR_BIND_MAP[${1}]}"
- if (( !ZI_CUR_BIND_MAP[empty] )) {
- [[ -z $bmap_val ]] && bmap_val="${ZI_CUR_BIND_MAP[${(qqq)1}]}"
- [[ -z $bmap_val ]] && bmap_val="${ZI_CUR_BIND_MAP[${(qqq)${(Q)1}}]}"
- [[ -z $bmap_val ]] && { bmap_val="${ZI_CUR_BIND_MAP[!${(qqq)1}]}"; integer val=1; }
- [[ -z $bmap_val ]] && bmap_val="${ZI_CUR_BIND_MAP[!${(qqq)${(Q)1}}]}"
- }
- if [[ -n $bmap_val ]]; then
- string="${(q)bmap_val}"
- if (( val )) {
- [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
- } else {
- [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
- }
- .zi-add-report "${ZI[CUR_USPL2]}" ":::Bindkey: combination <$1> changed to <$bmap_val>${${(M)bmap_val:#hold}:+, i.e. ${ZI[col-error]}unmapped${ZI[col-rst]}}"
- ((1))
- elif [[ ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[UPAR]}} && -n ${${ZI[UPAR]}[(r);:${(q)1};:]} ) || \
- ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[DOWNAR]}} && -n ${${ZI[DOWNAR]}[(r);:${(q)1};:]} ) || \
- ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[RIGHTAR]}} && -n ${${ZI[RIGHTAR]}[(r);:${(q)1};:]} ) || \
- ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[LEFTAR]}} && -n ${${ZI[LEFTAR]}[(r);:${(q)1};:]} )
- ]]; then
- string="${(q)bmap_val}"
- if (( val )) {
- [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
- } else {
- [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
- }
- .zi-add-report "${ZI[CUR_USPL2]}" ":::Bindkey: combination <$1> recognized as cursor-key and changed to <${bmap_val}>${${(M)bmap_val:#hold}:+, i.e. ${ZI[col-error]}unmapped${ZI[col-rst]}}"
- fi
- [[ $bmap_val = hold ]] && return 0
-
- local prev="${(q)${(s: :)$(builtin bindkey ${(Q)string})}[-1]#undefined-key}"
+ emulate -LR zsh
+ builtin setopt extendedglob warncreateglobal typesetsilent noshortloops
+
+ is-at-least 5.3 && \
+ .zi-add-report "${ZI[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || \
+ .zi-add-report "${ZI[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}"
+
+ # Remember to perform the actual bindkey call.
+ typeset -a pos
+ pos=( "$@" )
+
+ # Check if we have regular bindkey call, i.e.
+ # with no options or with -s, plus possible -M
+ # option.
+ local -A opts
+ zparseopts -A opts -D ${(s::):-lLdDAmrsevaR} M: N:
+
+ if (( ${#opts} == 0 ||
+ ( ${#opts} == 1 && ${+opts[-M]} ) ||
+ ( ${#opts} == 1 && ${+opts[-R]} ) ||
+ ( ${#opts} == 1 && ${+opts[-s]} ) ||
+ ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-s]} ) ||
+ ( ${#opts} <= 2 && ${+opts[-M]} && ${+opts[-R]} )
+ )); then
+ local string="${(q)1}" widget="${(q)2}"
+ local quoted
+
+ if [[ -n ${ICE[bindmap]} && ${ZI_CUR_BIND_MAP[empty]} -eq 1 ]]; then
+ local -a pairs
+ pairs=( "${(@s,;,)ICE[bindmap]}" )
+ if [[ -n ${(M)pairs:#*\\(#e)} ]] {
+ local prev
+ pairs=( ${pairs[@]//(#b)((*)\\(#e)|(*))/${match[3]:+${prev:+$prev\;}}${match[3]}${${prev::=${match[2]:+${prev:+$prev\;}}${match[2]}}:+}} )
+ }
+ pairs=( "${(@)${(@)${(@s:->:)pairs}##[[:space:]]##}%%[[:space:]]##}" )
+ ZI_CUR_BIND_MAP=( empty 0 )
+ (( ${#pairs} > 1 && ${#pairs[@]} % 2 == 0 )) && ZI_CUR_BIND_MAP+=( "${pairs[@]}" )
+ fi
- # "-M map" given?
- if (( ${+opts[-M]} )); then
- local Mopt=-M
- local Marg="${opts[-M]}"
+ local bmap_val="${ZI_CUR_BIND_MAP[${1}]}"
+ if (( !ZI_CUR_BIND_MAP[empty] )) {
+ [[ -z $bmap_val ]] && bmap_val="${ZI_CUR_BIND_MAP[${(qqq)1}]}"
+ [[ -z $bmap_val ]] && bmap_val="${ZI_CUR_BIND_MAP[${(qqq)${(Q)1}}]}"
+ [[ -z $bmap_val ]] && { bmap_val="${ZI_CUR_BIND_MAP[!${(qqq)1}]}"; integer val=1; }
+ [[ -z $bmap_val ]] && bmap_val="${ZI_CUR_BIND_MAP[!${(qqq)${(Q)1}}]}"
+ }
+ if [[ -n $bmap_val ]]; then
+ string="${(q)bmap_val}"
+ if (( val )) {
+ [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
+ } else {
+ [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
+ }
+ .zi-add-report "${ZI[CUR_USPL2]}" ":::Bindkey: combination <$1> changed to <$bmap_val>${${(M)bmap_val:#hold}:+, i.e. ${ZI[col-error]}unmapped${ZI[col-rst]}}"
+ ((1))
+ elif [[ ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[UPAR]}} && -n ${${ZI[UPAR]}[(r);:${(q)1};:]} ) || \
+ ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[DOWNAR]}} && -n ${${ZI[DOWNAR]}[(r);:${(q)1};:]} ) || \
+ ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[RIGHTAR]}} && -n ${${ZI[RIGHTAR]}[(r);:${(q)1};:]} ) || \
+ ( -n ${bmap_val::=${ZI_CUR_BIND_MAP[LEFTAR]}} && -n ${${ZI[LEFTAR]}[(r);:${(q)1};:]} )
+ ]]; then
+ string="${(q)bmap_val}"
+ if (( val )) {
+ [[ ${pos[1]} = "-M" ]] && pos[4]="$bmap_val" || pos[2]="$bmap_val"
+ } else {
+ [[ ${pos[1]} = "-M" ]] && pos[3]="${(Q)bmap_val}" || pos[1]="${(Q)bmap_val}"
+ }
+ .zi-add-report "${ZI[CUR_USPL2]}" ":::Bindkey: combination <$1> recognized as cursor-key and changed to <${bmap_val}>${${(M)bmap_val:#hold}:+, i.e. ${ZI[col-error]}unmapped${ZI[col-rst]}}"
+ fi
+ [[ $bmap_val = hold ]] && return 0
- Mopt="${(q)Mopt}"
- Marg="${(q)Marg}"
+ local prev="${(q)${(s: :)$(builtin bindkey ${(Q)string})}[-1]#undefined-key}"
- quoted="$string $widget $prev $Mopt $Marg"
- else
- quoted="$string $widget $prev"
- fi
+ # "-M map" given?
+ if (( ${+opts[-M]} )); then
+ local Mopt=-M
+ local Marg="${opts[-M]}"
- # -R given?
- if (( ${+opts[-R]} )); then
- local Ropt=-R
- Ropt="${(q)Ropt}"
+ Mopt="${(q)Mopt}"
+ Marg="${(q)Marg}"
- if (( ${+opts[-M]} )); then
- quoted="$quoted $Ropt"
- else
- # Two empty fields for non-existent -M arg.
- local space=_
- space="${(q)space}"
- quoted="$quoted $space $space $Ropt"
- fi
- fi
+ quoted="$string $widget $prev $Mopt $Marg"
+ else
+ quoted="$string $widget $prev"
+ fi
- quoted="${(q)quoted}"
+ # -R given?
+ if (( ${+opts[-R]} )); then
+ local Ropt=-R
+ Ropt="${(q)Ropt}"
+
+ if (( ${+opts[-M]} )); then
+ quoted="$quoted $Ropt"
+ else
+ # Two empty fields for non-existent -M arg.
+ local space=_
+ space="${(q)space}"
+ quoted="$quoted $space $space $Ropt"
+ fi
+ fi
- # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[BINDKEYS__${ZI[CUR_USPL2]}]+="$quoted "
- # Remember for dtrace.
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[BINDKEYS___dtrace/_dtrace]+="$quoted "
+ quoted="${(q)quoted}"
+
+ # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[BINDKEYS__${ZI[CUR_USPL2]}]+="$quoted "
+ # Remember for dtrace.
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[BINDKEYS___dtrace/_dtrace]+="$quoted "
+ else
+ # bindkey -A newkeymap main?
+ # Negative indices for KSH_ARRAYS immunity.
+ if [[ ${#opts} -eq 1 && ${+opts[-A]} = 1 && ${#pos} = 3 && ${pos[-1]} = main && ${pos[-2]} != -A ]]; then
+ # Save a copy of main keymap.
+ (( ZI[BINDKEY_MAIN_IDX] = ${ZI[BINDKEY_MAIN_IDX]:-0} + 1 ))
+ local pname="${ZI[CUR_PLUGIN]:-_dtrace}"
+ local name="${(q)pname}-main-${ZI[BINDKEY_MAIN_IDX]}"
+ builtin bindkey -N "$name" main
+
+ # Remember occurence of main keymap substitution, to revert on unload.
+ local keys=_ widget=_ prev= optA=-A mapname="${name}" optR=_
+ local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optA} ${(q)mapname} ${(q)optR}"
+ quoted="${(q)quoted}"
+
+ # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[BINDKEYS__${ZI[CUR_USPL2]}]+="$quoted "
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[BINDKEYS___dtrace/_dtrace]+="$quoted "
+
+ .zi-add-report "${ZI[CUR_USPL2]}" "Warning: keymap \`main' copied to \`${name}' because of \`${pos[-2]}' substitution"
+ # bindkey -N newkeymap [other].
+ elif [[ ${#opts} -eq 1 && ${+opts[-N]} = 1 ]]; then
+ local Nopt=-N
+ local Narg="${opts[-N]}"
+ local keys=_ widget=_ prev= optN=-N mapname="${Narg}" optR=_
+ local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optN} ${(q)mapname} ${(q)optR}"
+ quoted="${(q)quoted}"
+
+ # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[BINDKEYS__${ZI[CUR_USPL2]}]+="$quoted "
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[BINDKEYS___dtrace/_dtrace]+="$quoted "
else
- # bindkey -A newkeymap main?
- # Negative indices for KSH_ARRAYS immunity.
- if [[ ${#opts} -eq 1 && ${+opts[-A]} = 1 && ${#pos} = 3 && ${pos[-1]} = main && ${pos[-2]} != -A ]]; then
- # Save a copy of main keymap.
- (( ZI[BINDKEY_MAIN_IDX] = ${ZI[BINDKEY_MAIN_IDX]:-0} + 1 ))
- local pname="${ZI[CUR_PLUGIN]:-_dtrace}"
- local name="${(q)pname}-main-${ZI[BINDKEY_MAIN_IDX]}"
- builtin bindkey -N "$name" main
-
- # Remember occurence of main keymap substitution, to revert on unload.
- local keys=_ widget=_ prev= optA=-A mapname="${name}" optR=_
- local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optA} ${(q)mapname} ${(q)optR}"
- quoted="${(q)quoted}"
-
- # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[BINDKEYS__${ZI[CUR_USPL2]}]+="$quoted "
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[BINDKEYS___dtrace/_dtrace]+="$quoted "
-
- .zi-add-report "${ZI[CUR_USPL2]}" "Warning: keymap \`main' copied to \`${name}' because of \`${pos[-2]}' substitution"
- # bindkey -N newkeymap [other].
- elif [[ ${#opts} -eq 1 && ${+opts[-N]} = 1 ]]; then
- local Nopt=-N
- local Narg="${opts[-N]}"
-
- local keys=_ widget=_ prev= optN=-N mapname="${Narg}" optR=_
- local quoted="${(q)keys} ${(q)widget} ${(q)prev} ${(q)optN} ${(q)mapname} ${(q)optR}"
- quoted="${(q)quoted}"
-
- # Remember the bindkey, only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[BINDKEYS__${ZI[CUR_USPL2]}]+="$quoted "
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[BINDKEYS___dtrace/_dtrace]+="$quoted "
- else
- .zi-add-report "${ZI[CUR_USPL2]}" "Warning: last bindkey used non-typical options: ${(kv)opts[*]}"
- fi
+ .zi-add-report "${ZI[CUR_USPL2]}" "Warning: last bindkey used non-typical options: ${(kv)opts[*]}"
fi
-
- # Actual bindkey.
- builtin bindkey "${pos[@]}"
- return $? # testable
+ fi
+ # Actual bindkey.
+ builtin bindkey "${pos[@]}"
+ return $? # testable
} # ]]]
# FUNCTION: :zi-tmp-subst-zstyle. [[[
# Function defined to hijack plugin's calls to the `zstyle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zi-tmp-subst-zstyle() {
- builtin setopt localoptions noerrreturn noerrexit extendedglob nowarncreateglobal \
- typesetsilent noshortloops unset
- .zi-add-report "${ZI[CUR_USPL2]}" "Zstyle $*"
-
- # Remember in order to perform the actual zstyle call.
- typeset -a pos
- pos=( "$@" )
-
- # Check if we have regular zstyle call, i.e.
- # with no options or with -e.
- local -a opts
- zparseopts -a opts -D ${(s::):-eLdgabsTtm}
-
- if [[ ${#opts} -eq 0 || ( ${#opts} -eq 1 && ${+opts[(r)-e]} = 1 ) ]]; then
- # Have to quote $1, then $2, then concatenate them, then quote them again.
- local pattern="${(q)1}" style="${(q)2}"
- local ps="$pattern $style"
- ps="${(q)ps}"
-
- # Remember the zstyle, only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[ZSTYLES__${ZI[CUR_USPL2]}]+="$ps "
- # Remember for dtrace.
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[ZSTYLES___dtrace/_dtrace]+=$ps
- else
- if [[ ! ${#opts[@]} = 1 && ( ${+opts[(r)-s]} = 1 || ${+opts[(r)-b]} = 1 || ${+opts[(r)-a]} = 1 || ${+opts[(r)-t]} = 1 || ${+opts[(r)-T]} = 1 || ${+opts[(r)-m]} = 1 ) ]]; then
- .zi-add-report "${ZI[CUR_USPL2]}" "Warning: last zstyle used non-typical options: ${opts[*]}"
- fi
+ builtin setopt localoptions noerrreturn noerrexit extendedglob nowarncreateglobal typesetsilent noshortloops unset
+ .zi-add-report "${ZI[CUR_USPL2]}" "Zstyle $*"
+
+ # Remember in order to perform the actual zstyle call.
+ typeset -a pos
+ pos=( "$@" )
+
+ # Check if we have regular zstyle call, i.e.
+ # with no options or with -e.
+ local -a opts
+ zparseopts -a opts -D ${(s::):-eLdgabsTtm}
+
+ if [[ ${#opts} -eq 0 || ( ${#opts} -eq 1 && ${+opts[(r)-e]} = 1 ) ]]; then
+ # Have to quote $1, then $2, then concatenate them, then quote them again.
+ local pattern="${(q)1}" style="${(q)2}"
+ local ps="$pattern $style"
+ ps="${(q)ps}"
+
+ # Remember the zstyle, only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[ZSTYLES__${ZI[CUR_USPL2]}]+="$ps "
+ # Remember for dtrace.
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[ZSTYLES___dtrace/_dtrace]+=$ps
+ else
+ if [[ ! ${#opts[@]} = 1 && ( ${+opts[(r)-s]} = 1 || ${+opts[(r)-b]} = 1 || ${+opts[(r)-a]} = 1 || ${+opts[(r)-t]} = 1 || ${+opts[(r)-T]} = 1 || ${+opts[(r)-m]} = 1 ) ]]; then
+ .zi-add-report "${ZI[CUR_USPL2]}" "Warning: last zstyle used non-typical options: ${opts[*]}"
fi
+ fi
- # Actual zstyle.
- builtin zstyle "${pos[@]}"
- return $? # testable
+ # Actual zstyle.
+ builtin zstyle "${pos[@]}"
+ return $? # testable
} # ]]]
# FUNCTION: :zi-tmp-subst-alias. [[[
# Function defined to hijack plugin's calls to the `alias' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zi-tmp-subst-alias() {
- builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
- typesetsilent noshortloops unset
- .zi-add-report "${ZI[CUR_USPL2]}" "Alias $*"
-
- # Remember to perform the actual alias call.
- typeset -a pos
- pos=( "$@" )
-
- local -a opts
- zparseopts -a opts -D ${(s::):-gs}
-
- local a quoted tmp
- for a in "$@"; do
- local aname="${a%%[=]*}"
- local avalue="${a#*=}"
-
- # Check if alias is to be redefined.
- (( ${+aliases[$aname]} )) && .zi-add-report "${ZI[CUR_USPL2]}" "Warning: redefining alias \`${aname}', previous value: ${aliases[$aname]}"
-
- local bname=${(q)aliases[$aname]}
- aname="${(q)aname}"
-
- if (( ${+opts[(r)-s]} )); then
- tmp=-s
- tmp="${(q)tmp}"
- quoted="$aname $bname $tmp"
- elif (( ${+opts[(r)-g]} )); then
- tmp=-g
- tmp="${(q)tmp}"
- quoted="$aname $bname $tmp"
- else
- quoted="$aname $bname"
- fi
+ builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal typesetsilent noshortloops unset
+ .zi-add-report "${ZI[CUR_USPL2]}" "Alias $*"
+
+ # Remember to perform the actual alias call.
+ typeset -a pos
+ pos=( "$@" )
+
+ local -a opts
+ zparseopts -a opts -D ${(s::):-gs}
+
+ local a quoted tmp
+ for a in "$@"; do
+ local aname="${a%%[=]*}"
+ local avalue="${a#*=}"
+
+ # Check if alias is to be redefined.
+ (( ${+aliases[$aname]} )) && .zi-add-report "${ZI[CUR_USPL2]}" "Warning: redefining alias \`${aname}', previous value: ${aliases[$aname]}"
+
+ local bname=${(q)aliases[$aname]}
+ aname="${(q)aname}"
+
+ if (( ${+opts[(r)-s]} )); then
+ tmp=-s
+ tmp="${(q)tmp}"
+ quoted="$aname $bname $tmp"
+ elif (( ${+opts[(r)-g]} )); then
+ tmp=-g
+ tmp="${(q)tmp}"
+ quoted="$aname $bname $tmp"
+ else
+ quoted="$aname $bname"
+ fi
- quoted="${(q)quoted}"
+ quoted="${(q)quoted}"
- # Remember the alias, only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[ALIASES__${ZI[CUR_USPL2]}]+="$quoted "
- # Remember for dtrace.
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[ALIASES___dtrace/_dtrace]+="$quoted "
- done
+ # Remember the alias, only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[ALIASES__${ZI[CUR_USPL2]}]+="$quoted "
+ # Remember for dtrace.
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[ALIASES___dtrace/_dtrace]+="$quoted "
+ done
- # Actual alias.
- builtin alias "${pos[@]}"
- return $? # testable
+ # Actual alias.
+ builtin alias "${pos[@]}"
+ return $? # testable
} # ]]]
# FUNCTION: :zi-tmp-subst-zle. [[[.
# Function defined to hijack plugin's calls to the `zle' builtin.
#
# The hijacking is to gather report data (which is used in unload).
:zi-tmp-subst-zle() {
- builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
- typesetsilent noshortloops unset
- .zi-add-report "${ZI[CUR_USPL2]}" "Zle $*"
-
- # Remember to perform the actual zle call.
- typeset -a pos
- pos=( "$@" )
-
- builtin set -- "${@:#--}"
-
- # Try to catch game-changing "-N".
- if [[ ( $1 = -N && ( $# = 2 || $# = 3 ) ) || ( $1 = -C && $# = 4 ) ]]; then
- # Hooks.
- if [[ ${ZI_ZLE_HOOKS_LIST[$2]} = 1 ]]; then
- local quoted="$2"
- quoted="${(q)quoted}"
- # Remember only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[WIDGETS_DELETE__${ZI[CUR_USPL2]}]+="$quoted "
- # Remember for dtrace.
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
- # These will be saved and restored.
- elif (( ${+widgets[$2]} )); then
- # Have to remember original widget "$2" and
- # the copy that it's going to be done.
- local widname="$2" targetfun="${${${(M)1:#-C}:+$4}:-$3}"
- local completion_widget="${${(M)1:#-C}:+$3}"
- local saved_widcontents="${widgets[$widname]}"
-
- widname="${(q)widname}"
- completion_widget="${(q)completion_widget}"
- targetfun="${(q)targetfun}"
- saved_widcontents="${(q)saved_widcontents}"
- local quoted="$1 $widname $completion_widget $targetfun $saved_widcontents"
- quoted="${(q)quoted}"
- # Remember only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[WIDGETS_SAVED__${ZI[CUR_USPL2]}]+="$quoted "
- # Remember for dtrace.
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[WIDGETS_SAVED___dtrace/_dtrace]+="$quoted "
- # These will be deleted.
- else
- .zi-add-report "${ZI[CUR_USPL2]}" "Note: a new widget created via zle -N: \`$2'"
- local quoted="$2"
- quoted="${(q)quoted}"
- # Remember only when load is in progress (it can be dstart that leads execution here).
- [[ -n ${ZI[CUR_USPL2]} ]] && ZI[WIDGETS_DELETE__${ZI[CUR_USPL2]}]+="$quoted "
- # Remember for dtrace.
- [[ ${ZI[DTRACE]} = 1 ]] && ZI[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
- fi
- fi
+ builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal typesetsilent noshortloops unset
+ .zi-add-report "${ZI[CUR_USPL2]}" "Zle $*"
+
+ # Remember to perform the actual zle call.
+ typeset -a pos
+ pos=( "$@" )
+
+ builtin set -- "${@:#--}"
+
+ # Try to catch game-changing "-N".
+ if [[ ( $1 = -N && ( $# = 2 || $# = 3 ) ) || ( $1 = -C && $# = 4 ) ]]; then
+ # Hooks.
+ if [[ ${ZI_ZLE_HOOKS_LIST[$2]} = 1 ]]; then
+ local quoted="$2"
+ quoted="${(q)quoted}"
+ # Remember only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[WIDGETS_DELETE__${ZI[CUR_USPL2]}]+="$quoted "
+ # Remember for dtrace.
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
+ # These will be saved and restored.
+ elif (( ${+widgets[$2]} )); then
+ # Have to remember original widget "$2" and
+ # the copy that it's going to be done.
+ local widname="$2" targetfun="${${${(M)1:#-C}:+$4}:-$3}"
+ local completion_widget="${${(M)1:#-C}:+$3}"
+ local saved_widcontents="${widgets[$widname]}"
+
+ widname="${(q)widname}"
+ completion_widget="${(q)completion_widget}"
+ targetfun="${(q)targetfun}"
+ saved_widcontents="${(q)saved_widcontents}"
+ local quoted="$1 $widname $completion_widget $targetfun $saved_widcontents"
+ quoted="${(q)quoted}"
+ # Remember only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[WIDGETS_SAVED__${ZI[CUR_USPL2]}]+="$quoted "
+ # Remember for dtrace.
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[WIDGETS_SAVED___dtrace/_dtrace]+="$quoted "
+ # These will be deleted.
+ else
+ .zi-add-report "${ZI[CUR_USPL2]}" "Note: a new widget created via zle -N: \`$2'"
+ local quoted="$2"
+ quoted="${(q)quoted}"
+ # Remember only when load is in progress (it can be dstart that leads execution here).
+ [[ -n ${ZI[CUR_USPL2]} ]] && ZI[WIDGETS_DELETE__${ZI[CUR_USPL2]}]+="$quoted "
+ # Remember for dtrace.
+ [[ ${ZI[DTRACE]} = 1 ]] && ZI[WIDGETS_DELETE___dtrace/_dtrace]+="$quoted "
+ fi
+ fi
- # Actual zle.
- builtin zle "${pos[@]}"
- return $? # testable
+ # Actual zle.
+ builtin zle "${pos[@]}"
+ return $? # testable
} # ]]]
# FUNCTION: :zi-tmp-subst-compdef. [[[
# Function defined to hijack plugin's calls to the `compdef' function.
# The hijacking is not only for reporting, but also to save compdef
# calls so that `compinit' can be called after loading plugins.
:zi-tmp-subst-compdef() {
- builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
- typesetsilent noshortloops unset
- .zi-add-report "${ZI[CUR_USPL2]}" "Saving \`compdef $*' for replay"
- ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )
+ builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal typesetsilent noshortloops unset
+ .zi-add-report "${ZI[CUR_USPL2]}" "Saving \`compdef $*' for replay"
+ ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" )
- return 0 # testable
+ return 0 # testable
} # ]]]
# FUNCTION: .zi-tmp-subst-on. [[[
# Turn on temporary substituting of functions of builtins and functions according to passed
@@ -686,138 +633,136 @@ builtin setopt noaliases
# to gather report data, and to hijack `autoload', `bindkey' and
# `compdef' calls.
.zi-tmp-subst-on() {
- local mode="$1"
-
- # Enable temporary substituting of functions only once.
- #
- # One could expect possibility of widening of temporary substituting of functions, however
- # such sequence doesn't exist, e.g. "light" then "load"/"dtrace", "compdef" then "load"/
- # "dtrace", "light" then "compdef", "compdef" then "light".
- #
- # It is always "dtrace" then "load" (i.e. dtrace then load) "dtrace" then "light" (i.e.:
- # dtrace then light load) "dtrace" then "compdef" (i.e.: dtrace then snippet).
- [[ ${ZI[TMP_SUBST]} != inactive ]] && builtin return 0
-
- ZI[TMP_SUBST]="$mode"
-
- # The point about backuping is: does the key exist in functions array.
- # If it does exist, then it will also exist as ZI[bkp-*].
-
- # Defensive code, shouldn't be needed.
- builtin unset "ZI[bkp-autoload]" "ZI[bkp-compdef]" # 0, E.
-
- if [[ $mode != compdef ]]; then
- # 0. Used, but not in temporary restoration, which doesn't happen for autoload.
- (( ${+functions[autoload]} )) && ZI[bkp-autoload]="${functions[autoload]}"
- functions[autoload]=':zi-tmp-subst-autoload "$@";'
- fi
-
- # E. Always shade compdef.
- (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}"
- functions[compdef]=':zi-tmp-subst-compdef "$@";'
-
- # Temporarily replace `source' if subst'' given.
- if [[ -n ${ICE[subst]} ]] {
- (( ${+functions[source]} )) && ZI[bkp-source]="${functions[source]}"
- (( ${+functions[.]} )) && ZI[bkp-.]="${functions[.]}"
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- functions[source]=':zi-tmp-subst-source "$@";'
- functions[.]=':zi-tmp-subst-source "$@";'
- }
-
- # Light and compdef temporary substituting of functions stops here. Dtrace and load go on.
- [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
-
- # Defensive code, shouldn't be needed. A, B, C, D.
- builtin unset "ZI[bkp-bindkey]" "ZI[bkp-zstyle]" "ZI[bkp-alias]" "ZI[bkp-zle]"
-
- # A.
- (( ${+functions[bindkey]} )) && ZI[bkp-bindkey]="${functions[bindkey]}"
- functions[bindkey]=':zi-tmp-subst-bindkey "$@";'
-
- # B, when `zi light -b ...' or when `zi ice trackbinds ...; zi light ...'.
- [[ $mode = light-b || ( $mode = light && ${+ICE[trackbinds]} -eq 1 ) ]] && return 0
-
- # B.
- (( ${+functions[zstyle]} )) && ZI[bkp-zstyle]="${functions[zstyle]}"
- functions[zstyle]=':zi-tmp-subst-zstyle "$@";'
-
- # C.
- (( ${+functions[alias]} )) && ZI[bkp-alias]="${functions[alias]}"
- functions[alias]=':zi-tmp-subst-alias "$@";'
-
- # D.
- (( ${+functions[zle]} )) && ZI[bkp-zle]="${functions[zle]}"
- functions[zle]=':zi-tmp-subst-zle "$@";'
-
- builtin return 0
+ local mode="$1"
+
+ # Enable temporary substituting of functions only once.
+ #
+ # One could expect possibility of widening of temporary substituting of functions, however
+ # such sequence doesn't exist, e.g. "light" then "load"/"dtrace", "compdef" then "load"/
+ # "dtrace", "light" then "compdef", "compdef" then "light".
+ #
+ # It is always "dtrace" then "load" (i.e. dtrace then load) "dtrace" then "light" (i.e.:
+ # dtrace then light load) "dtrace" then "compdef" (i.e.: dtrace then snippet).
+ [[ ${ZI[TMP_SUBST]} != inactive ]] && builtin return 0
+
+ ZI[TMP_SUBST]="$mode"
+
+ # The point about backuping is: does the key exist in functions array.
+ # If it does exist, then it will also exist as ZI[bkp-*].
+
+ # Defensive code, shouldn't be needed.
+ builtin unset "ZI[bkp-autoload]" "ZI[bkp-compdef]" # 0, E.
+
+ if [[ $mode != compdef ]]; then
+ # 0. Used, but not in temporary restoration, which doesn't happen for autoload.
+ (( ${+functions[autoload]} )) && ZI[bkp-autoload]="${functions[autoload]}"
+ functions[autoload]=':zi-tmp-subst-autoload "$@";'
+ fi
+
+ # E. Always shade compdef.
+ (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}"
+ functions[compdef]=':zi-tmp-subst-compdef "$@";'
+
+ # Temporarily replace `source' if subst'' given.
+ if [[ -n ${ICE[subst]} ]] {
+ (( ${+functions[source]} )) && ZI[bkp-source]="${functions[source]}"
+ (( ${+functions[.]} )) && ZI[bkp-.]="${functions[.]}"
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ functions[source]=':zi-tmp-subst-source "$@";'
+ functions[.]=':zi-tmp-subst-source "$@";'
+ }
+
+ # Light and compdef temporary substituting of functions stops here. Dtrace and load go on.
+ [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
+
+ # Defensive code, shouldn't be needed. A, B, C, D.
+ builtin unset "ZI[bkp-bindkey]" "ZI[bkp-zstyle]" "ZI[bkp-alias]" "ZI[bkp-zle]"
+
+ # A.
+ (( ${+functions[bindkey]} )) && ZI[bkp-bindkey]="${functions[bindkey]}"
+ functions[bindkey]=':zi-tmp-subst-bindkey "$@";'
+
+ # B, when `zi light -b ...' or when `zi ice trackbinds ...; zi light ...'.
+ [[ $mode = light-b || ( $mode = light && ${+ICE[trackbinds]} -eq 1 ) ]] && return 0
+
+ # B.
+ (( ${+functions[zstyle]} )) && ZI[bkp-zstyle]="${functions[zstyle]}"
+ functions[zstyle]=':zi-tmp-subst-zstyle "$@";'
+
+ # C.
+ (( ${+functions[alias]} )) && ZI[bkp-alias]="${functions[alias]}"
+ functions[alias]=':zi-tmp-subst-alias "$@";'
+
+ # D.
+ (( ${+functions[zle]} )) && ZI[bkp-zle]="${functions[zle]}"
+ functions[zle]=':zi-tmp-subst-zle "$@";'
+
+ builtin return 0
} # ]]]
# FUNCTION: .zi-tmp-subst-off. [[[
# Turn off temporary substituting of functions completely for a given mode ("load", "light",
# "light-b" (i.e. the `trackbinds' mode) or "compdef").
.zi-tmp-subst-off() {
- builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal \
- typesetsilent noshortloops unset noaliases
- local mode="$1"
+ builtin setopt localoptions noerrreturn noerrexit extendedglob warncreateglobal typesetsilent noshortloops unset noaliases
+ local mode="$1"
- # Disable temporary substituting of functions only once.
- # Disable temporary substituting of functions only the way it was enabled first.
- [[ ${ZI[TMP_SUBST]} = inactive || ${ZI[TMP_SUBST]} != $mode ]] && return 0
+ # Disable temporary substituting of functions only once.
+ # Disable temporary substituting of functions only the way it was enabled first.
+ [[ ${ZI[TMP_SUBST]} = inactive || ${ZI[TMP_SUBST]} != $mode ]] && return 0
- ZI[TMP_SUBST]=inactive
+ ZI[TMP_SUBST]=inactive
- if [[ $mode != compdef ]]; then
- # 0. Unfunction autoload.
- (( ${+ZI[bkp-autoload]} )) && functions[autoload]="${ZI[bkp-autoload]}" || unfunction autoload
- fi
+ if [[ $mode != compdef ]]; then
+ # 0. Unfunction autoload.
+ (( ${+ZI[bkp-autoload]} )) && functions[autoload]="${ZI[bkp-autoload]}" || unfunction autoload
+ fi
- # E. Restore original compdef if it existed.
- (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef
+ # E. Restore original compdef if it existed.
+ (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef
- # Restore the possible source function.
- (( ${+ZI[bkp-source]} )) && functions[source]="${ZI[bkp-source]}" || unfunction source 2>/dev/null
- (( ${+ZI[bkp-.]} )) && functions[.]="${ZI[bkp-.]}" || unfunction . 2> /dev/null
+ # Restore the possible source function.
+ (( ${+ZI[bkp-source]} )) && functions[source]="${ZI[bkp-source]}" || unfunction source 2>/dev/null
+ (( ${+ZI[bkp-.]} )) && functions[.]="${ZI[bkp-.]}" || unfunction . 2> /dev/null
- # Light and compdef temporary substituting of functions stops here.
- [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
+ # Light and compdef temporary substituting of functions stops here.
+ [[ ( $mode = light && ${+ICE[trackbinds]} -eq 0 ) || $mode = compdef ]] && return 0
- # Unfunction temporary substituting of functions functions.
+ # Unfunction temporary substituting of functions functions.
- # A.
- (( ${+ZI[bkp-bindkey]} )) && functions[bindkey]="${ZI[bkp-bindkey]}" || unfunction bindkey
+ # A.
+ (( ${+ZI[bkp-bindkey]} )) && functions[bindkey]="${ZI[bkp-bindkey]}" || unfunction bindkey
- # When `zi light -b ...' or when `zi ice trackbinds ...; zi light ...'.
- [[ $mode = light-b || ( $mode = light && ${+ICE[trackbinds]} -eq 1 ) ]] && return 0
+ # When `zi light -b ...' or when `zi ice trackbinds ...; zi light ...'.
+ [[ $mode = light-b || ( $mode = light && ${+ICE[trackbinds]} -eq 1 ) ]] && return 0
- # B.
- (( ${+ZI[bkp-zstyle]} )) && functions[zstyle]="${ZI[bkp-zstyle]}" || unfunction zstyle
- # C.
- (( ${+ZI[bkp-alias]} )) && functions[alias]="${ZI[bkp-alias]}" || unfunction alias
- # D.
- (( ${+ZI[bkp-zle]} )) && functions[zle]="${ZI[bkp-zle]}" || unfunction zle
+ # B.
+ (( ${+ZI[bkp-zstyle]} )) && functions[zstyle]="${ZI[bkp-zstyle]}" || unfunction zstyle
+ # C.
+ (( ${+ZI[bkp-alias]} )) && functions[alias]="${ZI[bkp-alias]}" || unfunction alias
+ # D.
+ (( ${+ZI[bkp-zle]} )) && functions[zle]="${ZI[bkp-zle]}" || unfunction zle
- return 0
+ return 0
} # ]]]
# FUNCTION: pmodload. [[[
# {function:pmodload} Compatibility with Prezto. Calls can be recursive.
(( ${+functions[pmodload]} )) || pmodload() {
- local -A ices
- (( ${+ICE} )) && ices=( "${(kv)ICE[@]}" teleid '' )
- local -A ICE ZI_ICE
- ICE=( "${(kv)ices[@]}" ) ZI_ICE=( "${(kv)ices[@]}" )
- while (( $# )); do
- ICE[teleid]="PZT::modules/$1${ICE[svn]-/init.zsh}"
- ZI_ICE[teleid]="PZT::modules/$1${ICE[svn]-/init.zsh}"
- if zstyle -t ":prezto:module:$1" loaded 'yes' 'no'; then
- shift
- continue
- else
- [[ -z ${ZI_SNIPPETS[PZT::modules/$1${ICE[svn]-/init.zsh}]} && -z ${ZI_SNIPPETS[https://github.com/sorin-ionescu/prezto/trunk/modules/$1${ICE[svn]-/init.zsh}]} ]] && .zi-load-snippet PZT::modules/"$1${ICE[svn]-/init.zsh}"
- shift
- fi
- done
-}
-# ]]]
+ local -A ices
+ (( ${+ICE} )) && ices=( "${(kv)ICE[@]}" teleid '' )
+ local -A ICE ZI_ICE
+ ICE=( "${(kv)ices[@]}" ) ZI_ICE=( "${(kv)ices[@]}" )
+ while (( $# )); do
+ ICE[teleid]="PZT::modules/$1${ICE[svn]-/init.zsh}"
+ ZI_ICE[teleid]="PZT::modules/$1${ICE[svn]-/init.zsh}"
+ if zstyle -t ":prezto:module:$1" loaded 'yes' 'no'; then
+ shift
+ continue
+ else
+ [[ -z ${ZI_SNIPPETS[PZT::modules/$1${ICE[svn]-/init.zsh}]} && -z ${ZI_SNIPPETS[https://github.com/sorin-ionescu/prezto/trunk/modules/$1${ICE[svn]-/init.zsh}]} ]] && .zi-load-snippet PZT::modules/"$1${ICE[svn]-/init.zsh}"
+ shift
+ fi
+ done
+} # ]]]
#
# Diff functions.
@@ -830,14 +775,11 @@ builtin setopt noaliases
# $1 - user/plugin (i.e. uspl2 format)
# $2 - command, can be "begin" or "end"
.zi-diff-functions() {
- local uspl2="$1"
- local cmd="$2"
-
- [[ $cmd = begin ]] && \
- { [[ -z ${ZI[FUNCTIONS_BEFORE__$uspl2]} ]] && \
- ZI[FUNCTIONS_BEFORE__$uspl2]="${(j: :)${(qk)functions[@]}}"
- } || \
- ZI[FUNCTIONS_AFTER__$uspl2]+=" ${(j: :)${(qk)functions[@]}}"
+ local uspl2="$1"
+ local cmd="$2"
+
+ [[ $cmd = begin ]] && { [[ -z ${ZI[FUNCTIONS_BEFORE__$uspl2]} ]] && ZI[FUNCTIONS_BEFORE__$uspl2]="${(j: :)${(qk)functions[@]}}"
+ } || ZI[FUNCTIONS_AFTER__$uspl2]+=" ${(j: :)${(qk)functions[@]}}"
} # ]]]
# FUNCTION: .zi-diff-options. [[[
# Implements detection of change in option state. Performs
@@ -846,13 +788,9 @@ builtin setopt noaliases
# $1 - user/plugin (i.e. uspl2 format)
# $2 - command, can be "begin" or "end"
.zi-diff-options() {
- local IFS=" "
-
- [[ $2 = begin ]] && \
- { [[ -z ${ZI[OPTIONS_BEFORE__$uspl2]} ]] && \
- ZI[OPTIONS_BEFORE__$1]="${(kv)options[@]}"
- } || \
- ZI[OPTIONS_AFTER__$1]+=" ${(kv)options[@]}"
+ local IFS=" "
+ [[ $2 = begin ]] && { [[ -z ${ZI[OPTIONS_BEFORE__$uspl2]} ]] && ZI[OPTIONS_BEFORE__$1]="${(kv)options[@]}"
+ } || ZI[OPTIONS_AFTER__$1]+=" ${(kv)options[@]}"
} # ]]]
# FUNCTION: .zi-diff-env. [[[
# Implements detection of change in PATH and FPATH.
@@ -860,24 +798,21 @@ builtin setopt noaliases
# $1 - user/plugin (i.e. uspl2 format)
# $2 - command, can be "begin" or "end"
.zi-diff-env() {
- typeset -a tmp
- local IFS=" "
-
- [[ $2 = begin ]] && {
- { [[ -z ${ZI[PATH_BEFORE__$uspl2]} ]] && \
- tmp=( "${(q)path[@]}" )
- ZI[PATH_BEFORE__$1]="${tmp[*]}"
- }
- { [[ -z ${ZI[FPATH_BEFORE__$uspl2]} ]] && \
- tmp=( "${(q)fpath[@]}" )
- ZI[FPATH_BEFORE__$1]="${tmp[*]}"
- }
- } || {
- tmp=( "${(q)path[@]}" )
- ZI[PATH_AFTER__$1]+=" ${tmp[*]}"
- tmp=( "${(q)fpath[@]}" )
- ZI[FPATH_AFTER__$1]+=" ${tmp[*]}"
+ typeset -a tmp
+ local IFS=" "
+ [[ $2 = begin ]] && {
+ { [[ -z ${ZI[PATH_BEFORE__$uspl2]} ]] && tmp=( "${(q)path[@]}" )
+ ZI[PATH_BEFORE__$1]="${tmp[*]}"
+ }
+ { [[ -z ${ZI[FPATH_BEFORE__$uspl2]} ]] && tmp=( "${(q)fpath[@]}" )
+ ZI[FPATH_BEFORE__$1]="${tmp[*]}"
}
+ } || {
+ tmp=( "${(q)path[@]}" )
+ ZI[PATH_AFTER__$1]+=" ${tmp[*]}"
+ tmp=( "${(q)fpath[@]}" )
+ ZI[FPATH_AFTER__$1]+=" ${tmp[*]}"
+ }
} # ]]]
# FUNCTION: .zi-diff-parameter. [[[
# Implements detection of change in any parameter's existence and type.
@@ -886,25 +821,22 @@ builtin setopt noaliases
# $1 - user/plugin (i.e. uspl2 format)
# $2 - command, can be "begin" or "end"
.zi-diff-parameter() {
- typeset -a tmp
-
- [[ $2 = begin ]] && {
- { [[ -z ${ZI[PARAMETERS_BEFORE__$uspl2]} ]] && \
- ZI[PARAMETERS_BEFORE__$1]="${(j: :)${(qkv)parameters[@]}}"
- }
- } || {
- ZI[PARAMETERS_AFTER__$1]+=" ${(j: :)${(qkv)parameters[@]}}"
- }
+ typeset -a tmp
+ [[ $2 = begin ]] && {
+ { [[ -z ${ZI[PARAMETERS_BEFORE__$uspl2]} ]] && ZI[PARAMETERS_BEFORE__$1]="${(j: :)${(qkv)parameters[@]}}"
+ }
+ } || {
+ ZI[PARAMETERS_AFTER__$1]+=" ${(j: :)${(qkv)parameters[@]}}"
+ }
} # ]]]
# FUNCTION: .zi-diff. [[[
# Performs diff actions of all types
.zi-diff() {
- .zi-diff-functions "$1" "$2"
- .zi-diff-options "$1" "$2"
- .zi-diff-env "$1" "$2"
- .zi-diff-parameter "$1" "$2"
-}
-# ]]]
+ .zi-diff-functions "$1" "$2"
+ .zi-diff-options "$1" "$2"
+ .zi-diff-env "$1" "$2"
+ .zi-diff-parameter "$1" "$2"
+} # ]]]
#
# Utility functions.
@@ -912,13 +844,13 @@ builtin setopt noaliases
# FUNCTION: .zi-get-mtime-into. [[[
.zi-get-mtime-into() {
- if (( ZI[HAVE_ZSTAT] )) {
- local -a arr
- { zstat +mtime -A arr "$1"; } 2>/dev/null
- : ${(P)2::="${arr[1]}"}
- } else {
- { : ${(P)2::="$(stat -c %Y "$1")"}; } 2>/dev/null
- }
+ if (( ZI[HAVE_ZSTAT] )) {
+ local -a arr
+ { zstat +mtime -A arr "$1"; } 2>/dev/null
+ : ${(P)2::="${arr[1]}"}
+ } else {
+ { : ${(P)2::="$(stat -c %Y "$1")"}; } 2>/dev/null
+ }
} # ]]]
# FUNCTION: .zi-any-to-user-plugin. [[[
# Allows elastic plugin-spec across the code.
@@ -929,266 +861,248 @@ builtin setopt noaliases
# Returns user and plugin in $reply.
#
.zi-any-to-user-plugin() {
- emulate -LR zsh
- builtin setopt extendedglob typesetsilent noshortloops rcquotes \
- ${${${+reply}:#0}:+warncreateglobal}
-
- # Two components given?
- # That's a pretty fast track to call this function this way.
- if [[ -n $2 ]]; then
- 2=${~2}
- reply=( ${1:-${${(M)2#/}:+%}} ${${${(M)1#%}:+$2}:-${2//---//}} )
- return 0
- fi
-
- # Is it absolute path?
- if [[ $1 = /* ]]; then
- reply=( % $1 )
- return 0
- fi
-
- # Is it absolute path in zi format?
- if [[ $1 = %* ]]; then
- local -A map
- map=( ZPFX "$ZPFX" HOME $HOME SNIPPETS $ZI[SNIPPETS_DIR] PLUGINS $ZI[PLUGINS_DIR] )
- reply=( % ${${1/(#b)(#s)%(${(~j:|:)${(@k)map}}|)/$map[$match[1]]}} )
- reply[2]=${~reply[2]}
- return 0
- fi
-
- # Rest is for single component given.
- # It doesn't touch $2
-
- 1=${1//---//}
- if [[ $1 = */* ]]; then
- reply=( ${1%%/*} ${1#*/} )
- return 0
- fi
-
- reply=( "" "${1:-_unknown}" )
-
+ emulate -LR zsh
+ builtin setopt extendedglob typesetsilent noshortloops rcquotes ${${${+reply}:#0}:+warncreateglobal}
+ # Two components given?
+ # That's a pretty fast track to call this function this way.
+ if [[ -n $2 ]]; then
+ 2=${~2}
+ reply=( ${1:-${${(M)2#/}:+%}} ${${${(M)1#%}:+$2}:-${2//---//}} )
+ return 0
+ fi
+ # Is it absolute path?
+ if [[ $1 = /* ]]; then
+ reply=( % $1 )
return 0
+ fi
+ # Is it absolute path in zi format?
+ if [[ $1 = %* ]]; then
+ local -A map
+ map=( ZPFX "$ZPFX" HOME $HOME SNIPPETS $ZI[SNIPPETS_DIR] PLUGINS $ZI[PLUGINS_DIR] )
+ reply=( % ${${1/(#b)(#s)%(${(~j:|:)${(@k)map}}|)/$map[$match[1]]}} )
+ reply[2]=${~reply[2]}
+ return 0
+ fi
+ # Rest is for single component given.
+ # It doesn't touch $2
+ 1=${1//---//}
+ if [[ $1 = */* ]]; then
+ reply=( ${1%%/*} ${1#*/} )
+ return 0
+ fi
+ reply=( "" "${1:-_unknown}" )
+
+ return 0
} # ]]]
# FUNCTION: .zi-any-to-pid. [[[
.zi-any-to-pid() {
- emulate -LR zsh
- builtin setopt extendedglob typesetsilent noshortloops rcquotes \
- ${${${+REPLY}:#0}:+warncreateglobal}
-
- 1=${~1} 2=${~2}
-
- # Two components given?
- if [[ -n $2 ]] {
- if [[ $1 == (%|/)* || ( -z $1 && $2 == /* ) ]] {
- .zi-util-shands-path $1${${(M)1#(%/?|%[^/]|/?)}:+/}$2
- REPLY=${${REPLY:#%*}:+%}$REPLY
- } else {
- REPLY=$1${1:+/}$2
- }
- return 0
- }
-
- # Is it absolute path?
- if [[ $1 = (%|/|\~)* ]] {
- .zi-util-shands-path $1
- REPLY=${${REPLY:#%*}:+%}$REPLY
- return 0
- }
-
- # Single component given.
- REPLY=${1//---//}
-
+ emulate -LR zsh
+ builtin setopt extendedglob typesetsilent noshortloops rcquotes ${${${+REPLY}:#0}:+warncreateglobal}
+
+ 1=${~1} 2=${~2}
+
+ # Two components given?
+ if [[ -n $2 ]] {
+ if [[ $1 == (%|/)* || ( -z $1 && $2 == /* ) ]] {
+ .zi-util-shands-path $1${${(M)1#(%/?|%[^/]|/?)}:+/}$2
+ REPLY=${${REPLY:#%*}:+%}$REPLY
+ } else {
+ REPLY=$1${1:+/}$2
+ }
+ return 0
+ }
+ # Is it absolute path?
+ if [[ $1 = (%|/|\~)* ]] {
+ .zi-util-shands-path $1
+ REPLY=${${REPLY:#%*}:+%}$REPLY
return 0
+ }
+ # Single component given.
+ REPLY=${1//---//}
+
+ return 0
} # ]]]
# FUNCTION: .zi-util-shands-path. [[[
# Replaces parts of path with %HOME, etc.
.zi-util-shands-path() {
- emulate -LR zsh
- builtin setopt extendedglob typesetsilent noshortloops rcquotes \
- ${${${+REPLY}:#0}:+warncreateglobal}
-
- local -A map
- map=( \~ %HOME $HOME %HOME $ZI[SNIPPETS_DIR] %SNIPPETS $ZI[PLUGINS_DIR] %PLUGINS
- "$ZPFX" %ZPFX HOME %HOME SNIPPETS %SNIPPETS PLUGINS %PLUGINS "" "" )
- REPLY=${${1/(#b)(#s)(%|)(${(~j:|:)${(@k)map:#$HOME}}|$HOME|)/$map[$match[2]]}}
- return 0
+ emulate -LR zsh
+ builtin setopt extendedglob typesetsilent noshortloops rcquotes ${${${+REPLY}:#0}:+warncreateglobal}
+
+ local -A map
+ map=( \~ %HOME $HOME %HOME $ZI[SNIPPETS_DIR] %SNIPPETS $ZI[PLUGINS_DIR] %PLUGINS
+ "$ZPFX" %ZPFX HOME %HOME SNIPPETS %SNIPPETS PLUGINS %PLUGINS "" "" )
+ REPLY=${${1/(#b)(#s)(%|)(${(~j:|:)${(@k)map:#$HOME}}|$HOME|)/$map[$match[2]]}}
+ return 0
} # ]]]
# FUNCTION: .zi-find-other-matches. [[[
# Plugin's main source file is in general `name.plugin.zsh'. However,
# there can be different conventions, if that file is not found, then
# this functions examines other conventions in the most sane order.
.zi-find-other-matches() {
- local pdir_path="$1" pbase="$2"
-
- if [[ -e $pdir_path/init.zsh ]] {
- reply=( "$pdir_path"/init.zsh )
- } elif [[ -e $pdir_path/$pbase.zsh-theme ]] {
- reply=( "$pdir_path/$pbase".zsh-theme )
- } elif [[ -e $pdir_path/$pbase.theme.zsh ]] {
- reply=( "$pdir_path/$pbase".theme.zsh )
- } else {
- reply=(
- "$pdir_path"/*.plugin.zsh(DN) "$pdir_path"/*.zsh-theme(DN) "$pdir_path"/*.lib.zsh(DN)
- "$pdir_path"/*.zsh(DN) "$pdir_path"/*.sh(DN) "$pdir_path"/.zshrc(DN)
- )
- }
- reply=( "${(u)reply[@]}" )
+ local pdir_path="$1" pbase="$2"
+
+ if [[ -e $pdir_path/init.zsh ]] {
+ reply=( "$pdir_path"/init.zsh )
+ } elif [[ -e $pdir_path/$pbase.zsh-theme ]] {
+ reply=( "$pdir_path/$pbase".zsh-theme )
+ } elif [[ -e $pdir_path/$pbase.theme.zsh ]] {
+ reply=( "$pdir_path/$pbase".theme.zsh )
+ } else {
+ reply=(
+ "$pdir_path"/*.plugin.zsh(DN) "$pdir_path"/*.zsh-theme(DN) "$pdir_path"/*.lib.zsh(DN)
+ "$pdir_path"/*.zsh(DN) "$pdir_path"/*.sh(DN) "$pdir_path"/.zshrc(DN)
+ )
+ }
+ reply=( "${(u)reply[@]}" )
- return $(( ${#reply} > 0 ? 0 : 1 ))
+ return $(( ${#reply} > 0 ? 0 : 1 ))
} # ]]]
# FUNCTION: .zi-register-plugin. [[[
# Adds the plugin to ZI_REGISTERED_PLUGINS array and to the
# zsh_loaded_plugins array (managed according to the plugin standard:
# http://z-shell.github.io/ZSH-TOP-100/Zsh-Plugin-Standard.html).
.zi-register-plugin() {
- local uspl2="$1" mode="$2" teleid="$3"
- integer ret=0
-
- if [[ -z ${ZI_REGISTERED_PLUGINS[(r)$uspl2]} ]]; then
- ZI_REGISTERED_PLUGINS+=( "$uspl2" )
- else
- # Allow overwrite-load, however warn about it.
- [[ -z ${ZI[TEST]}${${+ICE[wait]}:#0}${ICE[load]}${ICE[subscribe]} && ${ZI[MUTE_WARNINGS]} != (1|true|on|yes) ]] && +zi-message "{u-warn}Warning{b-warn}:{rst} plugin {apo}\`{pid}${uspl2}{apo}\`{rst} already registered, will overwrite-load."
- ret=1
- fi
-
- # Support Zsh plugin standard.
- zsh_loaded_plugins+=( "$teleid" )
-
- # Full or light load?
- [[ $mode == light ]] && ZI[STATES__$uspl2]=1 || ZI[STATES__$uspl2]=2
-
- ZI_REPORTS[$uspl2]= ZI_CUR_BIND_MAP=( empty 1 )
- # Functions.
- ZI[FUNCTIONS_BEFORE__$uspl2]= ZI[FUNCTIONS_AFTER__$uspl2]=
- ZI[FUNCTIONS__$uspl2]=
- # Objects.
- ZI[ZSTYLES__$uspl2]= ZI[BINDKEYS__$uspl2]=
- ZI[ALIASES__$uspl2]=
- # Widgets.
- ZI[WIDGETS_SAVED__$uspl2]= ZI[WIDGETS_DELETE__$uspl2]=
- # Rest (options and (f)path).
- ZI[OPTIONS__$uspl2]= ZI[PATH__$uspl2]=
- ZI[OPTIONS_BEFORE__$uspl2]= ZI[OPTIONS_AFTER__$uspl2]=
- ZI[FPATH__$uspl2]=
-
- return ret
+ local uspl2="$1" mode="$2" teleid="$3"
+ integer ret=0
+
+ if [[ -z ${ZI_REGISTERED_PLUGINS[(r)$uspl2]} ]]; then
+ ZI_REGISTERED_PLUGINS+=( "$uspl2" )
+ else
+ # Allow overwrite-load, however warn about it.
+ [[ -z ${ZI[TEST]}${${+ICE[wait]}:#0}${ICE[load]}${ICE[subscribe]} && ${ZI[MUTE_WARNINGS]} != (1|true|on|yes) ]] && +zi-message "{u-warn}Warning{b-warn}:{rst} plugin {apo}\`{pid}${uspl2}{apo}\`{rst} already registered, will overwrite-load."
+ ret=1
+ fi
+
+ # Support Zsh plugin standard.
+ zsh_loaded_plugins+=( "$teleid" )
+
+ # Full or light load?
+ [[ $mode == light ]] && ZI[STATES__$uspl2]=1 || ZI[STATES__$uspl2]=2
+
+ ZI_REPORTS[$uspl2]= ZI_CUR_BIND_MAP=( empty 1 )
+ # Functions.
+ ZI[FUNCTIONS_BEFORE__$uspl2]= ZI[FUNCTIONS_AFTER__$uspl2]=
+ ZI[FUNCTIONS__$uspl2]=
+ # Objects.
+ ZI[ZSTYLES__$uspl2]= ZI[BINDKEYS__$uspl2]=
+ ZI[ALIASES__$uspl2]=
+ # Widgets.
+ ZI[WIDGETS_SAVED__$uspl2]= ZI[WIDGETS_DELETE__$uspl2]=
+ # Rest (options and (f)path).
+ ZI[OPTIONS__$uspl2]= ZI[PATH__$uspl2]=
+ ZI[OPTIONS_BEFORE__$uspl2]= ZI[OPTIONS_AFTER__$uspl2]=
+ ZI[FPATH__$uspl2]=
+
+ return ret
} # ]]]
# FUNCTION: .zi-get-object-path. [[[
.zi-get-object-path() {
- local type="$1" id_as="$2" local_dir dirname
- integer exists
+ local type="$1" id_as="$2" local_dir dirname
+ integer exists
- id_as="${ICE[id-as]:-$id_as}"
+ id_as="${ICE[id-as]:-$id_as}"
- # Remove leading whitespace and trailing /.
- id_as="${${id_as#"${id_as%%[! $'\t']*}"}%/}"
+ # Remove leading whitespace and trailing /.
+ id_as="${${id_as#"${id_as%%[! $'\t']*}"}%/}"
- for type ( ${=${${(M)type:#AUTO}:+snippet plugin}:-$type} ) {
- if [[ $type == snippet ]] {
- dirname="${${id_as%%\?*}:t}"
- local_dir="${${${id_as%%\?*}/:\/\//--}:h}"
- [[ $local_dir = . ]] && local_dir= || local_dir="${${${${${local_dir#/}//\//--}//=/-EQ-}//\?/-QM-}//\&/-AMP-}"
- local_dir="${ZI[SNIPPETS_DIR]}${local_dir:+/$local_dir}"
- } else {
- .zi-any-to-user-plugin "$id_as"
- local_dir=${${${(M)reply[-2]:#%}:+${reply[2]}}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}
- [[ $id_as == _local/* && -d $local_dir && ! -d $local_dir/._zi ]] && command mkdir -p "$local_dir"/._zi
- dirname=""
- }
- [[ -e $local_dir/${dirname:+$dirname/}._zi || \
- -e $local_dir/${dirname:+$dirname/}._zplugin ]] && exists=1
-
- (( exists )) && break
+ for type ( ${=${${(M)type:#AUTO}:+snippet plugin}:-$type} ) {
+ if [[ $type == snippet ]] {
+ dirname="${${id_as%%\?*}:t}"
+ local_dir="${${${id_as%%\?*}/:\/\//--}:h}"
+ [[ $local_dir = . ]] && local_dir= || local_dir="${${${${${local_dir#/}//\//--}//=/-EQ-}//\?/-QM-}//\&/-AMP-}"
+ local_dir="${ZI[SNIPPETS_DIR]}${local_dir:+/$local_dir}"
+ } else {
+ .zi-any-to-user-plugin "$id_as"
+ local_dir=${${${(M)reply[-2]:#%}:+${reply[2]}}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}
+ [[ $id_as == _local/* && -d $local_dir && ! -d $local_dir/._zi ]] && command mkdir -p "$local_dir"/._zi
+ dirname=""
}
+ [[ -e $local_dir/${dirname:+$dirname/}._zi || \
+ -e $local_dir/${dirname:+$dirname/}._zplugin ]] && exists=1
+ (( exists )) && break
+ }
- reply=( "$local_dir" "$dirname" "$exists" )
- REPLY="$local_dir${dirname:+/$dirname}"
+ reply=( "$local_dir" "$dirname" "$exists" )
+ REPLY="$local_dir${dirname:+/$dirname}"
- return $(( 1 - exists ))
-}
-# ]]]
+ return $(( 1 - exists ))
+} # ]]]
# FUNCTION: @zi-substitute. [[[
@zi-substitute() {
- emulate -LR zsh
- builtin setopt extendedglob warncreateglobal typesetsilent noshortloops
-
- local -A ___subst_map
- ___subst_map=(
- "%ID%" "${id_as_clean:-$id_as}"
- "%USER%" "$user"
- "%PLUGIN%" "${plugin:-$save_url}"
- "%URL%" "${save_url:-${user:+$user/}$plugin}"
- "%DIR%" "${local_path:-$local_dir${dirname:+/$dirname}}"
- '$ZPFX' "$ZPFX"
- '${ZPFX}' "$ZPFX"
- '%OS%' "${OSTYPE%(-gnu|[0-9]##)}" '%MACH%' "$MACHTYPE" '%CPU%' "$CPUTYPE"
- '%VENDOR%' "$VENDOR" '%HOST%' "$HOST" '%UID%' "$UID" '%GID%' "$GID"
- )
- if [[ -n ${ICE[param]} && ${ZI[SUBST_DONE_FOR]} != ${ICE[param]} ]] {
- ZI[SUBST_DONE_FOR]=${ICE[param]}
- ZI[PARAM_SUBST]=
- local -a ___params
- ___params=( ${(s.;.)ICE[param]} )
- local ___param ___from ___to
- for ___param ( ${___params[@]} ) {
- local ___from=${${___param%%([[:space:]]|)(->|→)*}##[[:space:]]##} \
- ___to=${${___param#*(->|→)([[:space:]]|)}%[[:space:]]}
- ___from=${___from//((#s)[[:space:]]##|[[:space:]]##(#e))/}
- ___to=${___to//((#s)[[:space:]]##|[[:space:]]##(#e))/}
- ZI[PARAM_SUBST]+="%${(q)___from}% ${(q)___to} "
- }
+ emulate -LR zsh
+ builtin setopt extendedglob warncreateglobal typesetsilent noshortloops
+
+ local -A ___subst_map
+ ___subst_map=(
+ "%ID%" "${id_as_clean:-$id_as}"
+ "%USER%" "$user"
+ "%PLUGIN%" "${plugin:-$save_url}"
+ "%URL%" "${save_url:-${user:+$user/}$plugin}"
+ "%DIR%" "${local_path:-$local_dir${dirname:+/$dirname}}"
+ '$ZPFX' "$ZPFX"
+ '${ZPFX}' "$ZPFX"
+ '%OS%' "${OSTYPE%(-gnu|[0-9]##)}" '%MACH%' "$MACHTYPE" '%CPU%' "$CPUTYPE"
+ '%VENDOR%' "$VENDOR" '%HOST%' "$HOST" '%UID%' "$UID" '%GID%' "$GID"
+ )
+ if [[ -n ${ICE[param]} && ${ZI[SUBST_DONE_FOR]} != ${ICE[param]} ]] {
+ ZI[SUBST_DONE_FOR]=${ICE[param]}
+ ZI[PARAM_SUBST]=
+ local -a ___params
+ ___params=( ${(s.;.)ICE[param]} )
+ local ___param ___from ___to
+ for ___param ( ${___params[@]} ) {
+ local ___from=${${___param%%([[:space:]]|)(->|→)*}##[[:space:]]##} \
+ ___to=${${___param#*(->|→)([[:space:]]|)}%[[:space:]]}
+ ___from=${___from//((#s)[[:space:]]##|[[:space:]]##(#e))/}
+ ___to=${___to//((#s)[[:space:]]##|[[:space:]]##(#e))/}
+ ZI[PARAM_SUBST]+="%${(q)___from}% ${(q)___to} "
}
-
- local -a ___add
- ___add=( "${ICE[param]:+${(@Q)${(@z)ZI[PARAM_SUBST]}}}" )
- (( ${#___add} % 2 == 0 )) && ___subst_map+=( "${___add[@]}" )
-
- local ___var_name
- for ___var_name; do
- local ___value=${(P)___var_name}
- ___value=${___value//(#m)(%[a-zA-Z0-9]##%|\$ZPFX|\$\{ZPFX\})/${___subst_map[$MATCH]}}
- : ${(P)___var_name::=$___value}
- done
-}
-# ]]]
+ }
+
+ local -a ___add
+ ___add=( "${ICE[param]:+${(@Q)${(@z)ZI[PARAM_SUBST]}}}" )
+ (( ${#___add} % 2 == 0 )) && ___subst_map+=( "${___add[@]}" )
+
+ local ___var_name
+ for ___var_name; do
+ local ___value=${(P)___var_name}
+ ___value=${___value//(#m)(%[a-zA-Z0-9]##%|\$ZPFX|\$\{ZPFX\})/${___subst_map[$MATCH]}}
+ : ${(P)___var_name::=$___value}
+ done
+} # ]]]
# FUNCTION: @zi-register-annex. [[[
# Registers the z-annex inside ZI – i.e. an ZI extension
@zi-register-annex() {
- local name="$1" type="$2" handler="$3" helphandler="$4" icemods="$5" key="z-annex ${(q)2}"
- ZI_EXTS[seqno]=$(( ${ZI_EXTS[seqno]:-0} + 1 ))
- ZI_EXTS[$key${${(M)type#hook:}:+ ${ZI_EXTS[seqno]}}]="${ZI_EXTS[seqno]} z-annex-data: ${(q)name} ${(q)type} ${(q)handler} ${(q)helphandler} ${(q)icemods}"
- () {
- emulate -LR zsh -o extendedglob
- integer index="${type##[%a-zA-Z:_!-]##}"
- ZI_EXTS[ice-mods]="${ZI_EXTS[ice-mods]}${icemods:+|}${(j:|:)${(@)${(@s:|:)icemods}/(#b)(#s)(?)/$index-$match[1]}}"
- }
-}
-# ]]]
+ local name="$1" type="$2" handler="$3" helphandler="$4" icemods="$5" key="z-annex ${(q)2}"
+ ZI_EXTS[seqno]=$(( ${ZI_EXTS[seqno]:-0} + 1 ))
+ ZI_EXTS[$key${${(M)type#hook:}:+ ${ZI_EXTS[seqno]}}]="${ZI_EXTS[seqno]} z-annex-data: ${(q)name} ${(q)type} ${(q)handler} ${(q)helphandler} ${(q)icemods}"
+ () {
+ emulate -LR zsh -o extendedglob
+ integer index="${type##[%a-zA-Z:_!-]##}"
+ ZI_EXTS[ice-mods]="${ZI_EXTS[ice-mods]}${icemods:+|}${(j:|:)${(@)${(@s:|:)icemods}/(#b)(#s)(?)/$index-$match[1]}}"
+ }
+} # ]]]
# FUNCTION: @zi-register-hook. [[[
# Registers the z-annex inside ZI – i.e. an ZI extension
@zi-register-hook() {
- local name="$1" type="$2" handler="$3" icemods="$4" key="zi ${(q)2}"
- ZI_EXTS2[seqno]=$(( ${ZI_EXTS2[seqno]:-0} + 1 ))
- ZI_EXTS2[$key${${(M)type#hook:}:+ ${ZI_EXTS2[seqno]}}]="${ZI_EXTS2[seqno]} z-annex-data: ${(q)name} ${(q)type} ${(q)handler} '' ${(q)icemods}"
- ZI_EXTS2[ice-mods]="${ZI_EXTS2[ice-mods]}${icemods:+|}$icemods"
-}
-# ]]]
+ local name="$1" type="$2" handler="$3" icemods="$4" key="zi ${(q)2}"
+ ZI_EXTS2[seqno]=$(( ${ZI_EXTS2[seqno]:-0} + 1 ))
+ ZI_EXTS2[$key${${(M)type#hook:}:+ ${ZI_EXTS2[seqno]}}]="${ZI_EXTS2[seqno]} z-annex-data: ${(q)name} ${(q)type} ${(q)handler} '' ${(q)icemods}"
+ ZI_EXTS2[ice-mods]="${ZI_EXTS2[ice-mods]}${icemods:+|}$icemods"
+} # ]]]
# FUNCTION: @zsh-plugin-run-on-update. [[[
# The Plugin Standard required mechanism, see:
# http://z-shell.github.io/ZSH-TOP-100/Zsh-Plugin-Standard.html
@zsh-plugin-run-on-unload() {
- ICE[ps-on-unload]="${(j.; .)@}"
- .zi-pack-ice "$id_as" ""
-}
-# ]]]
+ ICE[ps-on-unload]="${(j.; .)@}"
+ .zi-pack-ice "$id_as" ""
+} # ]]]
# FUNCTION: @zsh-plugin-run-on-update. [[[
# The Plugin Standard required mechanism
@zsh-plugin-run-on-update() {
- ICE[ps-on-update]="${(j.; .)@}"
- .zi-pack-ice "$id_as" ""
-}
-# ]]]
+ ICE[ps-on-update]="${(j.; .)@}"
+ .zi-pack-ice "$id_as" ""
+} # ]]]
#
# Remaining functions.
@@ -1198,99 +1112,91 @@ builtin setopt noaliases
# Creates all directories needed by ZI, first checks if they
# already exist.
.zi-prepare-home() {
- [[ -n ${ZI[HOME_READY]} ]] && return
- ZI[HOME_READY]=1
-
- [[ ! -d ${ZI[HOME_DIR]} ]] && {
- command mkdir -p "${ZI[HOME_DIR]}"
- # For compaudit.
- command chmod go-w "${ZI[HOME_DIR]}"
- # Also set up */bin and ZPFX in general.
- command mkdir 2>/dev/null -p $ZPFX/bin
- }
- [[ ! -d ${ZI[ZMODULES_DIR]} ]] && {
- command mkdir -p "${ZI[ZMODULES_DIR]}"
- # For compaudit.
- command chmod go-w "${ZI[ZMODULES_DIR]}"
-
- }
- [[ ! -d ${ZI[PLUGINS_DIR]}/_local---zi ]] && {
- command rm -rf "${ZI[PLUGINS_DIR]:-${TMPDIR:-/tmp}/132bcaCAB}/_local---zi"
- command mkdir -p "${ZI[PLUGINS_DIR]}/_local---zi"
- command chmod go-w "${ZI[PLUGINS_DIR]}"
- command ln -s "${ZI[BIN_DIR]}/lib/_zi" "${ZI[PLUGINS_DIR]}/_local---zi"
-
- # Also set up */bin and ZPFX in general.
- command mkdir 2>/dev/null -p $ZPFX/bin
-
- (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
- .zi-clear-completions &>/dev/null
- .zi-compinit &>/dev/null
- }
- [[ ! -d ${ZI[COMPLETIONS_DIR]} ]] && {
- command mkdir "${ZI[COMPLETIONS_DIR]}"
- # For compaudit.
- command chmod go-w "${ZI[COMPLETIONS_DIR]}"
-
- # Symlink _zi completion into _local---zi directory.
- command ln -s "${ZI[PLUGINS_DIR]}/_local---zi/_zi" "${ZI[COMPLETIONS_DIR]}"
-
- # Also set up */bin and ZPFX in general.
- command mkdir 2>/dev/null -p $ZPFX/bin
-
- (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- .zi-compinit &>/dev/null
- }
- [[ ! -d ${ZI[SNIPPETS_DIR]} ]] && {
- command mkdir -p "${ZI[SNIPPETS_DIR]}/OMZ::plugins"
- command chmod go-w "${ZI[SNIPPETS_DIR]}"
- ( builtin cd ${ZI[SNIPPETS_DIR]}; command ln -s OMZ::plugins plugins; )
-
- # Also create the SERVICES_DIR.
- command mkdir -p "${ZI[SERVICES_DIR]}"
- command chmod go-w "${ZI[SERVICES_DIR]}"
-
- # Also set up */bin and ZPFX in general.
- command mkdir 2>/dev/null -p $ZPFX/bin
- }
+ [[ -n ${ZI[HOME_READY]} ]] && return
+ ZI[HOME_READY]=1
+
+ [[ ! -d ${ZI[HOME_DIR]} ]] && {
+ command mkdir -p "${ZI[HOME_DIR]}"
+ # For compaudit.
+ command chmod go-w "${ZI[HOME_DIR]}"
+ # Also set up */bin and ZPFX in general.
+ command mkdir 2>/dev/null -p $ZPFX/bin
+ }
+ [[ ! -d ${ZI[ZMODULES_DIR]} ]] && {
+ command mkdir -p "${ZI[ZMODULES_DIR]}"
+ # For compaudit.
+ command chmod go-w "${ZI[ZMODULES_DIR]}"
+ }
+ [[ ! -d ${ZI[PLUGINS_DIR]}/_local---zi ]] && {
+ command rm -rf "${ZI[PLUGINS_DIR]:-${TMPDIR:-/tmp}/132bcaCAB}/_local---zi"
+ command mkdir -p "${ZI[PLUGINS_DIR]}/_local---zi"
+ command chmod go-w "${ZI[PLUGINS_DIR]}"
+ command ln -s "${ZI[BIN_DIR]}/lib/_zi" "${ZI[PLUGINS_DIR]}/_local---zi"
+ # Also set up */bin and ZPFX in general.
+ command mkdir 2>/dev/null -p $ZPFX/bin
+ (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ .zi-clear-completions &>/dev/null
+ .zi-compinit &>/dev/null
+ }
+ [[ ! -d ${ZI[COMPLETIONS_DIR]} ]] && {
+ command mkdir "${ZI[COMPLETIONS_DIR]}"
+ # For compaudit.
+ command chmod go-w "${ZI[COMPLETIONS_DIR]}"
+ # Symlink _zi completion into _local---zi directory.
+ command ln -s "${ZI[PLUGINS_DIR]}/_local---zi/_zi" "${ZI[COMPLETIONS_DIR]}"
+ # Also set up */bin and ZPFX in general.
+ command mkdir 2>/dev/null -p $ZPFX/bin
+ (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ .zi-compinit &>/dev/null
+ }
+ [[ ! -d ${ZI[SNIPPETS_DIR]} ]] && {
+ command mkdir -p "${ZI[SNIPPETS_DIR]}/OMZ::plugins"
+ command chmod go-w "${ZI[SNIPPETS_DIR]}"
+ ( builtin cd ${ZI[SNIPPETS_DIR]}; command ln -s OMZ::plugins plugins; )
+ # Also create the SERVICES_DIR.
+ command mkdir -p "${ZI[SERVICES_DIR]}"
+ command chmod go-w "${ZI[SERVICES_DIR]}"
+ # Also set up */bin and ZPFX in general.
+ command mkdir 2>/dev/null -p $ZPFX/bin
+ }
} # ]]]
# FUNCTION: .zi-load-object. [[[
.zi-load-object() {
- local ___type="$1" ___id=$2
- local -a ___opt
- ___opt=( ${@[3,-1]} )
-
- if [[ $___type == snippet ]] {
- .zi-load-snippet $___opt "$___id"
- } elif [[ $___type == plugin ]] {
- .zi-load "$___id" "" $___opt
- }
- ___retval+=$?
-
- return __retval
+ local ___type="$1" ___id=$2
+ local -a ___opt
+ ___opt=( ${@[3,-1]} )
+
+ if [[ $___type == snippet ]] {
+ .zi-load-snippet $___opt "$___id"
+ } elif [[ $___type == plugin ]] {
+ .zi-load "$___id" "" $___opt
+ }
+ ___retval+=$?
+
+ return __retval
}
# ]]]
# FUNCTION:.zi-set-m-func() [[[
# Sets and withdraws the temporary, atclone/atpull time function `m`.
.zi-set-m-func() {
- if [[ $1 == set ]]; then
- ZI[___m_bkp]="${functions[m]}"
- setopt noaliases
- functions[m]="${functions[+zi-message]}"
- setopt aliases
- elif [[ $1 == unset ]]; then
- if [[ -n ${ZI[___m_bkp]} ]]; then
- setopt noaliases
- functions[m]="${ZI[___m_bkp]}"
- setopt aliases
- else
- noglob unset functions[m]
- fi
+ if [[ $1 == set ]]; then
+ ZI[___m_bkp]="${functions[m]}"
+ setopt noaliases
+ functions[m]="${functions[+zi-message]}"
+ setopt aliases
+ elif [[ $1 == unset ]]; then
+ if [[ -n ${ZI[___m_bkp]} ]]; then
+ setopt noaliases
+ functions[m]="${ZI[___m_bkp]}"
+ setopt aliases
else
- +zi-message "{error}ERROR #1"
- return 1
+ noglob unset functions[m]
fi
+ else
+ +zi-message "{error}ERROR #1"
+ return 1
+ fi
}
# ]]]
# FUNCTION: .zi-load-snippet. [[[
@@ -1298,240 +1204,236 @@ builtin setopt noaliases
#
# $1 - url (can be local, absolute path).
.zi-load-snippet() {
- typeset -F 3 SECONDS=0
- local -a opts
- zparseopts -E -D -a opts f -command || { +zi-message "{u-warn}Error{b-warn}:{rst} Incorrect options (accepted ones: {opt}-f{rst}, {opt}--command{rst})."; return 1; }
- local url="$1"
- [[ -n ${ICE[teleid]} ]] && url="${ICE[teleid]}"
- # Hide arguments from sourced scripts. Without this calls our "$@" are visible as "$@"
- # within scripts that we `source`.
- builtin set --
- integer correct retval exists
- [[ -o ksharrays ]] && correct=1
-
- [[ -n ${ICE[(i)(\!|)(sh|bash|ksh|csh)]}${ICE[opts]} ]] && {
- local -a precm
- precm=(
- emulate
- ${${(M)${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:+-R}
- ${${${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:-zsh}
- ${${ICE[(i)(\!|)bash]}:+-${(s: :):-o noshglob -o braceexpand -o kshglob}}
- ${(s: :):-${${:-${(@s: :):--o}" "${(s: :)^ICE[opts]}}:#-o }}
- -c
- )
- }
- # Remove leading whitespace and trailing /.
- url="${${url#"${url%%[! $'\t']*}"}%/}"
- ICE[teleid]="${ICE[teleid]:-$url}"
- [[ ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ]] && \
- ICE[pick]="${ICE[pick]:-/dev/null}"
-
- local local_dir dirname filename save_url="$url"
-
- # Allow things like $OSTYPE in the URL.
- eval "url=\"$url\""
-
- local id_as="${ICE[id-as]:-$url}"
-
- .zi-set-m-func set
+ typeset -F 3 SECONDS=0
+ local -a opts
+ zparseopts -E -D -a opts f -command || { +zi-message "{u-warn}Error{b-warn}:{rst} Incorrect options (accepted ones: {opt}-f{rst}, {opt}--command{rst})."; return 1; }
+ local url="$1"
+ [[ -n ${ICE[teleid]} ]] && url="${ICE[teleid]}"
+ # Hide arguments from sourced scripts. Without this calls our "$@" are visible as "$@"
+ # within scripts that we `source`.
+ builtin set --
+ integer correct retval exists
+ [[ -o ksharrays ]] && correct=1
+ [[ -n ${ICE[(i)(\!|)(sh|bash|ksh|csh)]}${ICE[opts]} ]] && {
+ local -a precm
+ precm=(
+ emulate
+ ${${(M)${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:+-R}
+ ${${${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:-zsh}
+ ${${ICE[(i)(\!|)bash]}:+-${(s: :):-o noshglob -o braceexpand -o kshglob}}
+ ${(s: :):-${${:-${(@s: :):--o}" "${(s: :)^ICE[opts]}}:#-o }}
+ -c
+ )
+ }
+ # Remove leading whitespace and trailing /.
+ url="${${url#"${url%%[! $'\t']*}"}%/}"
+ ICE[teleid]="${ICE[teleid]:-$url}"
+ [[ ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ]] && ICE[pick]="${ICE[pick]:-/dev/null}"
+ local local_dir dirname filename save_url="$url"
+
+ # Allow things like $OSTYPE in the URL.
+ eval "url=\"$url\""
+
+ local id_as="${ICE[id-as]:-$url}"
+
+ .zi-set-m-func set
+
+ # Set up param'' objects (parameters).
+ if [[ -n ${ICE[param]} ]] {
+ .zi-setup-params && local ${(Q)reply[@]}
+ }
+
+ .zi-pack-ice "$id_as" ""
+
+ # Oh-My-Zsh, Prezto and manual shorthands.
+ [[ $url = *(${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}}|robbyrussell*oh-my-zsh|ohmyzsh/ohmyzsh)* ]] && local ZSH="${ZI[SNIPPETS_DIR]}"
+
+ # Construct containing directory, extract final directory
+ # into handy-variable $dirname.
+ .zi-get-object-path snippet "$id_as"
+ filename="${reply[-2]}" dirname="${reply[-2]}"
+ local_dir="${reply[-3]}" exists=${reply[-1]}
+
+ local -a arr
+ local key
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
+ )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" load || \
+ return $(( 10 - $? ))
+ done
+
+ # Download or copy the file.
+ if [[ -n ${opts[(r)-f]} || $exists -eq 0 ]] {
+ (( ${+functions[.zi-download-snippet]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ .zi-download-snippet "$save_url" "$url" "$id_as" "$local_dir" "$dirname" "$filename"
+ retval=$?
+ }
+
+ (( ${+ICE[cloneonly]} || retval )) && return 0
+
+ ZI_SNIPPETS[$id_as]="$id_as <${${ICE[svn]+svn}:-single file}>"
+
+ ZI[CUR_USPL2]="$id_as" ZI_REPORTS[$id_as]=
+
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atinit-<-> <->]} )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" \!atinit || \
+ return $(( 10 - $? ))
+ done
+
+ (( ${+ICE[atinit]} )) && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:atinit-<-> <->]} )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" atinit || \
+ return $(( 10 - $? ))
+ done
+
+ local -a list
+ local ZERO
+
+ if [[ -z ${opts[(r)--command]} && ( -z ${ICE[as]} || ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ) ]]; then
+ # Source the file with compdef temporary substituting of functions.
+ if [[ ${ZI[TMP_SUBST]} = inactive ]]; then
+ # Temporary substituting of functions code is inlined from .zi-tmp-subst-on.
+ (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}" || builtin unset "ZI[bkp-compdef]"
+ functions[compdef]=':zi-tmp-subst-compdef "$@";'
+ ZI[TMP_SUBST]=1
+ else
+ (( ++ ZI[TMP_SUBST] ))
+ fi
- # Set up param'' objects (parameters).
- if [[ -n ${ICE[param]} ]] {
- .zi-setup-params && local ${(Q)reply[@]}
+ # Add to fpath.
+ if [[ -d $local_dir/$dirname/functions ]] {
+ [[ -z ${fpath[(r)$local_dir/$dirname/functions]} ]] && fpath+=( "$local_dir/$dirname/functions" )
+ () {
+ builtin setopt localoptions extendedglob
+ autoload $local_dir/$dirname/functions/^([_.]*|prompt_*_setup|README*)(D-.N:t)
+ }
}
- .zi-pack-ice "$id_as" ""
+ # Source.
+ if (( ${+ICE[svn]} == 0 )) {
+ [[ ${+ICE[pick]} = 0 ]] && list=( "$local_dir/$dirname/$filename" )
+ [[ -n ${ICE[pick]} ]] && list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
+ } else {
+ if [[ -n ${ICE[pick]} ]]; then
+ list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
+ elif (( ${+ICE[pick]} == 0 )); then
+ .zi-find-other-matches "$local_dir/$dirname" "$filename"
+ list=( ${reply[@]} )
+ fi
+ }
- # Oh-My-Zsh, Prezto and manual shorthands.
- [[ $url = *(${(~kj.|.)${(Mk)ZI_1MAP:#OMZ*}}|robbyrussell*oh-my-zsh|ohmyzsh/ohmyzsh)* ]] && local ZSH="${ZI[SNIPPETS_DIR]}"
+ if [[ -f ${list[1-correct]} ]] {
+ ZERO="${list[1-correct]}"
+ (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }
+ (( 0 == retval )) && [[ $url = PZT::* || $url = https://github.com/sorin-ionescu/prezto/* ]] && zstyle ":prezto:module:${${id_as%/init.zsh}:t}" loaded 'yes'
+ } else { [[ ${+ICE[silent]} -eq 1 || ${+ICE[pick]} -eq 1 && -z ${ICE[pick]} || ${ICE[pick]} = /dev/null ]] || { +zi-message "Snippet not loaded ({url}${id_as}{rst})"; retval=1; } }
- # Construct containing directory, extract final directory
- # into handy-variable $dirname.
- .zi-get-object-path snippet "$id_as"
- filename="${reply[-2]}" dirname="${reply[-2]}"
- local_dir="${reply[-3]}" exists=${reply[-1]}
+ [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$local_dir/$dirname/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; }
+ [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; }
- local -a arr
- local key
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
- )
+ # Run the atload hooks right before atload ice.
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]:-$ZI_EXTS2[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" "${${key##(zi|z-annex) hook:}%% <->}" load || \
- return $(( 10 - $? ))
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" \!atload
done
- # Download or copy the file.
- if [[ -n ${opts[(r)-f]} || $exists -eq 0 ]] {
- (( ${+functions[.zi-download-snippet]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- .zi-download-snippet "$save_url" "$url" "$id_as" "$local_dir" "$dirname" "$filename"
- retval=$?
+ # Run the functions' wrapping & tracking requests.
+ if [[ -n ${ICE[wrap]} ]] {
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-wrap-functions "$save_url" "" "$id_as"
}
- (( ${+ICE[cloneonly]} || retval )) && return 0
-
- ZI_SNIPPETS[$id_as]="$id_as <${${ICE[svn]+svn}:-single file}>"
-
- ZI[CUR_USPL2]="$id_as" ZI_REPORTS[$id_as]=
-
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atinit-<-> <->]} )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" \!atinit || \
- return $(( 10 - $? ))
- done
+ [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+
+ (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; }
+ elif [[ -n ${opts[(r)--command]} || ${ICE[as]} = command ]]; then
+ [[ ${+ICE[pick]} = 1 && -z ${ICE[pick]} ]] && ICE[pick]="${id_as:t}"
+ # Subversion - directory and multiple files possible.
+ if (( ${+ICE[svn]} )); then
+ if [[ -n ${ICE[pick]} ]]; then
+ list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
+ [[ -n ${list[1-correct]} ]] && local xpath="${list[1-correct]:h}" xfilepath="${list[1-correct]}"
+ else
+ local xpath="$local_dir/$dirname"
+ fi
+ else
+ local xpath="$local_dir/$dirname" xfilepath="$local_dir/$dirname/$filename"
+ # This doesn't make sense, but users may come up with something.
+ [[ -n ${ICE[pick]} ]] && {
+ list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
+ [[ -n ${list[1-correct]} ]] && xpath="${list[1-correct]:h}" xfilepath="${list[1-correct]}"
+ }
+ fi
+ [[ -n $xpath && -z ${path[(er)$xpath]} ]] && path=( "${xpath%/}" ${path[@]} )
+ [[ -n $xfilepath && -f $xfilepath && ! -x "$xfilepath" ]] && command chmod a+x "$xfilepath" ${list[@]:#$xfilepath}
+ [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
+ if [[ ${ZI[TMP_SUBST]} = inactive ]]; then
+ # Temporary substituting of functions code is inlined from .zi-tmp-subst-on.
+ (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}" || builtin unset "ZI[bkp-compdef]"
+ functions[compdef]=':zi-tmp-subst-compdef "$@";'
+ ZI[TMP_SUBST]=1
+ else
+ (( ++ ZI[TMP_SUBST] ))
+ fi
+ }
- (( ${+ICE[atinit]} )) && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ if [[ -n ${ICE[src]} ]]; then
+ ZERO="${${(M)ICE[src]##/*}:-$local_dir/$dirname/${ICE[src]}}"
+ (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }
+ fi
+ [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; }
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:atinit-<-> <->]} )
+ # Run the atload hooks right before atload ice.
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" atinit || \
- return $(( 10 - $? ))
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" \!atload
done
- local -a list
- local ZERO
-
- if [[ -z ${opts[(r)--command]} && ( -z ${ICE[as]} || ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ) ]]; then
- # Source the file with compdef temporary substituting of functions.
- if [[ ${ZI[TMP_SUBST]} = inactive ]]; then
- # Temporary substituting of functions code is inlined from .zi-tmp-subst-on.
- (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}" || builtin unset "ZI[bkp-compdef]"
- functions[compdef]=':zi-tmp-subst-compdef "$@";'
- ZI[TMP_SUBST]=1
- else
- (( ++ ZI[TMP_SUBST] ))
- fi
-
- # Add to fpath.
- if [[ -d $local_dir/$dirname/functions ]] {
- [[ -z ${fpath[(r)$local_dir/$dirname/functions]} ]] && fpath+=( "$local_dir/$dirname/functions" )
- () {
- builtin setopt localoptions extendedglob
- autoload $local_dir/$dirname/functions/^([_.]*|prompt_*_setup|README*)(D-.N:t)
- }
- }
-
- # Source.
- if (( ${+ICE[svn]} == 0 )) {
- [[ ${+ICE[pick]} = 0 ]] && list=( "$local_dir/$dirname/$filename" )
- [[ -n ${ICE[pick]} ]] && list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
- } else {
- if [[ -n ${ICE[pick]} ]]; then
- list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
- elif (( ${+ICE[pick]} == 0 )); then
- .zi-find-other-matches "$local_dir/$dirname" "$filename"
- list=( ${reply[@]} )
- fi
- }
-
- if [[ -f ${list[1-correct]} ]] {
- ZERO="${list[1-correct]}"
- (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }
- (( 0 == retval )) && [[ $url = PZT::* || $url = https://github.com/sorin-ionescu/prezto/* ]] && zstyle ":prezto:module:${${id_as%/init.zsh}:t}" loaded 'yes'
- } else { [[ ${+ICE[silent]} -eq 1 || ${+ICE[pick]} -eq 1 && -z ${ICE[pick]} || ${ICE[pick]} = /dev/null ]] || { +zi-message "Snippet not loaded ({url}${id_as}{rst})"; retval=1; } }
-
- [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$local_dir/$dirname/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; }
- [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; }
-
- # Run the atload hooks right before atload ice.
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" \!atload
- done
-
- # Run the functions' wrapping & tracking requests.
- if [[ -n ${ICE[wrap]} ]] {
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-wrap-functions "$save_url" "" "$id_as"
- }
-
- [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
-
- (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; }
- elif [[ -n ${opts[(r)--command]} || ${ICE[as]} = command ]]; then
- [[ ${+ICE[pick]} = 1 && -z ${ICE[pick]} ]] && \
- ICE[pick]="${id_as:t}"
- # Subversion - directory and multiple files possible.
- if (( ${+ICE[svn]} )); then
- if [[ -n ${ICE[pick]} ]]; then
- list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
- [[ -n ${list[1-correct]} ]] && local xpath="${list[1-correct]:h}" xfilepath="${list[1-correct]}"
- else
- local xpath="$local_dir/$dirname"
- fi
- else
- local xpath="$local_dir/$dirname" xfilepath="$local_dir/$dirname/$filename"
- # This doesn't make sense, but users may come up with something.
- [[ -n ${ICE[pick]} ]] && {
- list=( ${(M)~ICE[pick]##/*}(DN) $local_dir/$dirname/${~ICE[pick]}(DN) )
- [[ -n ${list[1-correct]} ]] && xpath="${list[1-correct]:h}" xfilepath="${list[1-correct]}"
- }
- fi
- [[ -n $xpath && -z ${path[(er)$xpath]} ]] && path=( "${xpath%/}" ${path[@]} )
- [[ -n $xfilepath && -f $xfilepath && ! -x "$xfilepath" ]] && command chmod a+x "$xfilepath" ${list[@]:#$xfilepath}
- [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
- if [[ ${ZI[TMP_SUBST]} = inactive ]]; then
- # Temporary substituting of functions code is inlined from .zi-tmp-subst-on.
- (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}" || builtin unset "ZI[bkp-compdef]"
- functions[compdef]=':zi-tmp-subst-compdef "$@";'
- ZI[TMP_SUBST]=1
- else
- (( ++ ZI[TMP_SUBST] ))
- fi
- }
-
- if [[ -n ${ICE[src]} ]]; then
- ZERO="${${(M)ICE[src]##/*}:-$local_dir/$dirname/${ICE[src]}}"
- (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }
- fi
- [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; }
-
- # Run the atload hooks right before atload ice.
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" \!atload
- done
-
- # Run the functions' wrapping & tracking requests.
- if [[ -n ${ICE[wrap]} ]] {
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-wrap-functions "$save_url" "" "$id_as"
- }
+ # Run the functions' wrapping & tracking requests.
+ if [[ -n ${ICE[wrap]} ]] {
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-wrap-functions "$save_url" "" "$id_as"
+ }
- [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
- [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
- (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; }
- }
- elif [[ ${ICE[as]} = completion ]]; then
- ((1))
- fi
+ [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
+ (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; }
+ }
+ elif [[ ${ICE[as]} = completion ]]; then
+ ((1))
+ fi
- (( ${+ICE[atload]} )) && [[ ${ICE[atload][1]} != "!" ]] && { ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ (( ${+ICE[atload]} )) && [[ ${ICE[atload][1]} != "!" ]] && { ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:atload-<-> <->]} )
- for key in "${reply[@]}"; do
- arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
- "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" atload
- done
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:atload-<-> <->]} )
+ for key in "${reply[@]}"; do
+ arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" )
+ "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" atload
+ done
- (( ${+ICE[notify]} == 1 )) && { [[ $retval -eq 0 || -n ${(M)ICE[notify]#\!} ]] && { local msg; eval "msg=\"${ICE[notify]#\!}\""; +zi-deploy-message @msg "$msg" } || +zi-deploy-message @msg "notify: Plugin not loaded / loaded with problem, the return code: $retval"; }
- (( ${+ICE[reset-prompt]} == 1 )) && +zi-deploy-message @rst
+ (( ${+ICE[notify]} == 1 )) && { [[ $retval -eq 0 || -n ${(M)ICE[notify]#\!} ]] && { local msg; eval "msg=\"${ICE[notify]#\!}\""; +zi-deploy-message @msg "$msg" } || +zi-deploy-message @msg "notify: Plugin not loaded / loaded with problem, the return code: $retval"; }
+ (( ${+ICE[reset-prompt]} == 1 )) && +zi-deploy-message @rst
- ZI[CUR_USPL2]=
- ZI[TIME_INDEX]=$(( ${ZI[TIME_INDEX]:-0} + 1 ))
- ZI[TIME_${ZI[TIME_INDEX]}_${id_as}]=$SECONDS
- ZI[AT_TIME_${ZI[TIME_INDEX]}_${id_as}]=$EPOCHREALTIME
+ ZI[CUR_USPL2]=
+ ZI[TIME_INDEX]=$(( ${ZI[TIME_INDEX]:-0} + 1 ))
+ ZI[TIME_${ZI[TIME_INDEX]}_${id_as}]=$SECONDS
+ ZI[AT_TIME_${ZI[TIME_INDEX]}_${id_as}]=$EPOCHREALTIME
- .zi-set-m-func unset
- return retval
+ .zi-set-m-func unset
+ return retval
} # ]]]
# FUNCTION: .zi-load. [[[
# Implements the exposed-to-user action of loading a plugin.
@@ -1539,104 +1441,106 @@ builtin setopt noaliases
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin name, if the third format is used
.zi-load () {
- typeset -F 3 SECONDS=0
- local ___mode="$3" ___rst=0 ___retval=0 ___key
- .zi-any-to-user-plugin "$1" "$2"
- local ___user="${reply[-2]}" ___plugin="${reply[-1]}" ___id_as="${ICE[id-as]:-${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}}"
- local ___pdir_path="${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"
- local ___pdir_orig="$___pdir_path"
- ZI[CUR_USR]="$___user" ZI[CUR_PLUGIN]="$___plugin" ZI[CUR_USPL2]="$___id_as"
- if [[ -n ${ICE[teleid]} ]] {
- .zi-any-to-user-plugin "${ICE[teleid]}"
- ___user="${reply[-2]}" ___plugin="${reply[-1]}"
- } else {
- ICE[teleid]="$___user${${___user:#%}:+/}$___plugin"
+ typeset -F 3 SECONDS=0
+ local ___mode="$3" ___rst=0 ___retval=0 ___key
+ .zi-any-to-user-plugin "$1" "$2"
+ local ___user="${reply[-2]}" ___plugin="${reply[-1]}" ___id_as="${ICE[id-as]:-${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}}"
+ local ___pdir_path="${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"
+ local ___pdir_orig="$___pdir_path"
+ ZI[CUR_USR]="$___user" ZI[CUR_PLUGIN]="$___plugin" ZI[CUR_USPL2]="$___id_as"
+ if [[ -n ${ICE[teleid]} ]] {
+ .zi-any-to-user-plugin "${ICE[teleid]}"
+ ___user="${reply[-2]}" ___plugin="${reply[-1]}"
+ } else {
+ ICE[teleid]="$___user${${___user:#%}:+/}$___plugin"
+ }
+
+ .zi-set-m-func set
+
+ local -a ___arr
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
+ )
+ for ___key in "${reply[@]}"; do
+ ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]:-$ZI_EXTS2[$___key]}[@]}" )
+ "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" "${${___key##(zi|z-annex) hook:}%% <->}" load || \
+ return $(( 10 - $? ))
+ done
+
+ if [[ $___user != % && ! -d ${ZI[PLUGINS_DIR]}/${___id_as//\//---} ]] {
+ (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ reply=( "$___user" "$___plugin" ) REPLY=github
+ if (( ${+ICE[pack]} )) {
+ if ! .zi-get-package "$___user" "$___plugin" "$___id_as" \
+ "${ZI[PLUGINS_DIR]}/${___id_as//\//---}" \
+ "${ICE[pack]:-default}"
+ then
+ zle && { builtin print; zle .reset-prompt; }
+ return 1
+ fi
+ ___id_as="${ICE[id-as]:-${___user}${${___user:#(%|/)*}:+/}$___plugin}"
}
-
- .zi-set-m-func set
-
- local -a ___arr
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:preinit-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:preinit-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:preinit-post <->]}
- )
- for ___key in "${reply[@]}"; do
- ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]:-$ZI_EXTS2[$___key]}[@]}" )
- "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" "${${___key##(zi|z-annex) hook:}%% <->}" load || \
- return $(( 10 - $? ))
- done
-
- if [[ $___user != % && ! -d ${ZI[PLUGINS_DIR]}/${___id_as//\//---} ]] {
- (( ${+functions[.zi-setup-plugin-dir]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- reply=( "$___user" "$___plugin" ) REPLY=github
- if (( ${+ICE[pack]} )) {
- if ! .zi-get-package "$___user" "$___plugin" "$___id_as" \
- "${ZI[PLUGINS_DIR]}/${___id_as//\//---}" \
- "${ICE[pack]:-default}"
- then
- zle && { builtin print; zle .reset-prompt; }
- return 1
- fi
- ___id_as="${ICE[id-as]:-${___user}${${___user:#(%|/)*}:+/}$___plugin}"
- }
- ___user="${reply[-2]}" ___plugin="${reply[-1]}"
- ICE[teleid]="$___user${${___user:#(%|/)*}:+/}$___plugin"
- [[ $REPLY = snippet ]] && {
- ICE[id-as]="${ICE[id-as]:-$___id_as}"
- .zi-load-snippet $___plugin && return
- zle && { builtin print; zle .reset-prompt; }
- return 1
- }
- if ! .zi-setup-plugin-dir "$___user" "$___plugin" "$___id_as" "$REPLY"; then
- zle && { builtin print; zle .reset-prompt; }
- return 1
- fi
- zle && ___rst=1
+ ___user="${reply[-2]}" ___plugin="${reply[-1]}"
+ ICE[teleid]="$___user${${___user:#(%|/)*}:+/}$___plugin"
+ [[ $REPLY = snippet ]] && {
+ ICE[id-as]="${ICE[id-as]:-$___id_as}"
+ .zi-load-snippet $___plugin && return
+ zle && { builtin print; zle .reset-prompt; }
+ return 1
}
+ .zi-setup-plugin-dir "$___user" "$___plugin" "$___id_as" "$REPLY"
+ local rc="$?"
+ if [[ "$rc" -ne 0 ]]; then
+ zle && { builtin print; zle .reset-prompt; }
+ return "$rc"
+ fi
+ zle && ___rst=1
+ }
- ZI_SICE[$___id_as]=
- .zi-pack-ice "$___id_as"
+ ZI_SICE[$___id_as]=
+ .zi-pack-ice "$___id_as"
- (( ${+ICE[cloneonly]} )) && return 0
+ (( ${+ICE[cloneonly]} )) && return 0
- .zi-register-plugin "$___id_as" "$___mode" "${ICE[teleid]}"
+ .zi-register-plugin "$___id_as" "$___mode" "${ICE[teleid]}"
- # Set up param'' objects (parameters).
- if [[ -n ${ICE[param]} ]] {
- .zi-setup-params && local ${(Q)reply[@]}
- }
+ # Set up param'' objects (parameters).
+ if [[ -n ${ICE[param]} ]] {
+ .zi-setup-params && local ${(Q)reply[@]}
+ }
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atinit-<-> <->]} )
- for ___key in "${reply[@]}"; do
- ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
- "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}" \!atinit || \
- return $(( 10 - $? ))
- done
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atinit-<-> <->]} )
+ for ___key in "${reply[@]}"; do
+ ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
+ "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}" \!atinit || \
+ return $(( 10 - $? ))
+ done
- [[ ${+ICE[atinit]} = 1 && $ICE[atinit] != '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ [[ ${+ICE[atinit]} = 1 && $ICE[atinit] != '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:atinit-<-> <->]} )
- for ___key in "${reply[@]}"; do
- ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
- "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}" atinit || \
- return $(( 10 - $? ))
- done
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:atinit-<-> <->]} )
+ for ___key in "${reply[@]}"; do
+ ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
+ "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}" atinit || \
+ return $(( 10 - $? ))
+ done
- .zi-load-plugin "$___user" "$___plugin" "$___id_as" "$___mode" "$___rst"; ___retval=$?
- (( ${+ICE[notify]} == 1 )) && { [[ $___retval -eq 0 || -n ${(M)ICE[notify]#\!} ]] && { local msg; eval "msg=\"${ICE[notify]#\!}\""; +zi-deploy-message @msg "$msg" } || +zi-deploy-message @msg "notify: Plugin not loaded / loaded with problem, the return code: $___retval"; }
- (( ${+ICE[reset-prompt]} == 1 )) && +zi-deploy-message @___rst
+ .zi-load-plugin "$___user" "$___plugin" "$___id_as" "$___mode" "$___rst"; ___retval=$?
+ (( ${+ICE[notify]} == 1 )) && { [[ $___retval -eq 0 || -n ${(M)ICE[notify]#\!} ]] && { local msg; eval "msg=\"${ICE[notify]#\!}\""; +zi-deploy-message @msg "$msg" } || +zi-deploy-message @msg "notify: Plugin not loaded / loaded with problem, the return code: $___retval"; }
+ (( ${+ICE[reset-prompt]} == 1 )) && +zi-deploy-message @___rst
- # Retire feature `m`.
- .zi-set-m-func unset
+ # Retire feature `m`.
+ .zi-set-m-func unset
- # Mark no load is in progress.
- ZI[CUR_USR]= ZI[CUR_PLUGIN]= ZI[CUR_USPL2]=
+ # Mark no load is in progress.
+ ZI[CUR_USR]= ZI[CUR_PLUGIN]= ZI[CUR_USPL2]=
- ZI[TIME_INDEX]=$(( ${ZI[TIME_INDEX]:-0} + 1 ))
- ZI[TIME_${ZI[TIME_INDEX]}_${___id_as//\//---}]=$SECONDS
- ZI[AT_TIME_${ZI[TIME_INDEX]}_${___id_as//\//---}]=$EPOCHREALTIME
- return ___retval
+ ZI[TIME_INDEX]=$(( ${ZI[TIME_INDEX]:-0} + 1 ))
+ ZI[TIME_${ZI[TIME_INDEX]}_${___id_as//\//---}]=$SECONDS
+ ZI[AT_TIME_${ZI[TIME_INDEX]}_${___id_as//\//---}]=$EPOCHREALTIME
+ return ___retval
} # ]]]
# FUNCTION: .zi-load-plugin. [[[
# Lower-level function for loading a plugin.
@@ -1645,184 +1549,181 @@ builtin setopt noaliases
# $2 - plugin
# $3 - mode (light or load)
.zi-load-plugin() {
- local ___user="$1" ___plugin="$2" ___id_as="$3" ___mode="$4" ___rst="$5" ___correct=0 ___retval=0
- local ___pbase="${${___plugin:t}%(.plugin.zsh|.zsh|.git)}" ___key
- # Hide arguments from sourced scripts. Without this calls our "$@" are visible as "$@"
- # within scripts that we `source`.
- builtin set --
- [[ -o ksharrays ]] && ___correct=1
-
- [[ -n ${ICE[(i)(\!|)(sh|bash|ksh|csh)]}${ICE[opts]} ]] && {
- local -a ___precm
- ___precm=(
- emulate
- ${${(M)${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:+-R}
- ${${${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:-zsh}
- ${${ICE[(i)(\!|)bash]}:+-${(s: :):-o noshglob -o braceexpand -o kshglob}}
- ${(s: :):-${${:-${(@s: :):--o}" "${(s: :)^ICE[opts]}}:#-o }}
- -c
- )
- }
+ local ___user="$1" ___plugin="$2" ___id_as="$3" ___mode="$4" ___rst="$5" ___correct=0 ___retval=0
+ local ___pbase="${${___plugin:t}%(.plugin.zsh|.zsh|.git)}" ___key
+ # Hide arguments from sourced scripts. Without this calls our "$@" are visible as "$@"
+ # within scripts that we `source`.
+ builtin set --
+ [[ -o ksharrays ]] && ___correct=1
+
+ [[ -n ${ICE[(i)(\!|)(sh|bash|ksh|csh)]}${ICE[opts]} ]] && {
+ local -a ___precm
+ ___precm=(
+ emulate
+ ${${(M)${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:+-R}
+ ${${${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:-zsh}
+ ${${ICE[(i)(\!|)bash]}:+-${(s: :):-o noshglob -o braceexpand -o kshglob}}
+ ${(s: :):-${${:-${(@s: :):--o}" "${(s: :)^ICE[opts]}}:#-o }}
+ -c
+ )
+ }
- [[ -z ${ICE[subst]} ]] && local ___builtin=builtin
+ [[ -z ${ICE[subst]} ]] && local ___builtin=builtin
- [[ ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ]] && \
- ICE[pick]="${ICE[pick]:-/dev/null}"
+ [[ ${ICE[as]} = null || ${+ICE[null]} -eq 1 || ${+ICE[binary]} -eq 1 ]] && ICE[pick]="${ICE[pick]:-/dev/null}"
- if [[ -n ${ICE[autoload]} ]] {
- :zi-tmp-subst-autoload -Uz \
- ${(s: :)${${${(s.;.)ICE[autoload]#[\!\#]}#[\!\#]}//(#b)((*)(->|=>|→)(*)|(*))/${match[2]:+$match[2] -S $match[4]}${match[5]:+${match[5]} -S ${match[5]}}}} \
- ${${(M)ICE[autoload]:#*(->|=>|→)*}:+-C} ${${(M)ICE[autoload]#(?\!|\!)}:+-C} ${${(M)ICE[autoload]#(?\#|\#)}:+-I}
+ if [[ -n ${ICE[autoload]} ]] {
+ :zi-tmp-subst-autoload -Uz \
+ ${(s: :)${${${(s.;.)ICE[autoload]#[\!\#]}#[\!\#]}//(#b)((*)(->|=>|→)(*)|(*))/${match[2]:+$match[2] -S $match[4]}${match[5]:+${match[5]} -S ${match[5]}}}} \
+ ${${(M)ICE[autoload]:#*(->|=>|→)*}:+-C} ${${(M)ICE[autoload]#(?\!|\!)}:+-C} ${${(M)ICE[autoload]#(?\#|\#)}:+-I}
+ }
+
+ if [[ ${ICE[as]} = command ]]; then
+ [[ ${+ICE[pick]} = 1 && -z ${ICE[pick]} ]] && ICE[pick]="${___id_as:t}"
+ reply=()
+ if [[ -n ${ICE[pick]} && ${ICE[pick]} != /dev/null ]]; then
+ reply=( ${(M)~ICE[pick]##/*}(DN) $___pdir_path/${~ICE[pick]}(DN) )
+ [[ -n ${reply[1-correct]} ]] && ___pdir_path="${reply[1-correct]:h}"
+ fi
+ [[ -z ${path[(er)$___pdir_path]} ]] && {
+ [[ $___mode != light ]] && .zi-diff-env "${ZI[CUR_USPL2]}" begin
+ path=( "${___pdir_path%/}" ${path[@]} )
+ [[ $___mode != light ]] && .zi-diff-env "${ZI[CUR_USPL2]}" end
+ .zi-add-report "${ZI[CUR_USPL2]}" "$ZI[col-info2]$___pdir_path$ZI[col-rst] added to \$PATH"
+ }
+ [[ -n ${reply[1-correct]} && ! -x ${reply[1-correct]} ]] && command chmod a+x ${reply[@]}
+ [[ ${ICE[atinit]} = '!'* || -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
+ if [[ ${ZI[TMP_SUBST]} = inactive ]]; then
+ (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}" || builtin unset "ZI[bkp-compdef]"
+ functions[compdef]=':zi-tmp-subst-compdef "$@";'
+ ZI[TMP_SUBST]=1
+ else
+ (( ++ ZI[TMP_SUBST] ))
+ fi
}
- if [[ ${ICE[as]} = command ]]; then
- [[ ${+ICE[pick]} = 1 && -z ${ICE[pick]} ]] && \
- ICE[pick]="${___id_as:t}"
- reply=()
- if [[ -n ${ICE[pick]} && ${ICE[pick]} != /dev/null ]]; then
- reply=( ${(M)~ICE[pick]##/*}(DN) $___pdir_path/${~ICE[pick]}(DN) )
- [[ -n ${reply[1-correct]} ]] && ___pdir_path="${reply[1-correct]:h}"
- fi
- [[ -z ${path[(er)$___pdir_path]} ]] && {
- [[ $___mode != light ]] && .zi-diff-env "${ZI[CUR_USPL2]}" begin
- path=( "${___pdir_path%/}" ${path[@]} )
- [[ $___mode != light ]] && .zi-diff-env "${ZI[CUR_USPL2]}" end
- .zi-add-report "${ZI[CUR_USPL2]}" "$ZI[col-info2]$___pdir_path$ZI[col-rst] added to \$PATH"
- }
- [[ -n ${reply[1-correct]} && ! -x ${reply[1-correct]} ]] && command chmod a+x ${reply[@]}
- [[ ${ICE[atinit]} = '!'* || -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
- if [[ ${ZI[TMP_SUBST]} = inactive ]]; then
- (( ${+functions[compdef]} )) && ZI[bkp-compdef]="${functions[compdef]}" || builtin unset "ZI[bkp-compdef]"
- functions[compdef]=':zi-tmp-subst-compdef "$@";'
- ZI[TMP_SUBST]=1
- else
- (( ++ ZI[TMP_SUBST] ))
- fi
- }
+ local ZERO
+ [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit#!]}"; ((1)); } || eval "${ICE[atinit]#!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$___pdir_orig/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; }
+ [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local ___fname; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; done; }
- local ZERO
- [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit#!]}"; ((1)); } || eval "${ICE[atinit]#!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
- [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$___pdir_orig/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; }
- [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local ___fname; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; done; }
-
- # Run the atload hooks right before atload ice.
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
- for ___key in "${reply[@]}"; do
- ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
- "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" \!atload
- done
-
- # Run the functions' wrapping & tracking requests.
- if [[ -n ${ICE[wrap]} ]] {
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-wrap-functions "$___user" "$___plugin" "$___id_as"
- }
+ # Run the atload hooks right before atload ice.
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
+ for ___key in "${reply[@]}"; do
+ ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
+ "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" \!atload
+ done
- [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ # Run the functions' wrapping & tracking requests.
+ if [[ -n ${ICE[wrap]} ]] {
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-wrap-functions "$___user" "$___plugin" "$___id_as"
+ }
- [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
- (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; }
- }
- elif [[ ${ICE[as]} = completion ]]; then
- ((1))
+ [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+
+ [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && {
+ (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; }
+ }
+ elif [[ ${ICE[as]} = completion ]]; then
+ ((1))
+ else
+ if [[ -n ${ICE[pick]} ]]; then
+ [[ ${ICE[pick]} = /dev/null ]] && reply=( /dev/null ) || reply=( ${(M)~ICE[pick]##/*}(DN) $___pdir_path/${~ICE[pick]}(DN) )
+ elif [[ -e $___pdir_path/$___pbase.plugin.zsh ]]; then
+ reply=( "$___pdir_path/$___pbase".plugin.zsh )
else
- if [[ -n ${ICE[pick]} ]]; then
- [[ ${ICE[pick]} = /dev/null ]] && reply=( /dev/null ) || reply=( ${(M)~ICE[pick]##/*}(DN) $___pdir_path/${~ICE[pick]}(DN) )
- elif [[ -e $___pdir_path/$___pbase.plugin.zsh ]]; then
- reply=( "$___pdir_path/$___pbase".plugin.zsh )
- else
- .zi-find-other-matches "$___pdir_path" "$___pbase"
- fi
+ .zi-find-other-matches "$___pdir_path" "$___pbase"
+ fi
- #[[ ${#reply} -eq 0 ]] && return 1
+ #[[ ${#reply} -eq 0 ]] && return 1
- # Get first one.
- local ___fname="${reply[1-correct]:t}"
- ___pdir_path="${reply[1-correct]:h}"
+ # Get first one.
+ local ___fname="${reply[1-correct]:t}"
+ ___pdir_path="${reply[1-correct]:h}"
- .zi-add-report "${ZI[CUR_USPL2]}" "Source $___fname ${${${(M)___mode:#light}:+(no reporting)}:-$ZI[col-info2](reporting enabled)$ZI[col-rst]}"
+ .zi-add-report "${ZI[CUR_USPL2]}" "Source $___fname ${${${(M)___mode:#light}:+(no reporting)}:-$ZI[col-info2](reporting enabled)$ZI[col-rst]}"
- # Light and compdef ___mode doesn't do diffs and temporary substituting of functions.
- [[ $___mode != light(|-b) ]] && .zi-diff "${ZI[CUR_USPL2]}" begin
+ # Light and compdef ___mode doesn't do diffs and temporary substituting of functions.
+ [[ $___mode != light(|-b) ]] && .zi-diff "${ZI[CUR_USPL2]}" begin
- .zi-tmp-subst-on "${___mode:-load}"
+ .zi-tmp-subst-on "${___mode:-load}"
- # We need some state, but ___user wants his for his plugins.
- (( ${+ICE[blockf]} )) && { local -a fpath_bkp; fpath_bkp=( "${fpath[@]}" ); }
- local ZERO="$___pdir_path/$___fname"
- (( ${+ICE[aliases]} )) || builtin setopt noaliases
- [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]#!}"; ((1)); } || eval "${ICE[atinit]#1}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
- (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }
- [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$___pdir_orig/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; }
- [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); } done; }
+ # We need some state, but ___user wants his for his plugins.
+ (( ${+ICE[blockf]} )) && { local -a fpath_bkp; fpath_bkp=( "${fpath[@]}" ); }
+ local ZERO="$___pdir_path/$___fname"
+ (( ${+ICE[aliases]} )) || builtin setopt noaliases
+ [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]#!}"; ((1)); } || eval "${ICE[atinit]#1}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }
+ [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$___pdir_orig/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; }
+ [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); } done; }
- # Run the atload hooks right before atload ice.
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
- for ___key in "${reply[@]}"; do
- ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
- "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" \!atload
- done
+ # Run the atload hooks right before atload ice.
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} )
+ for ___key in "${reply[@]}"; do
+ ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
+ "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" \!atload
+ done
- # Run the functions' wrapping & tracking requests.
- if [[ -n ${ICE[wrap]} ]] {
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-wrap-functions "$___user" "$___plugin" "$___id_as"
- }
+ # Run the functions' wrapping & tracking requests.
+ if [[ -n ${ICE[wrap]} ]] {
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-wrap-functions "$___user" "$___plugin" "$___id_as"
+ }
- [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
- (( ZI[ALIASES_OPT] )) && builtin setopt aliases
- (( ${+ICE[blockf]} )) && { fpath=( "${fpath_bkp[@]}" ); }
+ [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ (( ZI[ALIASES_OPT] )) && builtin setopt aliases
+ (( ${+ICE[blockf]} )) && { fpath=( "${fpath_bkp[@]}" ); }
- .zi-tmp-subst-off "${___mode:-load}"
+ .zi-tmp-subst-off "${___mode:-load}"
- [[ $___mode != light(|-b) ]] && .zi-diff "${ZI[CUR_USPL2]}" end
- fi
+ [[ $___mode != light(|-b) ]] && .zi-diff "${ZI[CUR_USPL2]}" end
+ fi
- [[ ${+ICE[atload]} = 1 && ${ICE[atload][1]} != "!" ]] && { ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
+ [[ ${+ICE[atload]} = 1 && ${ICE[atload][1]} != "!" ]] && { ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; }
- reply=( ${(on)ZI_EXTS[(I)z-annex hook:atload-<-> <->]} )
- for ___key in "${reply[@]}"; do
- ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
- "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" atload
- done
+ reply=( ${(on)ZI_EXTS[(I)z-annex hook:atload-<-> <->]} )
+ for ___key in "${reply[@]}"; do
+ ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" )
+ "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "$___pdir_orig" atload
+ done
- (( ___rst )) && { builtin print; zle .reset-prompt; }
+ (( ___rst )) && { builtin print; zle .reset-prompt; }
- return ___retval
+ return ___retval
} # ]]]
# FUNCTION: .zi-compdef-replay. [[[
-# Runs gathered compdef calls. This allows to run `compinit'
-# after loading plugins.
+# Runs gathered compdef calls. This allows to run `compinit' after loading plugins.
.zi-compdef-replay() {
- local quiet="$1"
- typeset -a pos
-
- # Check if compinit was loaded.
- if [[ ${+functions[compdef]} = 0 ]]; then
- +zi-message "{u-warn}Error{b-warn}:{rst} The {func}compinit{rst}" \
- "function hasn't been loaded, cannot do {it}{cmd}compdef replay{rst}."
- return 1
- fi
+ local quiet="$1"
+ typeset -a pos
- # In the same order.
- local cdf
- for cdf in "${ZI_COMPDEF_REPLAY[@]}"; do
- pos=( "${(z)cdf}" )
- # When ZI_COMPDEF_REPLAY empty (also when only white spaces).
- [[ ${#pos[@]} = 1 && -z ${pos[-1]} ]] && continue
- pos=( "${(Q)pos[@]}" )
- [[ $quiet = -q ]] || +zi-message "Running compdef: {cmd}${pos[*]}{rst}"
- compdef "${pos[@]}"
- done
-
- return 0
+ # Check if compinit was loaded.
+ if [[ ${+functions[compdef]} = 0 ]]; then
+ +zi-message "{u-warn}Error{b-warn}:{rst} The {func}compinit{rst}" \
+ "function hasn't been loaded, cannot do {it}{cmd}compdef replay{rst}."
+ return 1
+ fi
+
+ # In the same order.
+ local cdf
+ for cdf in "${ZI_COMPDEF_REPLAY[@]}"; do
+ pos=( "${(z)cdf}" )
+ # When ZI_COMPDEF_REPLAY empty (also when only white spaces).
+ [[ ${#pos[@]} = 1 && -z ${pos[-1]} ]] && continue
+ pos=( "${(Q)pos[@]}" )
+ [[ $quiet = -q ]] || +zi-message "Running compdef: {cmd}${pos[*]}{rst}"
+ compdef "${pos[@]}"
+ done
+
+ return 0
} # ]]]
# FUNCTION: .zi-compdef-clear. [[[
# Implements user-exposed functionality to clear gathered compdefs.
.zi-compdef-clear() {
- local quiet="$1" count="${#ZI_COMPDEF_REPLAY}"
- ZI_COMPDEF_REPLAY=( )
- [[ $quiet = -q ]] || +zi-message "Compdef-replay cleared (it had {num}${count}{rst} entries)."
+ local quiet="$1" count="${#ZI_COMPDEF_REPLAY}"
+ ZI_COMPDEF_REPLAY=( )
+ [[ $quiet = -q ]] || +zi-message "Compdef-replay cleared (it had {num}${count}{rst} entries)."
} # ]]]
# FUNCTION: .zi-add-report. [[[
# Adds a report line for given plugin.
@@ -1830,328 +1731,318 @@ builtin setopt noaliases
# $1 - uspl2, i.e. user/plugin
# $2, ... - the text
.zi-add-report() {
- # Use zi binary module if available.
- [[ -n $1 ]] && { (( ${+builtins[zpmod]} && 0 )) && zpmod report-append "$1" "$2"$'\n' || ZI_REPORTS[$1]+="$2"$'\n'; }
- [[ ${ZI[DTRACE]} = 1 ]] && { (( ${+builtins[zpmod]} )) && zpmod report-append _dtrace/_dtrace "$2"$'\n' || ZI_REPORTS[_dtrace/_dtrace]+="$2"$'\n'; }
- return 0
+ # Use zi binary module if available.
+ [[ -n $1 ]] && { (( ${+builtins[zpmod]} && 0 )) && zpmod report-append "$1" "$2"$'\n' || ZI_REPORTS[$1]+="$2"$'\n'; }
+ [[ ${ZI[DTRACE]} = 1 ]] && { (( ${+builtins[zpmod]} )) && zpmod report-append _dtrace/_dtrace "$2"$'\n' || ZI_REPORTS[_dtrace/_dtrace]+="$2"$'\n'; }
+ return 0
} # ]]]
# FUNCTION: .zi-add-fpath. [[[
.zi-add-fpath() {
- [[ $1 = (-f|--front) ]] && { shift; integer front=1; }
- .zi-any-to-user-plugin "$1" ""
- local id_as="$1" add_dir="$2" user="${reply[-2]}" plugin="${reply[-1]}"
- if (( front )) {
- fpath[1,0]=${${${(M)user:#%}:+$plugin}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}${add_dir:+/$add_dir}
- } else {
- fpath+=(
- ${${${(M)user:#%}:+$plugin}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}${add_dir:+/$add_dir}
- )
- }
+ [[ $1 = (-f|--front) ]] && { shift; integer front=1; }
+ .zi-any-to-user-plugin "$1" ""
+ local id_as="$1" add_dir="$2" user="${reply[-2]}" plugin="${reply[-1]}"
+ if (( front )) {
+ fpath[1,0]=${${${(M)user:#%}:+$plugin}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}${add_dir:+/$add_dir}
+ } else {
+ fpath+=(
+ ${${${(M)user:#%}:+$plugin}:-${ZI[PLUGINS_DIR]}/${id_as//\//---}}${add_dir:+/$add_dir}
+ )
+ }
}
# ]]]
# FUNCTION: .zi-run. [[[
# Run code inside plugin's folder
# It uses the `correct' parameter from upper's scope zi().
.zi-run() {
- if [[ $1 = (-l|--last) ]]; then
- { set -- "${ZI[last-run-plugin]:-$(<${ZI[BIN_DIR]}/last-run-object.txt)}" "${@[2-correct,-1]}"; } &>/dev/null
- [[ -z $1 ]] && { +zi-message "{u-warn}Error{b-warn}:{rst} No recent plugin-ID saved on the disk yet, please specify" \
- "it as the first argument, i.e.{ehi}: {cmd}zi run {pid}usr/plg{slight} {…}the code to run{…} "; return 1; }
- else
- integer ___nolast=1
- fi
- .zi-any-to-user-plugin "$1" ""
- local ___id_as="$1" ___user="${reply[-2]}" ___plugin="${reply[-1]}" ___oldpwd="$PWD"
- () {
- emulate -LR zsh
- builtin cd &>/dev/null -q ${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}} || {
- .zi-get-object-path snippet "$___id_as"
- builtin cd &>/dev/null -q $REPLY
- }
+ if [[ $1 = (-l|--last) ]]; then
+ { set -- "${ZI[last-run-plugin]:-$(<${ZI[BIN_DIR]}/last-run-object.txt)}" "${@[2-correct,-1]}"; } &>/dev/null
+ [[ -z $1 ]] && { +zi-message "{u-warn}Error{b-warn}:{rst} No recent plugin-ID saved on the disk yet, please specify" \
+ "it as the first argument, i.e.{ehi}: {cmd}zi run {pid}usr/plg{slight} {…}the code to run{…} "; return 1; }
+ else
+ integer ___nolast=1
+ fi
+ .zi-any-to-user-plugin "$1" ""
+ local ___id_as="$1" ___user="${reply[-2]}" ___plugin="${reply[-1]}" ___oldpwd="$PWD"
+ () {
+ emulate -LR zsh
+ builtin cd &>/dev/null -q ${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}} || {
+ .zi-get-object-path snippet "$___id_as"
+ builtin cd &>/dev/null -q $REPLY
}
- if (( $? == 0 )); then
- (( ___nolast )) && { builtin print -r "$1" >! ${ZI[BIN_DIR]}/last-run-object.txt; }
- ZI[last-run-plugin]="$1"
- eval "${@[2-correct,-1]}"
- () { setopt localoptions noautopushd; builtin cd -q "$___oldpwd"; }
- else
- +zi-message "{u-warn}Error{b-warn}:{rst} no such plugin or snippet."
- fi
+ }
+ if (( $? == 0 )); then
+ (( ___nolast )) && { builtin print -r "$1" >! ${ZI[BIN_DIR]}/last-run-object.txt; }
+ ZI[last-run-plugin]="$1"
+ eval "${@[2-correct,-1]}"
+ () { setopt localoptions noautopushd; builtin cd -q "$___oldpwd"; }
+ else
+ +zi-message "{u-warn}Error{b-warn}:{rst} no such plugin or snippet."
+ fi
}
# ]]]
# FUNCTION: +zi-deploy-message. [[[
# Deploys a sub-prompt message to be displayed OR a `zle
# .reset-prompt' call to be invoked
+zi-deploy-message() {
- [[ $1 = <-> && ( ${#} = 1 || ( $2 = (hup|nval|err) && ${#} = 2 ) ) ]] && { zle && {
- local alltext text IFS=$'\n' nl=$'\n'
- repeat 25; do read -r -u"$1" text; alltext+="${text:+$text$nl}"; done
- [[ $alltext = @rst$nl ]] && { builtin zle reset-prompt; ((1)); } || \
- { [[ -n $alltext ]] && builtin zle -M "$alltext"; }
- }
- builtin zle -F "$1"; exec {1}<&-
- return 0
- }
- local THEFD=13371337 hasw
- # The expansion is: if there is @sleep: pfx, then use what's after.
- # it, otherwise substitute 0
- exec {THEFD} < <(LANG=C sleep $(( 0.01 + ${${${(M)1#@sleep:}:+${1#@sleep:}}:-0} )); builtin print -r -- ${1:#(@msg|@sleep:*)} "${@[2,-1]}"; )
- command true # workaround a Zsh bug, see: http://www.zsh.org/mla/workers/2018/msg00966.html
- builtin zle -F "$THEFD" +zi-deploy-message
+ [[ $1 = <-> && ( ${#} = 1 || ( $2 = (hup|nval|err) && ${#} = 2 ) ) ]] && { zle && {
+ local alltext text IFS=$'\n' nl=$'\n'
+ repeat 25; do read -r -u"$1" text; alltext+="${text:+$text$nl}"; done
+ [[ $alltext = @rst$nl ]] && { builtin zle reset-prompt; ((1)); } || \
+ { [[ -n $alltext ]] && builtin zle -M "$alltext"; }
+ }
+ builtin zle -F "$1"; exec {1}<&-
+ return 0
+ }
+ local THEFD=13371337 hasw
+ # The expansion is: if there is @sleep: pfx, then use what's after. it, otherwise substitute 0
+ exec {THEFD} < <(LANG=C sleep $(( 0.01 + ${${${(M)1#@sleep:}:+${1#@sleep:}}:-0} )); builtin print -r -- ${1:#(@msg|@sleep:*)} "${@[2,-1]}"; )
+ command true # workaround a Zsh bug, see: http://www.zsh.org/mla/workers/2018/msg00966.html
+ builtin zle -F "$THEFD" +zi-deploy-message
}
# ]]]
# FUNCTION: .zi-formatter-pid. [[[
.zi-formatter-pid() {
- builtin emulate -L zsh -o extendedglob
+ builtin emulate -L zsh -o extendedglob
- # Remember extreme whitespace.
- local pbz=${(M)1##(#s)[[:space:]]##}
- local kbz=${(M)1%%[[:space:]]##(#e)}
- # Remove extreme whitespace.
- 1=${1//((#s)[[:space:]]##|[[:space:]]##(#e))/}
+ # Remember extreme whitespace.
+ local pbz=${(M)1##(#s)[[:space:]]##}
+ local kbz=${(M)1%%[[:space:]]##(#e)}
+ # Remove extreme whitespace.
+ 1=${1//((#s)[[:space:]]##|[[:space:]]##(#e))/}
- ((${+functions[.zi-first]})) || source ${ZI[BIN_DIR]}/lib/zsh/side.zsh
- .zi-any-colorify-as-uspl2 "$1";
+ ((${+functions[.zi-first]})) || source ${ZI[BIN_DIR]}/lib/zsh/side.zsh
+ .zi-any-colorify-as-uspl2 "$1";
- # Replace at least one character with an unbreakable space,
- # because extreme whitespace is lost due to implementation problems ...
- pbz=${pbz/[[:blank:]]/ }
- local kbz_rev="${(j::)${(@Oas::)kbz}}"
- kbz="${(j::)${(@Oas::)${kbz_rev/[[:blank:]]/ }}}"
+ # Replace at least one character with an unbreakable space,
+ # because extreme whitespace is lost due to implementation problems ...
+ pbz=${pbz/[[:blank:]]/ }
+ local kbz_rev="${(j::)${(@Oas::)kbz}}"
+ kbz="${(j::)${(@Oas::)${kbz_rev/[[:blank:]]/ }}}"
- # Supply extreme whitespace back.
- REPLY=$pbz$REPLY$kbz
+ # Supply extreme whitespace back.
+ REPLY=$pbz$REPLY$kbz
}
# ]]]
# FUNCTION: .zi-formatter-bar. [[[
.zi-formatter-bar() {
- .zi-formatter-bar-util ─ bar
+ .zi-formatter-bar-util ─ bar
}
# ]]]
# FUNCTION: .zi-formatter-th-bar. [[[
.zi-formatter-th-bar() {
- .zi-formatter-bar-util ━ th-bar
+ .zi-formatter-bar-util ━ th-bar
}
# FUNCTION: .zi-formatter-bar-util. [[[
.zi-formatter-bar-util() {
- if [[ $LANG == (#i)*utf-8* ]]; then
- ch=$1
- else
- ch=-
- fi
+ if [[ $LANG == (#i)*utf-8* ]]; then
+ ch=$1
+ else
+ ch=-
+ fi
- REPLY=$ZI[col-$2]${(pl:COLUMNS-1::$ch:):-}$ZI[col-rst]
+ REPLY=$ZI[col-$2]${(pl:COLUMNS-1::$ch:):-}$ZI[col-rst]
}
# ]]]
# FUNCTION: .zi-formatter-url. [[[
.zi-formatter-url() {
- builtin emulate -LR zsh -o extendedglob
- # 1:proto 3:domain/5:start 6:end-of-it 7:no-dot-domain 9:file-path
- if [[ $1 = (#b)([^:]#)(://|::)((([[:alnum:]._+-]##).([[:alnum:]_+-]##))|([[:alnum:].+_-]##))(|/(*)) ]] {
- # The advanced coloring if recognized the format…
- match[9]=${match[9]//\//"%F{227}%B"/"%F{81}%b"}
- if [[ -n $match[4] ]]; then
- REPLY="$(builtin print -Pr -- %F{220}$match[1]%F{227}$match[2]\
+ builtin emulate -LR zsh -o extendedglob
+ # 1:proto 3:domain/5:start 6:end-of-it 7:no-dot-domain 9:file-path
+ if [[ $1 = (#b)([^:]#)(://|::)((([[:alnum:]._+-]##).([[:alnum:]_+-]##))|([[:alnum:].+_-]##))(|/(*)) ]] {
+ # The advanced coloring if recognized the format…
+ match[9]=${match[9]//\//"%F{227}%B"/"%F{81}%b"}
+ if [[ -n $match[4] ]]; then
+ REPLY="$(builtin print -Pr -- %F{220}$match[1]%F{227}$match[2]\
%B%F{82}$match[5]\
%B%F{227}.\
%B%F{183}$match[6]%f%b)" # … this ·case· ends at: trailing component of the with-dot domain …
- else
- REPLY="$(builtin print -Pr -- %F{220}$match[1]%F{227}$match[2]\
+ else
+ REPLY="$(builtin print -Pr -- %F{220}$match[1]%F{227}$match[2]\
%B%F{82}$match[7]%f%b)" # … this ·case· ends at: no-dot domain …
- fi
- # Is there any file-path part in the URL?
- if [[ -n $match[9] ]]; then
- REPLY+="$(print -Pr -- \
+ fi
+ # Is there any file-path part in the URL?
+ if [[ -n $match[9] ]]; then
+ REPLY+="$(print -Pr -- \
%F{227}%B/%F{81}%b$match[9]%f%b)" # … append it. This ends the URL.
- fi
+ fi
#endif
- } else {
- # …revert to the basic if not…
- REPLY=$ZI[col-url]$1$ZI[col-rst]
- }
+ } else {
+ # …revert to the basic if not…
+ REPLY=$ZI[col-url]$1$ZI[col-rst]
+ }
}
# ]]]
# FUNCTION: +zi-message-formatter [[[
.zi-main-message-formatter() {
- if [[ -z $1 && -z $2 && -z $3 ]]; then
- REPLY=""
- return
- fi
- local append influx in_prepend
- if [[ $2 == (b|u|it|st|nb|nu|nit|nst) ]]; then
- append=$ZI[col-$2]
- elif [[ $2 == (…|ndsh|mdsh|mmdsh|-…|lr|) || -z $2 || -z $ZI[col-$2] ]]; then
- # Resume previous escape code, if stored.
- if [[ $ZI[__last-formatter-code] != (…|ndsh|mdsh|mmdsh|-…|lr|rst|nl|) ]]; then
- in_prepend=$ZI[col-$ZI[__last-formatter-code]]
- influx=$ZI[col-$ZI[__last-formatter-code]]
- fi
- else
- append=$ZI[col-rst]
+ if [[ -z $1 && -z $2 && -z $3 ]]; then
+ REPLY=""
+ return
+ fi
+ local append influx in_prepend
+ if [[ $2 == (b|u|it|st|nb|nu|nit|nst) ]]; then
+ append=$ZI[col-$2]
+ elif [[ $2 == (…|ndsh|mdsh|mmdsh|-…|lr|) || -z $2 || -z $ZI[col-$2] ]]; then
+ # Resume previous escape code, if stored.
+ if [[ $ZI[__last-formatter-code] != (…|ndsh|mdsh|mmdsh|-…|lr|rst|nl|) ]]; then
+ in_prepend=$ZI[col-$ZI[__last-formatter-code]]
+ influx=$ZI[col-$ZI[__last-formatter-code]]
fi
-
- # Construct the text.
- REPLY=$in_prepend${ZI[col-$2]:-$1}$influx$3$append
-
- # Replace new lines with characters that work the same but are not
- # deleted in the substitution $ (...) - vertical tab 0xB ↔ 13 in the system
- # octagonal connected back carriage (015).
- local nl=$'\n' vertical=$'\013' carriager=$'\015'
- REPLY=${REPLY//$nl/$vertical$carriager}
+ else
+ append=$ZI[col-rst]
+ fi
+ # Construct the text.
+ REPLY=$in_prepend${ZI[col-$2]:-$1}$influx$3$append
+ # Replace new lines with characters that work the same but are not
+ # deleted in the substitution $ (...) - vertical tab 0xB ↔ 13 in the system
+ # octagonal connected back carriage (015).
+ local nl=$'\n' vertical=$'\013' carriager=$'\015'
+ REPLY=${REPLY//$nl/$vertical$carriager}
# REPLY+="x(${3}…)"
-}
-# ]]]
+} # ]]]
# FUNCTION: +zi-message. [[[
+zi-message() {
- builtin emulate -LR zsh -o extendedglob
- local opt msg
- [[ $1 = -* ]] && { local opt=$1; shift; }
+ builtin emulate -LR zsh -o extendedglob
+ local opt msg
+ [[ $1 = -* ]] && { local opt=$1; shift; }
- ZI[__last-formatter-code]=
- msg=${${(j: :)${@:#--}}//\%/%%}
+ ZI[__last-formatter-code]=
+ msg=${${(j: :)${@:#--}}//\%/%%}
- # First try a dedicated formatter, marking its empty output with ←→, then
- # the general formatter and in the end filter-out the ←→ from the message.
- msg=${${msg//(#b)(([\\]|(%F))([\{]([^\}]##)[\}])|([\{]([^\}]##)[\}])([^\%\{\\]#))/\
+# First try a dedicated formatter, marking its empty output with ←→, then
+# the general formatter and in the end filter-out the ←→ from the message.
+msg=${${msg//(#b)(([\\]|(%F))([\{]([^\}]##)[\}])|([\{]([^\}]##)[\}])([^\%\{\\]#))/\
${match[4]:+${${match[3]:-$ZI[col-${ZI[__last-formatter-code]}]}:#%F}}$match[3]$match[4]\
-${${functions[.zi-formatter-$match[7]]:+\
-${$(.zi-formatter-$match[7] "$match[8]"; builtin print -rn -- $REPLY):-←→}}:-\
+${${functions[.zi-formatter-$match[7]]:+${$(.zi-formatter-$match[7] "$match[8]"; builtin print -rn -- $REPLY):-←→}}:-\
$(.zi-main-message-formatter "$match[6]" "$match[7]" "$match[8]"; \
- builtin print -rn -- "$REPLY"
-)${${ZI[__last-formatter-code]::=${${${match[7]:#(…|ndsh|mdsh|mmdsh|-…|lr)}:+\
-$match[7]}:-${ZI[__last-formatter-code]}}}:+}}}//←→}
-
- # Restore the default color at the end of the message.
- msg=$msg$ZI[col-rst]
- # Output the processed message:
- builtin print -Pr ${opt:#--} -- $msg
-
- # Needed to properly end a message with {nl}.
- if [[ -n ${opt:#*n*} || -z $opt ]]; then
- print -n $'\015'
- fi
+ builtin print -rn -- "$REPLY"
+)${${ZI[__last-formatter-code]::=${${${match[7]:#(…|ndsh|mdsh|mmdsh|-…|lr)}:+$match[7]}:-${ZI[__last-formatter-code]}}}:+}}}//←→}
+
+ # Restore the default color at the end of the message.
+ msg=$msg$ZI[col-rst]
+ # Output the processed message:
+ builtin print -Pr ${opt:#--} -- $msg
+
+ # Needed to properly end a message with {nl}.
+ if [[ -n ${opt:#*n*} || -z $opt ]]; then
+ print -n $'\015'
+ fi
}
# ]]]
# FUNCTION: +zi-prehelp-usage-message. [[[
+zi-prehelp-usage-message() {
- builtin emulate -LR zsh -o extendedglob
- local cmd=$1 allowed=$2 sep="$ZI[col-msg2], $ZI[col-ehi]" \
- sep2="$ZI[col-msg2], $ZI[col-opt]" bcol
-
- # -h/--help given?
- if (( OPTS[opt_-h,--help] )) {
- # Yes – a help message:
- +zi-message "{lhi}HELP FOR {apo}\`{cmd}$cmd{apo}\`{lhi} subcommand {mdsh}" \
- "the available {b-lhi}options{ehi}:{rst}"
- local opt
- for opt ( ${(kos:|:)allowed} ) {
- [[ $opt == --* ]] && continue
- local msg=${___opt_map[$opt]#*:} txt=${___opt_map[(r)opt_$opt,--[^:]##]}
- if [[ $msg == *":["* ]] {
- msg=${${(MS)msg##$cmd:\[[^]]##}:-${(MS)msg##\*:\[[^]]##}}
- msg=${msg#($cmd|\*):\[}
- }
- local pre_msg=`+zi-message -n {opt}${(r:14:)${txt#opt_}}`
- +zi-message ${(r:35:: :)pre_msg}{rst}{ehi}→{rst}" $msg"
- }
- } elif [[ -n $allowed ]] {
- shift 2
- # No – an error message:
- +zi-message "{b}{u-warn}ERROR{b-warn}:{rst}{msg2} Incorrect options given{ehi}:" \
- "${(Mpj:$sep:)@:#-*}{rst}{msg2}. Allowed for the subcommand{ehi}:{rst}" \
- "{apo}\`{cmd}$cmd{apo}\`{msg2} are{ehi}:{rst}" \
- "{nl}{mmdsh} {opt}${allowed//\|/$sep2}{msg2}." \
- "{nl}{…} Aborting.{rst}"
- } else {
- local -a cmds
- cmds=( load snippet update delete )
- local bcol="{$cmd}" sep="${ZI[col-rst]}${ZI[col-$cmd]}\`, \`${ZI[col-cmd]}"
- +zi-message "$bcol(it should be one of, e.g.{ehi}:" \
- "{nb}$bcol\`{cmd}${(pj:$sep:)cmds}$bcol\`," \
- "{cmd}{…}$bcol, e.g.{ehi}: {nb}$bcol\`{lhi}zi {b}{cmd}load" \
- "{pid}username/reponame$bcol\`) or a {b}{hi}for{nb}$bcol-based" \
- "command body (i.e.{ehi}:{rst}$bcol e.g.{ehi}: {rst}$bcol\`{lhi}zi" \
- "{…}{b}ice-spec{nb}{…} {hi}for{nb}{lhi} {…}({b}plugin" \
- "{nb}or{b} snippet) {pname}ID-1 ID-2 {-…} {lhi}{…}$bcol\`)." \
- "See \`{cmd}help$bcol\` for a more detailed usage information and" \
- "the list of the {cmd}subcommands$bcol.{rst}"
+ builtin emulate -LR zsh -o extendedglob
+ local cmd=$1 allowed=$2 sep="$ZI[col-msg2], $ZI[col-ehi]" \
+ sep2="$ZI[col-msg2], $ZI[col-opt]" bcol
+
+ # -h/--help given?
+ if (( OPTS[opt_-h,--help] )) {
+ # Yes – a help message:
+ +zi-message "{lhi}HELP FOR {apo}\`{cmd}$cmd{apo}\`{lhi} subcommand {mdsh}" \
+ "the available {b-lhi}options{ehi}:{rst}"
+ local opt
+ for opt ( ${(kos:|:)allowed} ) {
+ [[ $opt == --* ]] && continue
+ local msg=${___opt_map[$opt]#*:} txt=${___opt_map[(r)opt_$opt,--[^:]##]}
+ if [[ $msg == *":["* ]] {
+ msg=${${(MS)msg##$cmd:\[[^]]##}:-${(MS)msg##\*:\[[^]]##}}
+ msg=${msg#($cmd|\*):\[}
+ }
+ local pre_msg=`+zi-message -n {opt}${(r:14:)${txt#opt_}}`
+ +zi-message ${(r:35:: :)pre_msg}{rst}{ehi}→{rst}" $msg"
}
+ } elif [[ -n $allowed ]] {
+ shift 2
+ # No – an error message:
+ +zi-message "{b}{u-warn}ERROR{b-warn}:{rst}{msg2} Incorrect options given{ehi}:" \
+ "${(Mpj:$sep:)@:#-*}{rst}{msg2}. Allowed for the subcommand{ehi}:{rst}" \
+ "{apo}\`{cmd}$cmd{apo}\`{msg2} are{ehi}:{rst}" \
+ "{nl}{mmdsh} {opt}${allowed//\|/$sep2}{msg2}." \
+ "{nl}{…} Aborting.{rst}"
+ } else {
+ local -a cmds
+ cmds=( load snippet update delete )
+ local bcol="{$cmd}" sep="${ZI[col-rst]}${ZI[col-$cmd]}\`, \`${ZI[col-cmd]}"
+ +zi-message "$bcol(it should be one of, e.g.{ehi}:" \
+ "{nb}$bcol\`{cmd}${(pj:$sep:)cmds}$bcol\`," \
+ "{cmd}{…}$bcol, e.g.{ehi}: {nb}$bcol\`{lhi}zi {b}{cmd}load" \
+ "{pid}username/reponame$bcol\`) or a {b}{hi}for{nb}$bcol-based" \
+ "command body (i.e.{ehi}:{rst}$bcol e.g.{ehi}: {rst}$bcol\`{lhi}zi" \
+ "{…}{b}ice-spec{nb}{…} {hi}for{nb}{lhi} {…}({b}plugin" \
+ "{nb}or{b} snippet) {pname}ID-1 ID-2 {-…} {lhi}{…}$bcol\`)." \
+ "See \`{cmd}help$bcol\` for a more detailed usage information and" \
+ "the list of the {cmd}subcommands$bcol.{rst}"
+ }
}
# ]]]
# FUNCTION: +zi-parse-opts. [[[
.zi-parse-opts() {
- builtin emulate -LR zsh -o extendedglob
- reply=( "${(@)${@[2,-1]//([ $'\t']##|(#s))(#b)(${(~j.|.)${(@s.|.)___opt_map[$1]}})(#B)([ $'\t']##|(#e))/${OPTS[${___opt_map[${match[1]}]%%:*}]::=1}ß←↓→}:#1ß←↓→}" )
-}
-# ]]]
+ builtin emulate -LR zsh -o extendedglob
+ reply=( "${(@)${@[2,-1]//([ $'\t']##|(#s))(#b)(${(~j.|.)${(@s.|.)___opt_map[$1]}})(#B)([ $'\t']##|(#e))/${OPTS[${___opt_map[${match[1]}]%%:*}]::=1}ß←↓→}:#1ß←↓→}" )
+} # ]]]
#
# Ice support.
#
# FUNCTION: .zi-ice. [[[
-# Parses ICE specification, puts the result into ICE global hash.
-# The ice-spec is valid for next command only (i.e. it "melts"), but
-# it can then stick to plugin and activate e.g. at update.
+# Parses ICE specification, puts the result into ICE global hash. The ice-spec is valid for
+# next command only (i.e. it "melts"), but it can then stick to plugin and activate e.g. at update.
.zi-ice() {
- builtin setopt localoptions noksharrays extendedglob warncreateglobal typesetsilent noshortloops
- integer retval
- local bit exts="${(j:|:)${(@)${(@Akons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}}"
- for bit; do
- [[ $bit = (#b)(--|)(${~ZI[ice-list]}${~exts})(*) ]] && \
- ZI_ICES[${match[2]}]+="${ZI_ICES[${match[2]}]:+;}${match[3]#(:|=)}" || \
- break
- retval+=1
- done
- [[ ${ZI_ICES[as]} = program ]] && ZI_ICES[as]=command
- [[ -n ${ZI_ICES[on-update-of]} ]] && ZI_ICES[subscribe]="${ZI_ICES[subscribe]:-${ZI_ICES[on-update-of]}}"
- [[ -n ${ZI_ICES[pick]} ]] && ZI_ICES[pick]="${ZI_ICES[pick]//\$ZPFX/${ZPFX%/}}"
- return retval
+builtin setopt localoptions noksharrays extendedglob warncreateglobal typesetsilent noshortloops
+integer retval
+ local bit exts="${(j:|:)${(@)${(@Akons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}}"
+ for bit; do
+ [[ $bit = (#b)(--|)(${~ZI[ice-list]}${~exts})(*) ]] && \
+ ZI_ICES[${match[2]}]+="${ZI_ICES[${match[2]}]:+;}${match[3]#(:|=)}" || \
+ break
+ retval+=1
+ done
+ [[ ${ZI_ICES[as]} = program ]] && ZI_ICES[as]=command
+ [[ -n ${ZI_ICES[on-update-of]} ]] && ZI_ICES[subscribe]="${ZI_ICES[subscribe]:-${ZI_ICES[on-update-of]}}"
+ [[ -n ${ZI_ICES[pick]} ]] && ZI_ICES[pick]="${ZI_ICES[pick]//\$ZPFX/${ZPFX%/}}"
+return retval
} # ]]]
# FUNCTION: .zi-pack-ice. [[[
-# Remembers all ice-mods, assigns them to concrete plugin. Ice spec
-# is in general forgotten for second-next command (that's why it's
-# called "ice" - it melts), however they glue to the object (plugin
-# or snippet) mentioned in the next command – for later use with e.g.
-# `zi update ...'.
+# Remembers all ice-mods, assigns them to concrete plugin. Ice spec is in general forgotten for
+# second-next command (that's why it's called "ice" - it melts), however they glue to the object (plugin
+# or snippet) mentioned in the next command – for later use with e.g. `zi update ...'.
.zi-pack-ice() {
- ZI_SICE[$1${1:+${2:+/}}$2]+="${(j: :)${(qkv)ICE[@]}} "
- ZI_SICE[$1${1:+${2:+/}}$2]="${ZI_SICE[$1${1:+${2:+/}}$2]# }"
- return 0
+ ZI_SICE[$1${1:+${2:+/}}$2]+="${(j: :)${(qkv)ICE[@]}} "
+ ZI_SICE[$1${1:+${2:+/}}$2]="${ZI_SICE[$1${1:+${2:+/}}$2]# }"
+ return 0
} # ]]]
# FUNCTION: .zi-load-ices. [[[
.zi-load-ices() {
- local id_as="$1" ___key ___path
- local -a ice_order
- ice_order=(
- ${(As:|:)ZI[ice-list]}
- ${(@)${(A@kons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
- )
- ___path="${ZI[PLUGINS_DIR]}/${id_as//\//---}"/._zi
- # TODO snippet's dir computation…
- if [[ ! -d $___path ]] {
- if ! .zi-get-object-path snippet "${id_as//\//---}"; then
- return 1
- fi
- ___path="$REPLY"/._zi
- }
- for ___key ( "${ice_order[@]}" ) {
- (( ${+ICE[$___key]} )) && [[ ${ICE[$___key]} != +* ]] && continue
- [[ -e $___path/$___key ]] && ICE[$___key]="$(<$___path/$___key)"
- }
- [[ -n ${ICE[on-update-of]} ]] && ICE[subscribe]="${ICE[subscribe]:-${ICE[on-update-of]}}"
- [[ ${ICE[as]} = program ]] && ICE[as]=command
- [[ -n ${ICE[pick]} ]] && ICE[pick]="${ICE[pick]//\$ZPFX/${ZPFX%/}}"
-
- return 0
+ local id_as="$1" ___key ___path
+ local -a ice_order
+ ice_order=(
+ ${(As:|:)ZI[ice-list]}
+ ${(@)${(A@kons:|:)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}
+ )
+ ___path="${ZI[PLUGINS_DIR]}/${id_as//\//---}"/._zi
+ # TODO snippet's dir computation…
+ if [[ ! -d $___path ]] {
+ if ! .zi-get-object-path snippet "${id_as//\//---}"; then
+ return 1
+ fi
+ ___path="$REPLY"/._zi
+ }
+ for ___key ( "${ice_order[@]}" ) {
+ (( ${+ICE[$___key]} )) && [[ ${ICE[$___key]} != +* ]] && continue
+ [[ -e $___path/$___key ]] && ICE[$___key]="$(<$___path/$___key)"
+ }
+ [[ -n ${ICE[on-update-of]} ]] && ICE[subscribe]="${ICE[subscribe]:-${ICE[on-update-of]}}"
+ [[ ${ICE[as]} = program ]] && ICE[as]=command
+ [[ -n ${ICE[pick]} ]] && ICE[pick]="${ICE[pick]//\$ZPFX/${ZPFX%/}}"
+
+ return 0
}
# ]]]
# FUNCTION: .zi-setup-params. [[[
.zi-setup-params() {
- emulate -LR zsh -o extendedglob
- reply=( ${(@)${(@s.;.)ICE[param]}/(#m)*/${${MATCH%%(-\>|→|=\>)*}//((#s)[[:space:]]##|[[:space:]]##(#e))}${${(M)MATCH#*(-\>|→|=\>)}:+\=${${MATCH#*(-\>|→|=\>)}//((#s)[[:space:]]##|[[:space:]]##(#e))}}} )
- (( ${#reply} )) && return 0 || return 1
+ emulate -LR zsh -o extendedglob
+ reply=( ${(@)${(@s.;.)ICE[param]}/(#m)*/${${MATCH%%(-\>|→|=\>)*}//((#s)[[:space:]]##|[[:space:]]##(#e))}${${(M)MATCH#*(-\>|→|=\>)}:+\=${${MATCH#*(-\>|→|=\>)}//((#s)[[:space:]]##|[[:space:]]##(#e))}}} )
+ (( ${#reply} )) && return 0 || return 1
}
# ]]]
@@ -2172,53 +2063,52 @@ $match[7]}:-${ZI[__last-formatter-code]}}}:+}}}//←→}
# $5 - mode: load or light
# $6 - the plugin-spec or snippet URL or alias name (from id-as'')
.zi-run-task() {
- local ___pass="$1" ___t="$2" ___tpe="$3" ___idx="$4" ___mode="$5" ___id="${(Q)6}" ___opt="${(Q)7}" ___action ___s=1 ___retval=0
-
- local -A ICE ZI_ICE
- ICE=( "${(@Q)${(z@)ZI[WAIT_ICE_${___idx}]}}" )
- ZI_ICE=( "${(kv)ICE[@]}" )
-
- local ___id_as=${ICE[id-as]:-$___id}
-
- if [[ $___pass = 1 && ${${ICE[wait]#\!}%%[^0-9]([^0-9]|)([^0-9]|)([^0-9]|)} = <-> ]]; then
- ___action="${(M)ICE[wait]#\!}load"
- elif [[ $___pass = 1 && -n ${ICE[wait]#\!} ]] && { eval "${ICE[wait]#\!}" || [[ $(( ___s=0 )) = 1 ]]; }; then
- ___action="${(M)ICE[wait]#\!}load"
- elif [[ -n ${ICE[load]#\!} && -n $(( ___s=0 )) && $___pass = 3 && -z ${ZI_REGISTERED_PLUGINS[(r)$___id_as]} ]] && eval "${ICE[load]#\!}"; then
- ___action="${(M)ICE[load]#\!}load"
- elif [[ -n ${ICE[unload]#\!} && -n $(( ___s=0 )) && $___pass = 2 && -n ${ZI_REGISTERED_PLUGINS[(r)$___id_as]} ]] && eval "${ICE[unload]#\!}"; then
- ___action="${(M)ICE[unload]#\!}remove"
- elif [[ -n ${ICE[subscribe]#\!} && -n $(( ___s=0 )) && $___pass = 3 ]] && \
- { local -a fts_arr
- eval "fts_arr=( ${ICE[subscribe]}(DNms-$(( EPOCHSECONDS - ZI[fts-${ICE[subscribe]}] ))) ); (( \${#fts_arr} ))" && \
- { ZI[fts-${ICE[subscribe]}]="$EPOCHSECONDS"; ___s=${+ICE[once]}; } || \
- (( 0 ))
- }
- then
- ___action="${(M)ICE[subscribe]#\!}load"
- fi
-
- if [[ $___action = *load ]]; then
- if [[ $___tpe = p ]]; then
- .zi-load "${(@)=___id}" "" "$___mode"; (( ___retval += $? ))
- elif [[ $___tpe = s ]]; then
- .zi-load-snippet $___opt "$___id"; (( ___retval += $? ))
- elif [[ $___tpe = p1 || $___tpe = s1 ]]; then
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- zpty -b "${___id//\//:} / ${ICE[service]}" '.zi-service '"${(M)___tpe#?}"' "$___mode" "$___id"'
- fi
- (( ${+ICE[silent]} == 0 && ${+ICE[lucid]} == 0 && ___retval == 0 )) && zle && zle -M "Loaded $___id"
- elif [[ $___action = *remove ]]; then
- (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
- [[ $___tpe = p ]] && .zi-unload "$___id_as" "" -q
- (( ${+ICE[silent]} == 0 && ${+ICE[lucid]} == 0 && ___retval == 0 )) && zle && zle -M "Unloaded $___id_as"
+ local ___pass="$1" ___t="$2" ___tpe="$3" ___idx="$4" ___mode="$5" ___id="${(Q)6}" ___opt="${(Q)7}" ___action ___s=1 ___retval=0
+
+ local -A ICE ZI_ICE
+ ICE=( "${(@Q)${(z@)ZI[WAIT_ICE_${___idx}]}}" )
+ ZI_ICE=( "${(kv)ICE[@]}" )
+
+ local ___id_as=${ICE[id-as]:-$___id}
+
+ if [[ $___pass = 1 && ${${ICE[wait]#\!}%%[^0-9]([^0-9]|)([^0-9]|)([^0-9]|)} = <-> ]]; then
+ ___action="${(M)ICE[wait]#\!}load"
+ elif [[ $___pass = 1 && -n ${ICE[wait]#\!} ]] && { eval "${ICE[wait]#\!}" || [[ $(( ___s=0 )) = 1 ]]; }; then
+ ___action="${(M)ICE[wait]#\!}load"
+ elif [[ -n ${ICE[load]#\!} && -n $(( ___s=0 )) && $___pass = 3 && -z ${ZI_REGISTERED_PLUGINS[(r)$___id_as]} ]] && eval "${ICE[load]#\!}"; then
+ ___action="${(M)ICE[load]#\!}load"
+ elif [[ -n ${ICE[unload]#\!} && -n $(( ___s=0 )) && $___pass = 2 && -n ${ZI_REGISTERED_PLUGINS[(r)$___id_as]} ]] && eval "${ICE[unload]#\!}"; then
+ ___action="${(M)ICE[unload]#\!}remove"
+ elif [[ -n ${ICE[subscribe]#\!} && -n $(( ___s=0 )) && $___pass = 3 ]] && \
+ { local -a fts_arr
+ eval "fts_arr=( ${ICE[subscribe]}(DNms-$(( EPOCHSECONDS - ZI[fts-${ICE[subscribe]}] ))) ); (( \${#fts_arr} ))" && \
+ { ZI[fts-${ICE[subscribe]}]="$EPOCHSECONDS"; ___s=${+ICE[once]}; } || \
+ (( 0 ))
+ }
+ then
+ ___action="${(M)ICE[subscribe]#\!}load"
+ fi
+
+ if [[ $___action = *load ]]; then
+ if [[ $___tpe = p ]]; then
+ .zi-load "${(@)=___id}" "" "$___mode"; (( ___retval += $? ))
+ elif [[ $___tpe = s ]]; then
+ .zi-load-snippet $___opt "$___id"; (( ___retval += $? ))
+ elif [[ $___tpe = p1 || $___tpe = s1 ]]; then
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ zpty -b "${___id//\//:} / ${ICE[service]}" '.zi-service '"${(M)___tpe#?}"' "$___mode" "$___id"'
fi
+ (( ${+ICE[silent]} == 0 && ${+ICE[lucid]} == 0 && ___retval == 0 )) && zle && zle -M "Loaded $___id"
+ elif [[ $___action = *remove ]]; then
+ (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ [[ $___tpe = p ]] && .zi-unload "$___id_as" "" -q
+ (( ${+ICE[silent]} == 0 && ${+ICE[lucid]} == 0 && ___retval == 0 )) && zle && zle -M "Unloaded $___id_as"
+ fi
- [[ ${REPLY::=$___action} = \!* ]] && zle && zle .reset-prompt
+ [[ ${REPLY::=$___action} = \!* ]] && zle && zle .reset-prompt
- return ___s
-}
-# ]]]
+ return ___s
+} # ]]]
# FUNCTION: .zi-submit-turbo. [[[
# If `zi load`, `zi light` or `zi snippet` will be
@@ -2227,38 +2117,36 @@ $match[7]}:-${ZI[__last-formatter-code]}}}:+}}}//←→}
# and this function adds it to internal data structures, so that
# @zi-scheduler can run (load, unload) this as a task.
.zi-submit-turbo() {
- local tpe="$1" mode="$2" opt_uspl2="$3" opt_plugin="$4"
-
- ICE[wait]="${ICE[wait]%%.[0-9]##}"
- ZI[WAIT_IDX]=$(( ${ZI[WAIT_IDX]:-0} + 1 ))
- ZI[WAIT_ICE_${ZI[WAIT_IDX]}]="${(j: :)${(qkv)ICE[@]}}"
- ZI[fts-${ICE[subscribe]}]="${ICE[subscribe]:+$EPOCHSECONDS}"
-
- [[ $tpe = s* ]] && \
- local id="${${opt_plugin:+$opt_plugin}:-$opt_uspl2}" || \
- local id="${${opt_plugin:+$opt_uspl2${${opt_uspl2:#%*}:+/}$opt_plugin}:-$opt_uspl2}"
-
- if [[ ${${ICE[wait]}%%[^0-9]([^0-9]|)([^0-9]|)([^0-9]|)} = (\!|.|)<-> ]]; then
- ZI_TASKS+=( "$EPOCHSECONDS+${${ICE[wait]#(\!|.)}%%[^0-9]([^0-9]|)([^0-9]|)([^0-9]|)}+${${${(M)ICE[wait]%a}:+1}:-${${${(M)ICE[wait]%b}:+2}:-${${${(M)ICE[wait]%c}:+3}:-1}}} $tpe ${ZI[WAIT_IDX]} ${mode:-_} ${(q)id} ${opt_plugin:+${(q)opt_uspl2}}" )
- elif [[ -n ${ICE[wait]}${ICE[load]}${ICE[unload]}${ICE[subscribe]} ]]; then
- ZI_TASKS+=( "${${ICE[wait]:+0}:-1}+0+1 $tpe ${ZI[WAIT_IDX]} ${mode:-_} ${(q)id} ${opt_plugin:+${(q)opt_uspl2}}" )
- fi
-}
-# ]]]
+ local tpe="$1" mode="$2" opt_uspl2="$3" opt_plugin="$4"
+
+ ICE[wait]="${ICE[wait]%%.[0-9]##}"
+ ZI[WAIT_IDX]=$(( ${ZI[WAIT_IDX]:-0} + 1 ))
+ ZI[WAIT_ICE_${ZI[WAIT_IDX]}]="${(j: :)${(qkv)ICE[@]}}"
+ ZI[fts-${ICE[subscribe]}]="${ICE[subscribe]:+$EPOCHSECONDS}"
+
+ [[ $tpe = s* ]] && \
+ local id="${${opt_plugin:+$opt_plugin}:-$opt_uspl2}" || \
+ local id="${${opt_plugin:+$opt_uspl2${${opt_uspl2:#%*}:+/}$opt_plugin}:-$opt_uspl2}"
+
+ if [[ ${${ICE[wait]}%%[^0-9]([^0-9]|)([^0-9]|)([^0-9]|)} = (\!|.|)<-> ]]; then
+ ZI_TASKS+=( "$EPOCHSECONDS+${${ICE[wait]#(\!|.)}%%[^0-9]([^0-9]|)([^0-9]|)([^0-9]|)}+${${${(M)ICE[wait]%a}:+1}:-${${${(M)ICE[wait]%b}:+2}:-${${${(M)ICE[wait]%c}:+3}:-1}}} $tpe ${ZI[WAIT_IDX]} ${mode:-_} ${(q)id} ${opt_plugin:+${(q)opt_uspl2}}" )
+ elif [[ -n ${ICE[wait]}${ICE[load]}${ICE[unload]}${ICE[subscribe]} ]]; then
+ ZI_TASKS+=( "${${ICE[wait]:+0}:-1}+0+1 $tpe ${ZI[WAIT_IDX]} ${mode:-_} ${(q)id} ${opt_plugin:+${(q)opt_uspl2}}" )
+ fi
+} # ]]]
# FUNCTION: -zi_scheduler_add_sh. [[[
# Copies task into ZI_RUN array, called when a task timeouts.
# A small function ran from pattern in /-substitution as a math
# function.
-zi_scheduler_add_sh() {
- local idx="$1" in_wait="$___ar2" in_abc="$___ar3" ver_wait="$___ar4" ver_abc="$___ar5"
- if [[ ( $in_wait = $ver_wait || $in_wait -ge 4 ) && $in_abc = $ver_abc ]]; then
- ZI_RUN+=( "${ZI_TASKS[$idx]}" )
- return 1
- else
- return idx
- fi
-}
-# ]]]
+ local idx="$1" in_wait="$___ar2" in_abc="$___ar3" ver_wait="$___ar4" ver_abc="$___ar5"
+ if [[ ( $in_wait = $ver_wait || $in_wait -ge 4 ) && $in_abc = $ver_abc ]]; then
+ ZI_RUN+=( "${ZI_TASKS[$idx]}" )
+ return 1
+ else
+ return idx
+ fi
+} # ]]]
# FUNCTION: @zi-scheduler. [[[
# Searches for timeout tasks, executes them. There's an array of tasks
# waiting for execution, this scheduler manages them, detects which ones
@@ -2277,106 +2165,105 @@ $match[7]}:-${ZI[__last-formatter-code]}}}:+}}}//←→}
#
@zi-scheduler() {
- integer ___ret="${${ZI[lro-data]%:*}##*:}"
- # lro stands for lastarg-retval-option.
- [[ $1 = following ]] && sched +1 'ZI[lro-data]="$_:$?:${options[printexitvalue]}"; @zi-scheduler following "${ZI[lro-data]%:*:*}"'
- [[ -n $1 && $1 != (following*|burst) ]] && { local THEFD="$1"; zle -F "$THEFD"; exec {THEFD}<&-; }
- [[ $1 = burst ]] && local -h EPOCHSECONDS=$(( EPOCHSECONDS+10000 ))
- ZI[START_TIME]="${ZI[START_TIME]:-$EPOCHREALTIME}"
-
- integer ___t=EPOCHSECONDS ___i correct
- local -a match mbegin mend reply
- local MATCH REPLY AFD; integer MBEGIN MEND
-
- [[ -o ksharrays ]] && correct=1
-
- if [[ -n $1 ]] {
- if [[ ${#ZI_RUN} -le 1 || $1 = following ]] {
- () {
- builtin emulate -L zsh
- builtin setopt extendedglob
- # Example entry:
- # 1531252764+2+1 p 18 light z-shell/zsh-diff-so-fancy
- #
- # This either doesn't change ZI_TASKS entry - when
- # ___i is used in the ternary expression, or replaces
- # an entry with "", i.e. ZI_TASKS[1] entry.
- integer ___idx1 ___idx2
- local ___ar2 ___ar3 ___ar4 ___ar5
- for (( ___idx1 = 0; ___idx1 <= 4; ___idx1 ++ )) {
- for (( ___idx2 = 1; ___idx2 <= (___idx >= 4 ? 1 : 3); ___idx2 ++ )) {
- # The following substitution could be just (well, 'just'..) this:
- #
- # ZI_TASKS=( ${ZI_TASKS[@]/(#b)([0-9]##)+([0-9]##)+([1-3])(*)/
- # ${ZI_TASKS[$(( (${match[1]}+${match[2]}) <= $___t ?
- # zi_scheduler_add(___i++, ${match[2]},
- # ${(M)match[3]%[1-3]}, ___idx1, ___idx2) : ___i++ ))]}} )
- #
- # However, there's a severe bug in Zsh <= 5.3.1 - use of the period
- # (,) is impossible inside ${..//$arr[$(( ... ))]}.
- ___i=2
-
- ZI_TASKS=( ${ZI_TASKS[@]/(#b)([0-9]##)+([0-9]##)+([1-3])(*)/${ZI_TASKS[
- $(( (___ar2=${match[2]}+1) ? (
- (___ar3=${(M)match[3]%[1-3]}) ? (
- (___ar4=___idx1+1) ? (
- (___ar5=___idx2) ? (
- (${match[1]}+${match[2]}) <= $___t ?
- zi_scheduler_add(___i++) : ___i++ )
- : 1 )
- : 1 )
- : 1 )
- : 1 ))]}} )
- ZI_TASKS=( "" ${ZI_TASKS[@]:#} )
- }
- }
- }
- }
- } else {
- add-zsh-hook -d -- precmd @zi-scheduler
- add-zsh-hook -- chpwd @zi-scheduler
- () {
- builtin emulate -L zsh
- builtin setopt extendedglob
- # No "+" in this pattern, it will match only "1531252764"
- # in "1531252764+2" and replace it with current time.
- ZI_TASKS=( ${ZI_TASKS[@]/(#b)([0-9]##)(*)/$(( ${match[1]} <= 1 ? ${match[1]} : ___t ))${match[2]}} )
- }
- # There's a bug in Zsh: first sched call would not be issued
- # until a key-press, if "sched +1 ..." would be called inside
- # zle -F handler. So it's done here, in precmd-handle code.
- sched +1 'ZI[lro-data]="$_:$?:${options[printexitvalue]}"; @zi-scheduler following ${ZI[lro-data]%:*:*}'
-
- AFD=13371337 # for older Zsh + noclobber option
- exec {AFD}< <(LANG=C command sleep 0.002; builtin print run;)
- command true # workaround a Zsh bug, see: http://www.zsh.org/mla/workers/2018/msg00966.html
- zle -F "$AFD" @zi-scheduler
- }
-
- local ___task ___idx=0 ___count=0 ___idx2
- # All wait'' objects.
- for ___task ( "${ZI_RUN[@]}" ) {
- .zi-run-task 1 "${(@z)___task}" && ZI_TASKS+=( "$___task" )
- if [[ $(( ++___idx, ___count += ${${REPLY:+1}:-0} )) -gt 0 && $1 != burst ]] {
- AFD=13371337 # for older Zsh + noclobber option
- exec {AFD}< <(LANG=C command sleep 0.0002; builtin print run;)
- command true
- # The $? and $_ will be left unchanged automatically by Zsh.
- zle -F "$AFD" @zi-scheduler
- break
+ integer ___ret="${${ZI[lro-data]%:*}##*:}"
+ # lro stands for lastarg-retval-option.
+ [[ $1 = following ]] && sched +1 'ZI[lro-data]="$_:$?:${options[printexitvalue]}"; @zi-scheduler following "${ZI[lro-data]%:*:*}"'
+ [[ -n $1 && $1 != (following*|burst) ]] && { local THEFD="$1"; zle -F "$THEFD"; exec {THEFD}<&-; }
+ [[ $1 = burst ]] && local -h EPOCHSECONDS=$(( EPOCHSECONDS+10000 ))
+ ZI[START_TIME]="${ZI[START_TIME]:-$EPOCHREALTIME}"
+
+ integer ___t=EPOCHSECONDS ___i correct
+ local -a match mbegin mend reply
+ local MATCH REPLY AFD; integer MBEGIN MEND
+
+ [[ -o ksharrays ]] && correct=1
+
+ if [[ -n $1 ]] {
+ if [[ ${#ZI_RUN} -le 1 || $1 = following ]] {
+ () {
+ builtin emulate -L zsh
+ builtin setopt extendedglob
+ # Example entry:
+ # 1531252764+2+1 p 18 light z-shell/zsh-diff-so-fancy
+ #
+ # This either doesn't change ZI_TASKS entry - when
+ # ___i is used in the ternary expression, or replaces
+ # an entry with "", i.e. ZI_TASKS[1] entry.
+ integer ___idx1 ___idx2
+ local ___ar2 ___ar3 ___ar4 ___ar5
+ for (( ___idx1 = 0; ___idx1 <= 4; ___idx1 ++ )) {
+ for (( ___idx2 = 1; ___idx2 <= (___idx >= 4 ? 1 : 3); ___idx2 ++ )) {
+ # The following substitution could be just (well, 'just'..) this:
+ #
+ # ZI_TASKS=( ${ZI_TASKS[@]/(#b)([0-9]##)+([0-9]##)+([1-3])(*)/
+ # ${ZI_TASKS[$(( (${match[1]}+${match[2]}) <= $___t ?
+ # zi_scheduler_add(___i++, ${match[2]},
+ # ${(M)match[3]%[1-3]}, ___idx1, ___idx2) : ___i++ ))]}} )
+ #
+ # However, there's a severe bug in Zsh <= 5.3.1 - use of the period
+ # (,) is impossible inside ${..//$arr[$(( ... ))]}.
+ ___i=2
+ ZI_TASKS=( ${ZI_TASKS[@]/(#b)([0-9]##)+([0-9]##)+([1-3])(*)/${ZI_TASKS[
+ $(( (___ar2=${match[2]}+1) ? (
+ (___ar3=${(M)match[3]%[1-3]}) ? (
+ (___ar4=___idx1+1) ? (
+ (___ar5=___idx2) ? (
+ (${match[1]}+${match[2]}) <= $___t ?
+ zi_scheduler_add(___i++) : ___i++ )
+ : 1 )
+ : 1 )
+ : 1 )
+ : 1 ))]}} )
+ ZI_TASKS=( "" ${ZI_TASKS[@]:#} )
+ }
}
+ }
}
- # All unload'' objects.
- for (( ___idx2=1; ___idx2 <= ___idx; ++ ___idx2 )) {
- .zi-run-task 2 "${(@z)ZI_RUN[___idx2-correct]}"
+ } else {
+ add-zsh-hook -d -- precmd @zi-scheduler
+ add-zsh-hook -- chpwd @zi-scheduler
+ () {
+ builtin emulate -L zsh
+ builtin setopt extendedglob
+ # No "+" in this pattern, it will match only "1531252764"
+ # in "1531252764+2" and replace it with current time.
+ ZI_TASKS=( ${ZI_TASKS[@]/(#b)([0-9]##)(*)/$(( ${match[1]} <= 1 ? ${match[1]} : ___t ))${match[2]}} )
}
- # All load'' & subscribe'' objects.
- for (( ___idx2=1; ___idx2 <= ___idx; ++ ___idx2 )) {
- .zi-run-task 3 "${(@z)ZI_RUN[___idx2-correct]}"
+ # There's a bug in Zsh: first sched call would not be issued
+ # until a key-press, if "sched +1 ..." would be called inside
+ # zle -F handler. So it's done here, in precmd-handle code.
+ sched +1 'ZI[lro-data]="$_:$?:${options[printexitvalue]}"; @zi-scheduler following ${ZI[lro-data]%:*:*}'
+
+ AFD=13371337 # for older Zsh + noclobber option
+ exec {AFD}< <(LANG=C command sleep 0.002; builtin print run;)
+ command true # workaround a Zsh bug, see: http://www.zsh.org/mla/workers/2018/msg00966.html
+ zle -F "$AFD" @zi-scheduler
+ }
+
+ local ___task ___idx=0 ___count=0 ___idx2
+ # All wait'' objects.
+ for ___task ( "${ZI_RUN[@]}" ) {
+ .zi-run-task 1 "${(@z)___task}" && ZI_TASKS+=( "$___task" )
+ if [[ $(( ++___idx, ___count += ${${REPLY:+1}:-0} )) -gt 0 && $1 != burst ]] {
+ AFD=13371337 # for older Zsh + noclobber option
+ exec {AFD}< <(LANG=C command sleep 0.0002; builtin print run;)
+ command true
+ # The $? and $_ will be left unchanged automatically by Zsh.
+ zle -F "$AFD" @zi-scheduler
+ break
}
- ZI_RUN[1-correct,___idx-correct]=()
-
- [[ ${ZI[lro-data]##*:} = on ]] && return 0 || return ___ret
+ }
+ # All unload'' objects.
+ for (( ___idx2=1; ___idx2 <= ___idx; ++ ___idx2 )) {
+ .zi-run-task 2 "${(@z)ZI_RUN[___idx2-correct]}"
+ }
+ # All load'' & subscribe'' objects.
+ for (( ___idx2=1; ___idx2 <= ___idx; ++ ___idx2 )) {
+ .zi-run-task 3 "${(@z)ZI_RUN[___idx2-correct]}"
+ }
+ ZI_RUN[1-correct,___idx-correct]=()
+
+ [[ ${ZI[lro-data]##*:} = on ]] && return 0 || return ___ret
}
# ]]]
@@ -2388,604 +2275,602 @@ $match[7]}:-${ZI[__last-formatter-code]}}}:+}}}//←→}
# Main function directly exposed to user, obtains subcommand and its
# arguments, has completion.
zi() {
- local -A ICE ZI_ICE
- ICE=( "${(kv)ZI_ICES[@]}" )
- ZI_ICE=( "${(kv)ICE[@]}" )
- ZI_ICES=()
-
- integer ___retval ___retval2 ___correct
- local -a match mbegin mend
- local MATCH cmd ___q="\`" ___q2="'" IFS=$' \t\n\0'; integer MBEGIN MEND
-
- # An annex's subcommand might use the reply vars.
- match=( ${ZI_EXTS[(I)z-annex subcommand:$1]} )
- if (( !${#match} )) {
- local -a reply; local REPLY
- }
-
- [[ -o ksharrays ]] && ___correct=1
-
- local -A ___opt_map OPTS
- ___opt_map=(
- -q opt_-q,--quiet:"update:[Turn off almost-all messages from the {cmd}update{rst} operation {b-lhi}FOR the objects{rst} which don't have any {b-lhi}new version{rst} available.] *:[Turn off any (or: almost-any) messages from the operation.]"
- --quiet opt_-q,--quiet
- -v opt_-v,--verbose:"Turn on more messages from the operation."
- --verbose opt_-v,--verbose
- -r opt_-r,--reset:"Reset the repository before updating (or remove the files for single-file snippets and gh-r plugins)."
- --reset opt_-r,--reset
- -a opt_-a,--all:"delete:[Delete {hi}all{rst} plugins and snippets.] update:[Update {b-lhi}all{rst} plugins and snippets.]"
- --all opt_-a,--all
- -c opt_-c,--clean:"Delete {b-lhi}only{rst} the {b-lhi}currently-not loaded{rst} plugins and snippets."
- --clean opt_-c,--clean
- -y opt_-y,--yes:"Automatically confirm any yes/no prompts."
- --yes opt_-y,--yes
- -f opt_-f,--force:"Force new download of the snippet file."
- --force opt_-f,--force
- -p opt_-p,--parallel:"Turn on concurrent, multi-thread update (of all objects)."
- --parallel opt_-p,--parallel
- -s opt_-s,--snippets:"snippets:[Update only snippets (i.e.: skip updating plugins).] times:[Show times in seconds instead of milliseconds.]"
- --snippets opt_-s,--snippets
- -L opt_-l,--plugins:"Update only plugins (i.e.: skip updating snippets)."
- --plugins opt_-l,--plugins
- -h opt_-h,--help:"Show this help message."
- --help opt_-h,--help
- -u opt_-u,--urge:"Cause all the hooks like{ehi}:{rst} {ice}atpull{apo}''{rst}, {ice}cp{apo}''{rst}, etc. to execute even when there aren't any new commits {b}/{rst} any new version of the {b}{meta}gh-r{rst} file {b}/{rst} etc.{…} available for download {ehi}{lr}{rst} simulate a non-empty update."
- --urge opt_-u,--urge
- -n opt_-n,--no-pager:"Disable the use of the pager."
- --no-pager opt_-n,--no-pager
- -m opt_-m,--moments:"Show the {apo}*{b-lhi}moments{apo}*{rst} of object (i.e.: a plugin or snippet) loading time."
- --moments opt_-m,--moments
- -b opt_-b,--bindkeys:"Load in light mode, however do still track {cmd}bindkey{rst} calls (to allow remapping the keys bound)."
- --bindkeys opt_-b,--bindkeys
- -x opt_-x,--command:"Load the snippet as a {cmd}command{rst}, i.e.: add it to {var}\$PATH{rst} and set {b-lhi}+x{rst} on it."
- --command opt_-x,--command
- env-whitelist "-h|--help|-v|--verbose"
- update "-L|--plugins|-s|--snippets|-p|--parallel|-a|--all|-q|--quiet|-r|--reset|-u|--urge|-n|--no-pager|-v|--verbose|-h|--help"
- delete "-a|--all|-c|--clean|-y|--yes|-q|--quiet|-h|--help"
- unload "-h|--help|-q|--quiet"
- cdclear "-h|--help|-q|--quiet"
- cdreplay "-h|--help|-q|--quiet"
- times "-h|--help|-m|-s"
- light "-h|--help|-b"
- snippet "-h|--help|-f|--force|--command|-x"
- )
-
- cmd="$1"
- if [[ $cmd == (times|unload|env-whitelist|update|snippet|load|light|cdreplay|\
-cdclear|delete) ]]; then
- if (( $@[(I)-*] || OPTS[opt_-h,--help] )); then
- .zi-parse-opts "$cmd" "$@"
- if (( OPTS[opt_-h,--help] )); then
- +zi-prehelp-usage-message $cmd $___opt_map[$cmd] $@
- return 1;
- fi
- fi
+ local -A ICE ZI_ICE
+ ICE=( "${(kv)ZI_ICES[@]}" )
+ ZI_ICE=( "${(kv)ICE[@]}" )
+ ZI_ICES=()
+
+ integer ___retval ___retval2 ___correct
+ local -a match mbegin mend
+ local MATCH cmd ___q="\`" ___q2="'" IFS=$' \t\n\0'; integer MBEGIN MEND
+
+ # An annex's subcommand might use the reply vars.
+ match=( ${ZI_EXTS[(I)z-annex subcommand:$1]} )
+ if (( !${#match} )) {
+ local -a reply; local REPLY
+ }
+
+ [[ -o ksharrays ]] && ___correct=1
+
+ local -A ___opt_map OPTS
+ ___opt_map=(
+ -q opt_-q,--quiet:"update:[Turn off almost-all messages from the {cmd}update{rst} operation {b-lhi}FOR the objects{rst} which don't have any {b-lhi}new version{rst} available.] *:[Turn off any (or: almost-any) messages from the operation.]"
+ --quiet opt_-q,--quiet
+ -v opt_-v,--verbose:"Turn on more messages from the operation."
+ --verbose opt_-v,--verbose
+ -r opt_-r,--reset:"Reset the repository before updating (or remove the files for single-file snippets and gh-r plugins)."
+ --reset opt_-r,--reset
+ -a opt_-a,--all:"delete:[Delete {hi}all{rst} plugins and snippets.] update:[Update {b-lhi}all{rst} plugins and snippets.]"
+ --all opt_-a,--all
+ -c opt_-c,--clean:"Delete {b-lhi}only{rst} the {b-lhi}currently-not loaded{rst} plugins and snippets."
+ --clean opt_-c,--clean
+ -y opt_-y,--yes:"Automatically confirm any yes/no prompts."
+ --yes opt_-y,--yes
+ -f opt_-f,--force:"Force new download of the snippet file."
+ --force opt_-f,--force
+ -p opt_-p,--parallel:"Turn on concurrent, multi-thread update (of all objects)."
+ --parallel opt_-p,--parallel
+ -s opt_-s,--snippets:"snippets:[Update only snippets (i.e.: skip updating plugins).] times:[Show times in seconds instead of milliseconds.]"
+ --snippets opt_-s,--snippets
+ -L opt_-l,--plugins:"Update only plugins (i.e.: skip updating snippets)."
+ --plugins opt_-l,--plugins
+ -h opt_-h,--help:"Show this help message."
+ --help opt_-h,--help
+ -u opt_-u,--urge:"Cause all the hooks like{ehi}:{rst} {ice}atpull{apo}''{rst}, {ice}cp{apo}''{rst}, etc. to execute even when there aren't any new commits {b}/{rst} any new version of the {b}{meta}gh-r{rst} file {b}/{rst} etc.{…} available for download {ehi}{lr}{rst} simulate a non-empty update."
+ --urge opt_-u,--urge
+ -n opt_-n,--no-pager:"Disable the use of the pager."
+ --no-pager opt_-n,--no-pager
+ -m opt_-m,--moments:"Show the {apo}*{b-lhi}moments{apo}*{rst} of object (i.e.: a plugin or snippet) loading time."
+ --moments opt_-m,--moments
+ -b opt_-b,--bindkeys:"Load in light mode, however do still track {cmd}bindkey{rst} calls (to allow remapping the keys bound)."
+ --bindkeys opt_-b,--bindkeys
+ -x opt_-x,--command:"Load the snippet as a {cmd}command{rst}, i.e.: add it to {var}\$PATH{rst} and set {b-lhi}+x{rst} on it."
+ --command opt_-x,--command
+ env-whitelist "-h|--help|-v|--verbose"
+ update "-L|--plugins|-s|--snippets|-p|--parallel|-a|--all|-q|--quiet|-r|--reset|-u|--urge|-n|--no-pager|-v|--verbose|-h|--help"
+ delete "-a|--all|-c|--clean|-y|--yes|-q|--quiet|-h|--help"
+ unload "-h|--help|-q|--quiet"
+ cdclear "-h|--help|-q|--quiet"
+ cdreplay "-h|--help|-q|--quiet"
+ times "-h|--help|-m|-s"
+ light "-h|--help|-b"
+ snippet "-h|--help|-f|--force|--command|-x"
+ )
+
+ cmd="$1"
+ if [[ $cmd == (times|unload|env-whitelist|update|snippet|load|light|cdreplay|cdclear|delete) ]]; then
+ if (( $@[(I)-*] || OPTS[opt_-h,--help] )); then
+ .zi-parse-opts "$cmd" "$@"
+ if (( OPTS[opt_-h,--help] )); then
+ +zi-prehelp-usage-message $cmd $___opt_map[$cmd] $@
+ return 1;
+ fi
fi
+ fi
- reply=( ${ZI_EXTS[(I)z-annex subcommand:*]} )
+ reply=( ${ZI_EXTS[(I)z-annex subcommand:*]} )
- [[ -n $1 && $1 != (-h|--help|help|analytics|control|man|self-update|times|zstatus|load|light|unload|snippet|ls|ice|\
+ [[ -n $1 && $1 != (-h|--help|help|analytics|control|man|self-update|times|zstatus|load|light|unload|snippet|ls|ice|\
update|status|report|delete|loaded|list|cd|create|edit|glance|stress|changes|recently|clist|\
completions|cclear|cdisable|cenable|creinstall|cuninstall|csearch|compinit|dtrace|dstart|dstop|\
dunload|dreport|dclear|compile|uncompile|compiled|cdlist|cdreplay|cdclear|srv|recall|\
env-whitelist|bindkeys|module|add-fpath|run${reply:+|${(~j:|:)"${reply[@]#z-annex subcommand:}"}}) || $1 = (load|light|snippet) ]] && \
- {
- integer ___error
- if [[ $1 = (load|light|snippet) ]] {
- integer ___is_snippet
- # Classic syntax -> simulate a call through the for-syntax.
- () {
- builtin setopt localoptions extendedglob
- : ${@[@]//(#b)([ $'\t']##|(#s))(-b|--command|-f|--force)([ $'\t']##|(#e))/${OPTS[${match[2]}]::=1}}
- } "$@"
- builtin set -- "${@[@]:#(-b|--command|-f|--force)}"
- [[ $1 = light && -z ${OPTS[(I)-b]} ]] && ICE[light-mode]=
- [[ $1 = snippet ]] && ICE[is-snippet]= || ___is_snippet=-1
- shift
-
- ZI_ICES=( "${(kv)ICE[@]}" )
- ICE=() ZI_ICE=()
- 1="${1:+@}${1#@}${2:+/$2}"
- (( $# > 1 )) && { shift -p $(( $# - 1 )); }
- [[ -z $1 ]] && {
- +zi-message "Argument needed, try: {cmd}help."
- return 1
+ {
+ integer ___error
+ if [[ $1 = (load|light|snippet) ]] {
+ integer ___is_snippet
+ # Classic syntax -> simulate a call through the for-syntax.
+ () {
+ builtin setopt localoptions extendedglob
+ : ${@[@]//(#b)([ $'\t']##|(#s))(-b|--command|-f|--force)([ $'\t']##|(#e))/${OPTS[${match[2]}]::=1}}
+ } "$@"
+ builtin set -- "${@[@]:#(-b|--command|-f|--force)}"
+ [[ $1 = light && -z ${OPTS[(I)-b]} ]] && ICE[light-mode]=
+ [[ $1 = snippet ]] && ICE[is-snippet]= || ___is_snippet=-1
+ shift
+
+ ZI_ICES=( "${(kv)ICE[@]}" )
+ ICE=() ZI_ICE=()
+ 1="${1:+@}${1#@}${2:+/$2}"
+ (( $# > 1 )) && { shift -p $(( $# - 1 )); }
+ [[ -z $1 ]] && {
+ +zi-message "Argument needed, try: {cmd}help."
+ return 1
+ }
+ } else {
+ .zi-ice "$@"
+ ___retval2=$?
+ local ___last_ice=${@[___retval2]}
+ shift ___retval2
+ if [[ $# -gt 0 && $1 != for ]] {
+ +zi-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:" \
+ "{apo}\`{cmd}$1{apo}\`{rst} "
+ +zi-prehelp-usage-message rst
+ return 1
+ } elif (( $# == 0 )) {
+ ___error=1
+ } else {
+ shift
+ }
+ }
+ integer ___had_wait
+ local ___id ___ehid ___etid ___key
+ local -a ___arr
+ ZI[annex-exposed-processed-IDs]=
+ if (( $# )) {
+ local -a ___ices
+ ___ices=( "${(kv)ZI_ICES[@]}" )
+ ZI_ICES=()
+ while (( $# )) {
+ .zi-ice "$@"
+ ___retval2=$?
+ local ___last_ice=${@[___retval2]}
+ shift ___retval2
+ if [[ -n $1 ]] {
+ ICE=( "${___ices[@]}" "${(kv)ZI_ICES[@]}" )
+ ZI_ICE=( "${(kv)ICE[@]}" ) ZI_ICES=()
+ integer ___msgs=${+ICE[debug]}
+ (( ___msgs )) && +zi-message "{pre}zi-main:{faint} Processing {pname}$1{faint}{…}{rst}"
+ # Delete up to the final space to get the previously-processed ID.
+ ZI[annex-exposed-processed-IDs]+="${___id:+ $___id}"
+ # Strip the ID-qualifier (`@') and GitHub domain from the ID.
+ ___id="${${1#@}%%(///|//|/)}"
+ (( ___is_snippet == -1 )) && ___id="${___id#https://github.com/}"
+ # Effective handle-ID – the label under which the object
+ # will be identified / referred-to by ZI.
+ ___ehid="${ICE[id-as]:-$___id}"
+ # Effective remote-ID (i.e.: URL, GitHub username/repo,
+ # package name, etc.). teleid'' allows "overriding" of $1.
+ # In case of a package using teleid'', the value here
+ # is being took from the given ices, before disk-ices.
+ ___etid="${ICE[teleid]:-$___id}"
+ if (( ${+ICE[pack]} )); then
+ ___had_wait=${+ICE[wait]}
+ .zi-load-ices "$___ehid"
+ # wait'' isn't possible via the disk-ices (for
+ # packages), only via the command's ice-spec.
+ [[ $___had_wait -eq 0 ]] && unset 'ICE[wait]'
+ fi
+ [[ ${ICE[id-as]} = (auto|) && ${+ICE[id-as]} == 1 ]] && ICE[id-as]="${___etid:t}"
+ integer ___is_snippet=${${(M)___is_snippet:#-1}:-0}
+ () {
+ builtin setopt localoptions extendedglob
+ if [[ $___is_snippet -ge 0 && ( -n ${ICE[is-snippet]+1} || $___etid = ((#i)(http(s|)|ftp(s|)):/|(${(~kj.|.)ZI_1MAP}))* ) ]] {
+ ___is_snippet=1
}
- } else {
- .zi-ice "$@"
+ } "$@"
+ local ___type=${${${(M)___is_snippet:#1}:+snippet}:-plugin}
+ reply=(
+ ${(on)ZI_EXTS2[(I)zi hook:before-load-pre <->]}
+ ${(on)ZI_EXTS[(I)z-annex hook:before-load-<-> <->]}
+ ${(on)ZI_EXTS2[(I)zi hook:before-load-post <->]}
+ )
+ for ___key in "${reply[@]}"; do
+ ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]:-$ZI_EXTS2[$___key]}[@]}" )
+ "${___arr[5]}" "$___type" "$___id" "${ICE[id_as]}" \
+ "${(j: :)${(q)@[2,-1]}}" "${(j: :)${(qkv)___ices[@]}}" \
+ "${${___key##(zi|z-annex) hook:}%% <->}" load
___retval2=$?
- local ___last_ice=${@[___retval2]}
- shift ___retval2
- if [[ $# -gt 0 && $1 != for ]] {
- +zi-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:" \
- "{apo}\`{cmd}$1{apo}\`{rst} "
- +zi-prehelp-usage-message rst
- return 1
- } elif (( $# == 0 )) {
- ___error=1
+ if (( ___retval2 )) {
+ # An error is actually only an odd return code.
+ ___retval+=$(( ___retval2 & 1 ? ___retval2 : 0 ))
+ (( ___retval2 & 1 && $# )) && shift
+ # Override $@?
+ if (( ___retval2 & 2 )) {
+ local -a ___args
+ ___args=( "${(@Q)${(@z)ZI[annex-before-load:new-@]}}" )
+ builtin set -- "${___args[@]}"
+ }
+ # Override $___ices?
+ if (( ___retval2 & 4 )) {
+ local -a ___new_ices
+ ___new_ices=( "${(Q@)${(@z)ZI[annex-before-load:new-global-ices]}}" )
+ (( 0 == ${#___new_ices} % 2 )) && \
+ ___ices=( "${___new_ices[@]}" ) || \
+ { [[ ${ZI[MUTE_WARNINGS]} != (1|true|on|yes) ]] && \
+ +zi-message "{u-warn}Warning{b-warn}:{msg} Bad new-ices returned" \
+ "from the annex{ehi}:{rst} {annex}${___arr[3]}{msg}," \
+ "please file an issue report at:{url}" \
+ "https://github.com/z-shell/${___arr[3]}/issues/new{msg}.{rst}"
+ ___ices=( ) ___retval+=7
+ }
+ }
+ continue 2
+ }
+ done
+ integer ___action_load=0 ___turbo=0
+ if [[ -n ${(M)${+ICE[wait]}:#1}${ICE[load]}${ICE[unload]}${ICE[service]}${ICE[subscribe]} ]] {
+ ___turbo=1
+ }
+
+ if [[ -n ${ICE[trigger-load]} || \
+ ( ${+ICE[wait]} == 1 &&
+ ${ICE[wait]} = (\!|)(<->(a|b|c|)|) )
+ ]] && (( !ZI[OPTIMIZE_OUT_DISK_ACCESSES]
+ )) {
+ if (( ___is_snippet > 0 )) {
+ .zi-get-object-path snippet $___ehid
} else {
- shift
+ .zi-get-object-path plugin $___ehid
+ }
+ (( $? )) && [[ ${zsh_eval_context[1]} = file ]] && { ___action_load=1; }
+ local ___object_path="$REPLY"
+ } elif (( ! ___turbo )) {
+ ___action_load=1
+ reply=( 1 )
+ } else {
+ reply=( 1 )
+ }
+
+ if [[ ${reply[-1]} -eq 1 && -n ${ICE[trigger-load]} ]] {
+ () {
+ builtin setopt localoptions extendedglob
+ local ___mode
+ (( ___is_snippet > 0 )) && ___mode=snippet || ___mode="${${${ICE[light-mode]+light}}:-load}"
+ for MATCH ( ${(s.;.)ICE[trigger-load]} ) {
+ eval "${MATCH#!}() {
+ ${${(M)MATCH#!}:+unset -f ${MATCH#!}}
+ local a b; local -a ices
+ # The wait'' ice is filtered-out.
+ for a b ( ${(qqkv@)${(kv@)ICE[(I)^(trigger-load|wait|light-mode)]}} ) {
+ ices+=( \"\$a\$b\" )
+ }
+ zi ice \${ices[@]}; zi $___mode ${(qqq)___id}
+ ${${(M)MATCH#!}:+# Forward the call
+ eval ${MATCH#!} \$@}
+ }"
+ }
+ } "$@"
+ ___retval+=$?
+ (( $# )) && shift
+ continue
+ }
+
+ if (( ${+ICE[if]} )) {
+ eval "${ICE[if]}" || { (( $# )) && shift; continue; };
+ }
+ for REPLY ( ${(s.;.)ICE[has]} ) {
+ (( ${+commands[$REPLY]} )) || \
+ { (( $# )) && shift; continue 2; }
+ }
+
+ integer ___had_cloneonly=0
+ ICE[wait]="${${(M)${+ICE[wait]}:#1}:+${(M)ICE[wait]#!}${${ICE[wait]#!}:-0}}"
+ if (( ___action_load || !ZI[HAVE_SCHEDULER] )) {
+ if (( ___turbo && ZI[HAVE_SCHEDULER] )) {
+ ___had_cloneonly=${+ICE[cloneonly]}
+ ICE[cloneonly]=""
}
- }
- integer ___had_wait
- local ___id ___ehid ___etid ___key
- local -a ___arr
- ZI[annex-exposed-processed-IDs]=
- if (( $# )) {
- local -a ___ices
- ___ices=( "${(kv)ZI_ICES[@]}" )
- ZI_ICES=()
- while (( $# )) {
- .zi-ice "$@"
- ___retval2=$?
- local ___last_ice=${@[___retval2]}
- shift ___retval2
- if [[ -n $1 ]] {
- ICE=( "${___ices[@]}" "${(kv)ZI_ICES[@]}" )
- ZI_ICE=( "${(kv)ICE[@]}" ) ZI_ICES=()
- integer ___msgs=${+ICE[debug]}
- (( ___msgs )) && +zi-message "{pre}zi-main:{faint} Processing {pname}$1{faint}{…}{rst}"
- # Delete up to the final space to get the previously-processed ID.
- ZI[annex-exposed-processed-IDs]+="${___id:+ $___id}"
- # Strip the ID-qualifier (`@') and GitHub domain from the ID.
- ___id="${${1#@}%%(///|//|/)}"
- (( ___is_snippet == -1 )) && ___id="${___id#https://github.com/}"
- # Effective handle-ID – the label under which the object
- # will be identified / referred-to by ZI.
- ___ehid="${ICE[id-as]:-$___id}"
- # Effective remote-ID (i.e.: URL, GitHub username/repo,
- # package name, etc.). teleid'' allows "overriding" of $1.
- # In case of a package using teleid'', the value here
- # is being took from the given ices, before disk-ices.
- ___etid="${ICE[teleid]:-$___id}"
- if (( ${+ICE[pack]} )); then
- ___had_wait=${+ICE[wait]}
- .zi-load-ices "$___ehid"
- # wait'' isn't possible via the disk-ices (for
- # packages), only via the command's ice-spec.
- [[ $___had_wait -eq 0 ]] && unset 'ICE[wait]'
- fi
- [[ ${ICE[id-as]} = (auto|) && ${+ICE[id-as]} == 1 ]] && ICE[id-as]="${___etid:t}"
- integer ___is_snippet=${${(M)___is_snippet:#-1}:-0}
- () {
- builtin setopt localoptions extendedglob
- if [[ $___is_snippet -ge 0 && ( -n ${ICE[is-snippet]+1} || $___etid = ((#i)(http(s|)|ftp(s|)):/|(${(~kj.|.)ZI_1MAP}))* ) ]] {
- ___is_snippet=1
- }
- } "$@"
- local ___type=${${${(M)___is_snippet:#1}:+snippet}:-plugin}
- reply=(
- ${(on)ZI_EXTS2[(I)zi hook:before-load-pre <->]}
- ${(on)ZI_EXTS[(I)z-annex hook:before-load-<-> <->]}
- ${(on)ZI_EXTS2[(I)zi hook:before-load-post <->]}
- )
- for ___key in "${reply[@]}"; do
- ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]:-$ZI_EXTS2[$___key]}[@]}" )
- "${___arr[5]}" "$___type" "$___id" "${ICE[id_as]}" \
- "${(j: :)${(q)@[2,-1]}}" "${(j: :)${(qkv)___ices[@]}}" \
- "${${___key##(zi|z-annex) hook:}%% <->}" load
- ___retval2=$?
- if (( ___retval2 )) {
- # An error is actually only an odd return code.
- ___retval+=$(( ___retval2 & 1 ? ___retval2 : 0 ))
- (( ___retval2 & 1 && $# )) && shift
-
- # Override $@?
- if (( ___retval2 & 2 )) {
- local -a ___args
- ___args=( "${(@Q)${(@z)ZI[annex-before-load:new-@]}}" )
- builtin set -- "${___args[@]}"
- }
- # Override $___ices?
- if (( ___retval2 & 4 )) {
- local -a ___new_ices
- ___new_ices=( "${(Q@)${(@z)ZI[annex-before-load:new-global-ices]}}" )
- (( 0 == ${#___new_ices} % 2 )) && \
- ___ices=( "${___new_ices[@]}" ) || \
- { [[ ${ZI[MUTE_WARNINGS]} != (1|true|on|yes) ]] && \
- +zi-message "{u-warn}Warning{b-warn}:{msg} Bad new-ices returned" \
- "from the annex{ehi}:{rst} {annex}${___arr[3]}{msg}," \
- "please file an issue report at:{url}" \
- "https://github.com/z-shell/${___arr[3]}/issues/new{msg}.{rst}"
- ___ices=( ) ___retval+=7
- }
- }
- continue 2
- }
- done
- integer ___action_load=0 ___turbo=0
- if [[ -n ${(M)${+ICE[wait]}:#1}${ICE[load]}${ICE[unload]}${ICE[service]}${ICE[subscribe]} ]] {
- ___turbo=1
- }
-
- if [[ -n ${ICE[trigger-load]} || \
- ( ${+ICE[wait]} == 1 &&
- ${ICE[wait]} = (\!|)(<->(a|b|c|)|) )
- ]] && (( !ZI[OPTIMIZE_OUT_DISK_ACCESSES]
- )) {
- if (( ___is_snippet > 0 )) {
- .zi-get-object-path snippet $___ehid
- } else {
- .zi-get-object-path plugin $___ehid
- }
- (( $? )) && [[ ${zsh_eval_context[1]} = file ]] && { ___action_load=1; }
- local ___object_path="$REPLY"
- } elif (( ! ___turbo )) {
- ___action_load=1
- reply=( 1 )
- } else {
- reply=( 1 )
- }
- if [[ ${reply[-1]} -eq 1 && -n ${ICE[trigger-load]} ]] {
- () {
- builtin setopt localoptions extendedglob
- local ___mode
- (( ___is_snippet > 0 )) && ___mode=snippet || ___mode="${${${ICE[light-mode]+light}}:-load}"
- for MATCH ( ${(s.;.)ICE[trigger-load]} ) {
- eval "${MATCH#!}() {
- ${${(M)MATCH#!}:+unset -f ${MATCH#!}}
- local a b; local -a ices
- # The wait'' ice is filtered-out.
- for a b ( ${(qqkv@)${(kv@)ICE[(I)^(trigger-load|wait|light-mode)]}} ) {
- ices+=( \"\$a\$b\" )
- }
- zi ice \${ices[@]}; zi $___mode ${(qqq)___id}
- ${${(M)MATCH#!}:+# Forward the call
- eval ${MATCH#!} \$@}
- }"
- }
- } "$@"
- ___retval+=$?
- (( $# )) && shift
- continue
- }
+ (( ___is_snippet )) && \
+ local ___opt="${(k)OPTS[*]}" || \
+ local ___opt="${${ICE[light-mode]+light}:-${OPTS[(I)-b]:+light-b}}"
- if (( ${+ICE[if]} )) {
- eval "${ICE[if]}" || { (( $# )) && shift; continue; };
- }
- for REPLY ( ${(s.;.)ICE[has]} ) {
- (( ${+commands[$REPLY]} )) || \
- { (( $# )) && shift; continue 2; }
- }
+ .zi-load-object ${${${(M)___is_snippet:#1}:+snippet}:-plugin} $___id $___opt
+ integer ___last_retval=$?
+ ___retval+=___last_retval
- integer ___had_cloneonly=0
- ICE[wait]="${${(M)${+ICE[wait]}:#1}:+${(M)ICE[wait]#!}${${ICE[wait]#!}:-0}}"
- if (( ___action_load || !ZI[HAVE_SCHEDULER] )) {
- if (( ___turbo && ZI[HAVE_SCHEDULER] )) {
- ___had_cloneonly=${+ICE[cloneonly]}
- ICE[cloneonly]=""
- }
-
- (( ___is_snippet )) && \
- local ___opt="${(k)OPTS[*]}" || \
- local ___opt="${${ICE[light-mode]+light}:-${OPTS[(I)-b]:+light-b}}"
-
- .zi-load-object ${${${(M)___is_snippet:#1}:+snippet}:-plugin} $___id $___opt
- integer ___last_retval=$?
- ___retval+=___last_retval
-
- if (( ___turbo && !___had_cloneonly && ZI[HAVE_SCHEDULER] )) {
- command rm -f $___object_path/._zi/cloneonly
- unset 'ICE[cloneonly]'
- }
- }
- if (( ___turbo && ZI[HAVE_SCHEDULER] && 0 == ___last_retval )) {
- ICE[wait]="${ICE[wait]:-${ICE[service]:+0}}"
- if (( ___is_snippet > 0 )); then
- ZI_SICE[$___ehid]=
- .zi-submit-turbo s${ICE[service]:+1} "" \
- "$___id" "${(k)OPTS[*]}"
- else
- ZI_SICE[$___ehid]=
- .zi-submit-turbo p${ICE[service]:+1} \
- "${${${ICE[light-mode]+light}}:-load}" \
- "$___id" ""
- fi
- ___retval+=$?
- }
- } else {
- ___error=1
- }
- (( $# )) && shift
- ___is_snippet=0
+ if (( ___turbo && !___had_cloneonly && ZI[HAVE_SCHEDULER] )) {
+ command rm -f $___object_path/._zi/cloneonly
+ unset 'ICE[cloneonly]'
}
+ }
+ if (( ___turbo && ZI[HAVE_SCHEDULER] && 0 == ___last_retval )) {
+ ICE[wait]="${ICE[wait]:-${ICE[service]:+0}}"
+ if (( ___is_snippet > 0 )); then
+ ZI_SICE[$___ehid]=
+ .zi-submit-turbo s${ICE[service]:+1} "" \
+ "$___id" "${(k)OPTS[*]}"
+ else
+ ZI_SICE[$___ehid]=
+ .zi-submit-turbo p${ICE[service]:+1} \
+ "${${${ICE[light-mode]+light}}:-load}" \
+ "$___id" ""
+ fi
+ ___retval+=$?
+ }
} else {
- ___error=1
+ ___error=1
}
+ (( $# )) && shift
+ ___is_snippet=0
+ }
+ } else {
+ ___error=1
+ }
- if (( ___error )) {
- () {
- emulate -LR zsh -o extendedglob
- +zi-message -n "{u-warn}Error{b-warn}:{rst} No plugin or snippet ID given"
- if [[ -n $___last_ice ]] {
- +zi-message -n " (the last recognized ice was: {ice}"\
+ if (( ___error )) {
+ () {
+ emulate -LR zsh -o extendedglob
+ +zi-message -n "{u-warn}Error{b-warn}:{rst} No plugin or snippet ID given"
+ if [[ -n $___last_ice ]] {
+ +zi-message -n " (the last recognized ice was: {ice}"\
"${___last_ice/(#m)(${~ZI[ice-list]})/"{data}$MATCH"}{apo}''{rst}).{error}
You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice is in fact a plugin.{rst}
{note}Note:{rst} The {apo}\`{ice}ice{apo}\`{rst} subcommand is now again required if not using the for-syntax"
- }
- +zi-message "."
- }
- return 2
- } elif (( ! $# )) {
- return ___retval
}
+ +zi-message "."
+ }
+ return 2
+ } elif (( ! $# )) {
+ return ___retval
}
-
- case "$1" in
- (ice)
- shift
- .zi-ice "$@"
- ;;
- (cdreplay)
- .zi-compdef-replay "$2"; ___retval=$?
- ;;
- (cdclear)
- .zi-compdef-clear "$2"
- ;;
- (add-fpath)
- .zi-add-fpath "${@[2-correct,-1]}"
- ;;
- (run)
- .zi-run "${@[2-correct,-1]}"
- ;;
- (dstart|dtrace)
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-debug-start
- ;;
- (dstop)
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-debug-stop
- ;;
- (man)
- man "${ZI[BIN_DIR]}/docs/man/zi.1"
- ;;
- (env-whitelist)
- shift
- .zi-parse-opts env-whitelist "$@"
- builtin set -- "${reply[@]}"
-
- if (( $# == 0 )) {
- ZI[ENV-WHITELIST]=
- (( OPTS[opt_-v,--verbose] )) && +zi-message "{msg2}Cleared the parameter whitelist.{rst}"
- } else {
- ZI[ENV-WHITELIST]+="${(j: :)${(q-kv)@}} "
- local ___sep="$ZI[col-msg2], $ZI[col-data2]"
- (( OPTS[opt_-v,--verbose] )) && +zi-message "{msg2}Extended the parameter whitelist with: {data2}${(pj:$___sep:)@}{msg2}.{rst}"
+ }
+
+ case "$1" in
+ (ice)
+ shift
+ .zi-ice "$@"
+ ;;
+ (cdreplay)
+ .zi-compdef-replay "$2"; ___retval=$?
+ ;;
+ (cdclear)
+ .zi-compdef-clear "$2"
+ ;;
+ (add-fpath)
+ .zi-add-fpath "${@[2-correct,-1]}"
+ ;;
+ (run)
+ .zi-run "${@[2-correct,-1]}"
+ ;;
+ (dstart|dtrace)
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-debug-start
+ ;;
+ (dstop)
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-debug-stop
+ ;;
+ (man)
+ man "${ZI[BIN_DIR]}/docs/man/zi.1"
+ ;;
+ (env-whitelist)
+ shift
+ .zi-parse-opts env-whitelist "$@"
+ builtin set -- "${reply[@]}"
+
+ if (( $# == 0 )) {
+ ZI[ENV-WHITELIST]=
+ (( OPTS[opt_-v,--verbose] )) && +zi-message "{msg2}Cleared the parameter whitelist.{rst}"
+ } else {
+ ZI[ENV-WHITELIST]+="${(j: :)${(q-kv)@}} "
+ local ___sep="$ZI[col-msg2], $ZI[col-data2]"
+ (( OPTS[opt_-v,--verbose] )) && +zi-message "{msg2}Extended the parameter whitelist with: {data2}${(pj:$___sep:)@}{msg2}.{rst}"
+ }
+ ;;
+ (*)
+ # Check if there is a z-annex registered for the subcommand.
+ reply=( ${ZI_EXTS[z-annex subcommand:${(q)1}]} )
+ (( ${#reply} )) && {
+ reply=( "${(Q)${(z@)reply[1]}[@]}" )
+ (( ${+functions[${reply[5]}]} )) && \
+ { "${reply[5]}" "$@"; return $?; } || \
+ { +zi-message "({error}Couldn't find the subcommand-handler \`{obj}${reply[5]}{error}' of the z-annex \`{file}${reply[3]}{error}')"; return 1; }
+ }
+ (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ case "$1" in
+ (zstatus)
+ .zi-show-zstatus
+ ;;
+ (times)
+ .zi-show-times "${@[2-correct,-1]}"
+ ;;
+ (self-update)
+ .zi-self-update
+ ;;
+ (unload)
+ (( ${+functions[.zi-unload]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ if [[ -z $2 && -z $3 ]]; then
+ builtin print "Argument needed, try: help"; ___retval=1
+ else
+ [[ $2 = -q ]] && { 5=-q; shift; }
+ # Unload given plugin. Cloned directory remains intact
+ # so as are completions.
+ .zi-unload "${2%%(///|//|/)}" "${${3:#-q}%%(///|//|/)}" "${${(M)4:#-q}:-${(M)3:#-q}}"; ___retval=$?
+ fi
+ ;;
+ (bindkeys)
+ .zi-list-bindkeys
+ ;;
+ (update)
+ if (( ${+ICE[if]} )) {
+ eval "${ICE[if]}" || return 1;
+ }
+ for REPLY ( ${(s.;.)ICE[has]} ) {
+ (( ${+commands[$REPLY]} )) || return 1
+ }
+ shift
+ .zi-parse-opts update "$@"
+ builtin set -- "${reply[@]}"
+ if [[ ${OPTS[opt_-a,--all]} -eq 1 || ${OPTS[opt_-p,--parallel]} -eq 1 || ${OPTS[opt_-s,--snippets]} -eq 1 || ${OPTS[opt_-l,--plugins]} -eq 1 || -z $1$2${ICE[teleid]}${ICE[id-as]} ]]; then
+ [[ -z $1$2 && $(( OPTS[opt_-a,--all] + OPTS[opt_-p,--parallel] + OPTS[opt_-s,--snippets] + OPTS[opt_-l,--plugins] )) -eq 0 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
+ (( OPTS[opt_-p,--parallel] )) && OPTS[value]=${1:-15}
+ .zi-update-or-status-all update; ___retval=$?
+ else
+ local ___key ___id="${1%%(///|//|/)}${2:+/}${2%%(///|//|/)}"
+ [[ -z ${___id//[[:space:]]/} ]] && ___id="${ICE[id-as]:-$ICE[teleid]}"
+ .zi-update-or-status update "$___id" ""; ___retval=$?
+ fi
+ ;;
+ (status)
+ if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
+ [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
+ .zi-update-or-status-all status; ___retval=$?
+ else
+ .zi-update-or-status status "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
+ fi
+ ;;
+ (report)
+ if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
+ [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 4; }
+ .zi-show-all-reports
+ else
+ .zi-show-report "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
+ fi
+ ;;
+ (loaded|list)
+ # Show list of loaded plugins.
+ .zi-show-registered-plugins "$2"
+ ;;
+ (clist|completions)
+ # Show installed, enabled or disabled, completions.
+ # Detect stray and improper ones.
+ .zi-show-completions "$2"
+ ;;
+ (cclear)
+ # Delete stray and improper completions.
+ .zi-clear-completions
+ ;;
+ (cdisable)
+ if [[ -z $2 ]]; then
+ builtin print "Argument needed, try: help"; ___retval=1
+ else
+ local ___f="_${2#_}"
+ # Disable completion given by completion function name
+ # with or without leading _, e.g. cp, _cp.
+ if .zi-cdisable "$___f"; then
+ (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ .zi-forget-completion "$___f"
+ +zi-message "Initializing completion system ({func}compinit{rst}){…}"
+ builtin autoload -Uz compinit
+ compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
+ else
+ ___retval=1
+ fi
+ fi
+ ;;
+ (cenable)
+ if [[ -z $2 ]]; then
+ builtin print "Argument needed, try: help"; ___retval=1
+ else
+ local ___f="_${2#_}"
+ # Enable completion given by completion function name
+ # with or without leading _, e.g. cp, _cp.
+ if .zi-cenable "$___f"; then
+ (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ .zi-forget-completion "$___f"
+ +zi-message "Initializing completion system ({func}compinit{rst}){…}"
+ builtin autoload -Uz compinit
+ compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
+ else
+ ___retval=1
+ fi
+ fi
+ ;;
+ (creinstall)
+ (( ${+functions[.zi-install-completions]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ # Installs completions for plugin. Enables them all. It's a
+ # reinstallation, thus every obstacle gets overwritten or removed.
+ [[ $2 = -[qQ] ]] && { 5=$2; shift; }
+ .zi-install-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}" 1 "${(M)4:#-[qQ]}"; ___retval=$?
+ [[ -z ${(M)4:#-[qQ]} ]] && +zi-message "Initializing completion ({func}compinit{rst}){…}"
+ builtin autoload -Uz compinit
+ compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
+ ;;
+ (cuninstall)
+ if [[ -z $2 && -z $3 ]]; then
+ builtin print "Argument needed, try: help"; ___retval=1
+ else
+ (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ # Uninstalls completions for plugin.
+ .zi-uninstall-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
+ +zi-message "Initializing completion ({func}compinit{rst}){…}"
+ builtin autoload -Uz compinit
+ compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
+ fi
+ ;;
+ (csearch)
+ .zi-search-completions
+ ;;
+ (compinit)
+ (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ .zi-compinit; ___retval=$?
+ ;;
+ (dreport)
+ .zi-show-debug-report
+ ;;
+ (dclear)
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-clear-debug-report
+ ;;
+ (dunload)
+ (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
+ .zi-debug-unload
+ ;;
+ (compile)
+ (( ${+functions[.zi-compile-plugin]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
+ if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
+ [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
+ .zi-compile-uncompile-all 1; ___retval=$?
+ else
+ .zi-compile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
+ fi
+ ;;
+ (uncompile)
+ if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
+ [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
+ .zi-compile-uncompile-all 0; ___retval=$?
+ else
+ .zi-uncompile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
+ fi
+ ;;
+ (compiled)
+ .zi-compiled
+ ;;
+ (cdlist)
+ .zi-list-compdef-replay
+ ;;
+ (cd|delete|recall|edit|glance|changes|create|stress)
+ .zi-"$1" "${@[2-correct,-1]%%(///|//|/)}"; ___retval=$?
+ ;;
+ (recently)
+ shift
+ .zi-recently "$@"; ___retval=$?
+ ;;
+ (control)
+ .zi-control-menu
+ ;;
+ (analytics)
+ .zi-analytics-menu
+ ;;
+ (-h|help)
+ .zi-help
+ ;;
+ (ls)
+ shift
+ .zi-ls "$@"
+ ;;
+ (srv)
+ () { setopt localoptions extendedglob warncreateglobal
+ [[ ! -e ${ZI[SERVICES_DIR]}/"$2".fifo ]] && { builtin print "No such service: $2"; } ||
+ { [[ $3 = (#i)(next|stop|quit|restart) ]] &&
+ { builtin print "${(U)3}" >>! ${ZI[SERVICES_DIR]}/"$2".fifo || builtin print "Service $2 inactive"; ___retval=1; } ||
+ { [[ $3 = (#i)start ]] && rm -f ${ZI[SERVICES_DIR]}/"$2".stop ||
+ { builtin print "Unknown service-command: $3"; ___retval=1; }
+ }
}
- ;;
+ } "$@"
+ ;;
+ (module)
+ .zi-module "${@[2-correct,-1]}"; ___retval=$?
+ ;;
(*)
- # Check if there is a z-annex registered for the subcommand.
- reply=( ${ZI_EXTS[z-annex subcommand:${(q)1}]} )
- (( ${#reply} )) && {
- reply=( "${(Q)${(z@)reply[1]}[@]}" )
- (( ${+functions[${reply[5]}]} )) && \
- { "${reply[5]}" "$@"; return $?; } || \
- { +zi-message "({error}Couldn't find the subcommand-handler \`{obj}${reply[5]}{error}' of the z-annex \`{file}${reply[3]}{error}')"; return 1; }
- }
- (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
- case "$1" in
- (zstatus)
- .zi-show-zstatus
- ;;
- (times)
- .zi-show-times "${@[2-correct,-1]}"
- ;;
- (self-update)
- .zi-self-update
- ;;
- (unload)
- (( ${+functions[.zi-unload]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
- if [[ -z $2 && -z $3 ]]; then
- builtin print "Argument needed, try: help"; ___retval=1
- else
- [[ $2 = -q ]] && { 5=-q; shift; }
- # Unload given plugin. Cloned directory remains intact
- # so as are completions.
- .zi-unload "${2%%(///|//|/)}" "${${3:#-q}%%(///|//|/)}" "${${(M)4:#-q}:-${(M)3:#-q}}"; ___retval=$?
- fi
- ;;
- (bindkeys)
- .zi-list-bindkeys
- ;;
- (update)
- if (( ${+ICE[if]} )) {
- eval "${ICE[if]}" || return 1;
- }
- for REPLY ( ${(s.;.)ICE[has]} ) {
- (( ${+commands[$REPLY]} )) || return 1
- }
- shift
- .zi-parse-opts update "$@"
- builtin set -- "${reply[@]}"
- if [[ ${OPTS[opt_-a,--all]} -eq 1 || ${OPTS[opt_-p,--parallel]} -eq 1 || ${OPTS[opt_-s,--snippets]} -eq 1 || ${OPTS[opt_-l,--plugins]} -eq 1 || -z $1$2${ICE[teleid]}${ICE[id-as]} ]]; then
- [[ -z $1$2 && $(( OPTS[opt_-a,--all] + OPTS[opt_-p,--parallel] + OPTS[opt_-s,--snippets] + OPTS[opt_-l,--plugins] )) -eq 0 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
- (( OPTS[opt_-p,--parallel] )) && OPTS[value]=${1:-15}
- .zi-update-or-status-all update; ___retval=$?
- else
- local ___key ___id="${1%%(///|//|/)}${2:+/}${2%%(///|//|/)}"
- [[ -z ${___id//[[:space:]]/} ]] && ___id="${ICE[id-as]:-$ICE[teleid]}"
- .zi-update-or-status update "$___id" ""; ___retval=$?
- fi
- ;;
- (status)
- if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
- [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
- .zi-update-or-status-all status; ___retval=$?
- else
- .zi-update-or-status status "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
- fi
- ;;
- (report)
- if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
- [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 4; }
- .zi-show-all-reports
- else
- .zi-show-report "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
- fi
- ;;
- (loaded|list)
- # Show list of loaded plugins.
- .zi-show-registered-plugins "$2"
- ;;
- (clist|completions)
- # Show installed, enabled or disabled, completions.
- # Detect stray and improper ones.
- .zi-show-completions "$2"
- ;;
- (cclear)
- # Delete stray and improper completions.
- .zi-clear-completions
- ;;
- (cdisable)
- if [[ -z $2 ]]; then
- builtin print "Argument needed, try: help"; ___retval=1
- else
- local ___f="_${2#_}"
- # Disable completion given by completion function name
- # with or without leading _, e.g. cp, _cp.
- if .zi-cdisable "$___f"; then
- (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- .zi-forget-completion "$___f"
- +zi-message "Initializing completion system ({func}compinit{rst}){…}"
- builtin autoload -Uz compinit
- compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
- else
- ___retval=1
- fi
- fi
- ;;
- (cenable)
- if [[ -z $2 ]]; then
- builtin print "Argument needed, try: help"; ___retval=1
- else
- local ___f="_${2#_}"
- # Enable completion given by completion function name
- # with or without leading _, e.g. cp, _cp.
- if .zi-cenable "$___f"; then
- (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- .zi-forget-completion "$___f"
- +zi-message "Initializing completion system ({func}compinit{rst}){…}"
- builtin autoload -Uz compinit
- compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
- else
- ___retval=1
- fi
- fi
- ;;
- (creinstall)
- (( ${+functions[.zi-install-completions]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- # Installs completions for plugin. Enables them all. It's a
- # reinstallation, thus every obstacle gets overwritten or removed.
- [[ $2 = -[qQ] ]] && { 5=$2; shift; }
- .zi-install-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}" 1 "${(M)4:#-[qQ]}"; ___retval=$?
- [[ -z ${(M)4:#-[qQ]} ]] && +zi-message "Initializing completion ({func}compinit{rst}){…}"
- builtin autoload -Uz compinit
- compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
- ;;
- (cuninstall)
- if [[ -z $2 && -z $3 ]]; then
- builtin print "Argument needed, try: help"; ___retval=1
- else
- (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- # Uninstalls completions for plugin.
- .zi-uninstall-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
- +zi-message "Initializing completion ({func}compinit{rst}){…}"
- builtin autoload -Uz compinit
- compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
- fi
- ;;
- (csearch)
- .zi-search-completions
- ;;
- (compinit)
- (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- .zi-compinit; ___retval=$?
- ;;
- (dreport)
- .zi-show-debug-report
- ;;
- (dclear)
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-clear-debug-report
- ;;
- (dunload)
- (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh"
- .zi-debug-unload
- ;;
- (compile)
- (( ${+functions[.zi-compile-plugin]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
- [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
- .zi-compile-uncompile-all 1; ___retval=$?
- else
- .zi-compile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
- fi
- ;;
- (uncompile)
- if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
- [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
- .zi-compile-uncompile-all 0; ___retval=$?
- else
- .zi-uncompile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
- fi
- ;;
- (compiled)
- .zi-compiled
- ;;
- (cdlist)
- .zi-list-compdef-replay
- ;;
- (cd|delete|recall|edit|glance|changes|create|stress)
- .zi-"$1" "${@[2-correct,-1]%%(///|//|/)}"; ___retval=$?
- ;;
- (recently)
- shift
- .zi-recently "$@"; ___retval=$?
- ;;
- (control)
- .zi-control-menu
- ;;
- (analytics)
- .zi-analytics-menu
- ;;
- (-h|help)
- .zi-help
- ;;
- (ls)
- shift
- .zi-ls "$@"
- ;;
- (srv)
- () { setopt localoptions extendedglob warncreateglobal
- [[ ! -e ${ZI[SERVICES_DIR]}/"$2".fifo ]] && { builtin print "No such service: $2"; } ||
- { [[ $3 = (#i)(next|stop|quit|restart) ]] &&
- { builtin print "${(U)3}" >>! ${ZI[SERVICES_DIR]}/"$2".fifo || builtin print "Service $2 inactive"; ___retval=1; } ||
- { [[ $3 = (#i)start ]] && rm -f ${ZI[SERVICES_DIR]}/"$2".stop ||
- { builtin print "Unknown service-command: $3"; ___retval=1; }
- }
- }
- } "$@"
- ;;
- (module)
- .zi-module "${@[2-correct,-1]}"; ___retval=$?
- ;;
- (*)
- if [[ -z $1 ]] {
- +zi-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Missing a {cmd}subcommand "
- +zi-prehelp-usage-message rst
- } else {
- +zi-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:{rst}" \
- "{apo}\`{error}$1{apo}\`{rst} "
- +zi-prehelp-usage-message rst
- }
- ___retval=1
- ;;
- esac
- ;;
- esac
-
- return ___retval
+ if [[ -z $1 ]] {
+ +zi-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Missing a {cmd}subcommand "
+ +zi-prehelp-usage-message rst
+ } else {
+ +zi-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Unknown subcommand{ehi}:{rst}" \
+ "{apo}\`{error}$1{apo}\`{rst} "
+ +zi-prehelp-usage-message rst
+ }
+ ___retval=1
+ ;;
+ esac
+ ;;
+ esac
+
+ return ___retval
} # ]]]
# FUNCTION: zicdreplay. [[[
# A function that can be invoked from within `atinit', `atload', etc.
@@ -3012,22 +2897,17 @@ zicompdef() { ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
# ]]]
# FUNCTION: @autoload. [[[
@autoload() {
- :zi-tmp-subst-autoload -Uz \
- ${(s: :)${${(j: :)${@#\!}}//(#b)((*)(->|=>|→)(*)|(*))/${match[2]:+$match[2] -S $match[4]}${match[5]:+${match[5]} -S ${match[5]}}}} \
- ${${${(@M)${@#\!}:#*(->|=>|→)*}}:+-C} ${${@#\!}:+-C}
-}
-# ]]]
+ :zi-tmp-subst-autoload -Uz \
+ ${(s: :)${${(j: :)${@#\!}}//(#b)((*)(->|=>|→)(*)|(*))/${match[2]:+$match[2] -S $match[4]}${match[5]:+${match[5]} -S ${match[5]}}}} \
+ ${${${(@M)${@#\!}:#*(->|=>|→)*}}:+-C} ${${@#\!}:+-C}
+} # ]]]
# Compatibility functions. [[[
+zt() { zi depth'3' lucid ${1/#[0-9][a-d]/wait"${1}"} "${@:2}"; }
zinit() { zi "$@"; }
zpcdreplay() { .zi-compdef-replay -q; }
zpcdclear() { .zi-compdef-clear -q; }
zpcompinit() { autoload -Uz compinit; compinit -d ${ZI[ZCOMPDUMP_PATH]:-${ZDOTDIR:-$HOME}/.zcompdump} "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"; }
zpcompdef() { ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
-# ]]]
-# FUNCTION: zt. [[[
-# Common ICE modifier to simplify Turbo mode.
-zt() { zi depth'3' lucid ${1/#[0-9][a-d]/wait"${1}"} "${@:2}"; }
-# ]]]
#
# Source-executed code.
@@ -3038,8 +2918,8 @@ zt() { zi depth'3' lucid ${1/#[0-9][a-d]/wait"${1}"} "${@:2}"; }
autoload add-zsh-hook
if { zmodload zsh/datetime } {
- add-zsh-hook -- precmd @zi-scheduler # zsh/datetime required for wait/load/unload ice-mods
- ZI[HAVE_SCHEDULER]=1
+ add-zsh-hook -- precmd @zi-scheduler # zsh/datetime required for wait/load/unload ice-mods
+ ZI[HAVE_SCHEDULER]=1
}
functions -M -- zi_scheduler_add 1 1 -zi_scheduler_add_sh 2>/dev/null
zmodload zsh/zpty zsh/system 2>/dev/null
@@ -3053,11 +2933,10 @@ builtin alias zpl=zi zplg=zi zini=zi
# Remember source's timestamps for the automatic-reload feature.
typeset -g ZI_TMP
for ZI_TMP ( "" side install autoload ) {
- .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/$ZI_TMP.zsh" "ZI[mtime$ZI_TMP]"
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/$ZI_TMP.zsh" "ZI[mtime$ZI_TMP]"
}
-# Simulate existence of _local/zi plugin.
-# This will allow to cuninstall of its completion
+# Simulate existence of _local/zi plugin. This will allow to cuninstall of its completion
ZI_REGISTERED_PLUGINS=( _local/zi "${(u)ZI_REGISTERED_PLUGINS[@]:#_local/zi}" )
ZI[STATES___local/zi]=1
@@ -3069,40 +2948,33 @@ zstyle ':completion:*:zi:argument-rest:plugins' list-colors '=(#b)(*)/(*)==1;36=
zstyle ':completion:*:zi:argument-rest:plugins' matcher 'r:|=** l:|=*'
zstyle ':completion:*:*:zi:*' group-name ""
# ]]]
-
# module recompilation for the project rename. [[[
if [[ -e "${${ZI[ZMODULES_DIR]}}/zpmod/Src/zi/zpmod.so" ]] {
- if [[ ! -f ${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT || ( ${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT -ot ${${ZI[ZMODULES_DIR]}}/zpmod/RECOMPILE_REQUEST ) ]] {
- # Don't trust access times and verify hard stored values.
- [[ -e ${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT ]] && local compiled_at_ts="$(<${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT)"
- [[ -e ${${ZI[ZMODULES_DIR]}}/zpmod/RECOMPILE_REQUEST ]] && local recompile_request_ts="$(<${${ZI[ZMODULES_DIR]}}/zpmod/RECOMPILE_REQUEST)"
- if [[ ${recompile_request_ts:-1} -gt ${compiled_at_ts:-0} ]] {
- +zi-message "{u-warn}WARNING{b-warn}:{rst}{msg} A {lhi}recompilation{rst}" \
- "of the ZI module has been requested… {hi}Building{rst}…"
- (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
- command make -C "${${ZI[ZMODULES_DIR]}}/zpmod" distclean &>/dev/null
- .zi-module build &>/dev/null
- if command make -C "${${ZI[ZMODULES_DIR]}}/zpmod" &>/dev/null; then
- +zi-message "{ok}Build successful!{rst}"
- else
- builtin print -r -- "${ZI[col-error]}Compilation failed.${ZI[col-rst]}" \
- "${ZI[col-pre]}You can enter the following command:${ZI[col-rst]}" \
- 'make -C ${${ZI[ZMODULES_DIR]}}/zpmod' \
- "${ZI[col-pre]}to see the error messages and e.g.: report an issue" \
- "at GitHub${ZI[col-rst]}"
- fi
- command date '+%s' >! "${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT"
- }
- }
-}
-# ]]]
+ if [[ ! -f ${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT || ( ${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT -ot ${${ZI[ZMODULES_DIR]}}/zpmod/RECOMPILE_REQUEST ) ]] {
+ # Don't trust access times and verify hard stored values.
+ [[ -e ${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT ]] && local compiled_at_ts="$(<${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT)"
+ [[ -e ${${ZI[ZMODULES_DIR]}}/zpmod/RECOMPILE_REQUEST ]] && local recompile_request_ts="$(<${${ZI[ZMODULES_DIR]}}/zpmod/RECOMPILE_REQUEST)"
+ if [[ ${recompile_request_ts:-1} -gt ${compiled_at_ts:-0} ]] {
+ +zi-message "{u-warn}WARNING{b-warn}:{rst}{msg} A {lhi}recompilation{rst}" "of the❮ ZI ❯module has been requested… {hi}Building{rst}…"
+ (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ command make -C "${${ZI[ZMODULES_DIR]}}/zpmod" distclean &>/dev/null
+ .zi-module build &>/dev/null
+ if command make -C "${${ZI[ZMODULES_DIR]}}/zpmod" &>/dev/null; then
+ +zi-message "{ok}Build successful!{rst}"
+ else
+ builtin print -r -- "${ZI[col-error]}Compilation failed.${ZI[col-rst]}" "${ZI[col-pre]}You can enter the following command:${ZI[col-rst]}" \
+ 'make -C ${${ZI[ZMODULES_DIR]}}/zpmod' "${ZI[col-pre]}to see the error messages and e.g.: report an issue" "at GitHub${ZI[col-rst]}"
+ fi
+ command date '+%s' >! "${${ZI[ZMODULES_DIR]}}/zpmod/COMPILED_AT"
+ }
+ }
+} # ]]]
# !atpull-pre.
@zi-register-hook "-r/--reset" hook:e-\!atpull-pre ∞zi-reset-hook
# !atpull-post.
@zi-register-hook "ICE[reset]" hook:e-\!atpull-post ∞zi-reset-hook
@zi-register-hook "atpull'!'" hook:e-\!atpull-post ∞zi-atpull-e-hook
-
# e-!atpull-pre.
@zi-register-hook "make'!!'" hook:no-e-\!atpull-pre ∞zi-make-ee-hook
@zi-register-hook "mv''" hook:no-e-\!atpull-pre ∞zi-mv-hook
@@ -3116,7 +2988,6 @@ if [[ -e "${${ZI[ZMODULES_DIR]}}/zpmod/Src/zi/zpmod.so" ]] {
# atpull-post.
@zi-register-hook "compile-plugin" hook:atpull-post ∞zi-compile-plugin-hook
@zi-register-hook "ps-on-update" hook:%atpull-post ∞zi-ps-on-update-hook
-
# !atclone-pre.
@zi-register-hook "make'!!'" hook:\!atclone-pre ∞zi-make-ee-hook
@zi-register-hook "mv''" hook:\!atclone-pre ∞zi-mv-hook