diff --git a/.github/labeler.yml b/.github/labeler.yml
index 9405908..deee3c1 100644
--- a/.github/labeler.yml
+++ b/.github/labeler.yml
@@ -1,14 +1,22 @@
documentation 📝:
- - "docs/*.md"
- - "docs/man/*"
+ - changed-files:
+ - any-glob-to-any-file:
+ - "docs/*.md"
+ - "docs/man/*"
enhancement ✨:
- - "*.zsh"
- - "lib/**"
+ - changed-files:
+ - any-glob-to-any-file:
+ - "*.zsh"
+ - "lib/**"
maintenance 📈:
- - ".github/CODEOWNERS"
- - ".github/*.yml"
- - ".github/*.json"
- - ".vscode/*"
- - ".trunk/**"
+ - changed-files:
+ - any-glob-to-any-file:
+ - ".github/CODEOWNERS"
+ - ".github/*.yml"
+ - ".github/*.json"
+ - ".vscode/*"
+ - ".trunk/**"
ci 🤖:
- - ".github/workflows/*.yml"
+ - changed-files:
+ - any-glob-to-any-file:
+ - ".github/workflows/*.yml"
diff --git a/.github/workflows/zunit.yml b/.github/workflows/zunit.yml
index aff0fd8..13c28d4 100644
--- a/.github/workflows/zunit.yml
+++ b/.github/workflows/zunit.yml
@@ -8,13 +8,11 @@ on:
paths:
- "lib/zsh/install.zsh"
- "lib/zsh/autoload.zsh"
- pull_request:
- branches: [main]
- paths:
- - "lib/zsh/install.zsh"
- - "lib/zsh/autoload.zsh"
workflow_dispatch: {}
+env:
+ branch_ref: $GITHUB_REF_NAME
+
jobs:
zunit-matrix:
runs-on: ubuntu-latest
@@ -50,7 +48,7 @@ jobs:
with:
repository: "z-shell/zd"
token: ${{ secrets.GITHUB_TOKEN }}
- - run: command git clone --branch main --depth 1 -- https://github.com/z-shell/zi.git zi
+ - run: command git clone --branch ${{ env.branch_ref }} --depth 1 -- https://github.com/z-shell/zi.git zi
- name: "⚡ Install dependencies"
run: |
sudo apt-get update && sudo apt-get install -yq zsh
diff --git a/docs/README.md b/docs/README.md
index d8a8195..5d9d6d4 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -1,66 +1,46 @@
-
+
-
+
❮ Zi ❯
🧙♂️ 🪄 A Swiss Army Knife for Zsh -
- Unix Shell ✨
+ Unix Shell ✨
-
|
|
-
+
|
|
- |
@@ -74,10 +54,8 @@
|
|
@@ -194,21 +172,15 @@
⭐ Credits
diff --git a/lib/_zi b/lib/_zi
index 0ea5fa9..b6933ca 100755
--- a/lib/_zi
+++ b/lib/_zi
@@ -1,6 +1,6 @@
#compdef zi
-setopt local_options warn_create_global type_set_silent
+builtin setopt local_options warn_create_global type_set_silent
local curcontext="$curcontext" state state_descr line ret=1
local -a expl
@@ -61,6 +61,7 @@ commands=(
run:"Execute code inside plugin's folder"
env-whitelist:"Allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose"
add-fpath:"Add plugin folder to \$fpath"
+ version:"Show Zi version"
)
_arguments -C \
@@ -156,14 +157,15 @@ case $state in
&& ret=0
;;
unload|report)
- typeset -a plugins absolute normal
+ typeset -a plugins absolute1 absolute2 absolute3 normal
plugins=( "${ZI_REGISTERED_PLUGINS[@]:#_local/zi}" )
normal=( "${plugins[@]:#%*}" )
- absolute=( "${(M)plugins[@]:#%*}" )
- absolute=( "${absolute[@]/\%\/\//%/}" )
+ absolute1=( "${(M)plugins[@]:#%*}" )
+ absolute1=( "${absolute1[@]/\%\/\//%/}" )
local hm="${HOME%/}"
- absolute=( "${absolute[@]/$hm/HOME}" )
- plugins=( $normal $absolute )
+ absolute2=( "${absolute1[@]/$hm/HOME}" )
+ absolute3=( "${absolute1[@]/\%/}" )
+ plugins=( $absolute1 $absolute2 $absolute3 $normal )
_wanted plugins expl "-- Plugin --" \
compadd "$@" -a - plugins \
diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh
index db32118..7dc2438 100755
--- a/lib/zsh/autoload.zsh
+++ b/lib/zsh/autoload.zsh
@@ -491,7 +491,7 @@ ZI[EXTENDED_GLOB]=""
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]}"
+ (( error )) && +zi-message "{error}Manual edit of ${ZI[COMPLETIONS_DIR]} occurred?{rst}"
} # ]]]
# FUNCTION: .zi-check-which-completions-are-installed [[[
# For each argument that each should be a path to completion
@@ -540,7 +540,7 @@ ZI[EXTENDED_GLOB]=""
# $2 - plugin (only when $1 - i.e. user - given)
.zi-uninstall-completions() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
- builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
+ builtin setopt null_glob extended_glob warn_create_global typeset_silent no_short_loops
typeset -a completions symlinked backup_comps
local c cfile bkpfile
integer action global_action=0
@@ -557,8 +557,9 @@ ZI[EXTENDED_GLOB]=""
# 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#_}
+ cfile="${c:t}"
+ cfile="_${cfile#_}"
+ bkpfile="${cfile#_}"
# Remove symlink to completion
if [[ -n ${symlinked[(r)*/$cfile]} ]]; then
command rm -f ${ZI[COMPLETIONS_DIR]}/$cfile
@@ -581,7 +582,11 @@ ZI[EXTENDED_GLOB]=""
if (( global_action > 0 )); then
+zi-message "{msg}Uninstalled {num}$global_action{rst} completions"
fi
- .zi-compinit >/dev/null
+
+ # Workaround for a nasty trick in _vim
+ (( ${+functions[_vim_files]} )) && unfunction _vim_files
+
+ .zi-compinit 1 1 &>/dev/null
} # ]]]
#
@@ -590,7 +595,7 @@ ZI[EXTENDED_GLOB]=""
# FUNCTION: .zi-pager [[[
.zi-pager() {
- builtin setopt LOCAL_OPTIONS EQUALS
+ builtin setopt extended_glob no_short_loops local_options equals
# Quiet mode ? → no pager.
if (( OPTS[opt_-n,--no-pager] )) {
cat
@@ -623,61 +628,97 @@ ZI[EXTENDED_GLOB]=""
return 0
fi
} # ]]]
+# FUNCTION: .zi-auto-reload [[[
+# Function checks sum of all files that are used to calculate the mtime
+# and if it is different from the stored one, then recompile, and reload.
+.zi-auto-reload() {
+ builtin emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
+ builtin setopt extended_glob warn_create_global
+
+ [[ $1 == (-q|--quiet) ]] && { local quiet=1; } || { local quiet=0; };
+
+ # The sum of all files that are used to calculate the mtime
+ local file rm_file comp_file src_file
+ integer sum ela elb
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/zi.zsh" ela; (( sum += ela ))
+ for file ( side install autoload additional ) {
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/${file}.zsh" elb; (( sum += elb ))
+ }
+
+ # If the sum of all mtime is different from the stored one,
+ # then remove all compiled files then recompile new ones and reload.
+ if (( ZI[mtime] + ZI[mtime-side] + ZI[mtime-install] + ZI[mtime-autoload] + ZI[mtime-additional] != sum )); then
+
+ # Remove all compiled files
+ for rm_file ( ${ZI[BIN_DIR]}/**/*.zwc(DN) ) {
+ command rm -f -- ${rm_compiled} > /dev/null 2>&1
+ }
+
+ # Recompile new ones
+ (( quiet )) || +zi-message -n "{mmdsh}{happy} Zi{rst} » {profile}recompiling codebase{rst}{…}"
+ for comp_file ( ${ZI[BIN_DIR]}/**/*.zsh*~*.zwc ) {
+ zcompile -U -- ${comp_file} > /dev/null 2>&1
+ } && { (( quiet )) || +zi-message " {term}✔{rst}"; }
+
+ # Reload Zi
+ (( quiet )) || +zi-message -n "{mmdsh}{happy} Zi{rst} » {profile}reloading{rst}{…}"
+ for src_file ( zi side install autoload additional ) {
+ builtin source ${ZI[BIN_DIR]}/**/${src_file}.zsh > /dev/null 2>&1
+ } && { (( quiet )) || +zi-message " {term}✔{rst}"; }
+
+ # Update the stored mtime
+ .zi-set-mtime && return 0
+ fi
+} # ]]]
# FUNCTION: .zi-self-update [[[
-# Updates ❮ Zi ❯ code (does a git pull).
+# Function manages self-update of Zi codebase.
+#
+# It will fetch the latest changes from the upstream repository and,
+# display changelog if there are any, then update the codebase and,
+# reload Zi if there are any changes.
#
# User-action entry point.
+#
+# $1 - user given options for self-update (optional)
.zi-self-update() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
- builtin setopt extendedglob typesetsilent warncreateglobal
- [[ $1 != -q ]] && +zi-message "{profile}Updating »»»»{rst} ❮ {happy}Zi{rst} ❯ {…}{rst}"
- local nl=$'\n' escape=$'\x1b[' current_branch=$(builtin cd -q "$ZI[BIN_DIR]" && command git rev-parse --abbrev-ref HEAD 2>/dev/null)
+ builtin setopt extended_glob warn_create_global typeset_silent \
+ no_short_loops rc_quotes no_auto_pushd
+
+ (( OPTS[opt_-D,--dry-run] )) && { local dry_run=1; } || { local dry_run=0; }
+ (( OPTS[opt_-q,--quiet] )) && { local quiet=1 opt='--quiet'; } || { local quiet=0; }
+
+ [[ -z $origin_url ]] && local origin_url="$(builtin cd -q $ZI[BIN_DIR] && command git remote get-url origin)"
+
local -a lines
- ( builtin cd -q "$ZI[BIN_DIR]" && command git checkout $current_branch &>/dev/null && command git fetch --quiet && \
- lines=( ${(f)"$(command git log --color --abbrev-commit --date=short --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%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 $current_branch
- } else {
- command git pull --no-stat --quiet --ff-only origin $current_branch
- }
+ local nl=$'\n' escape=$'\x1b[' cores=$(nproc 2>/dev/null || \
+ sysctl -n hw.ncpu 2>/dev/null || command getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
+
+ (
+ # Fetch the latest changes from the upstream repository
+ (( quiet )) || +zi-message "{mmdsh}{happy} Zi{rst} » {profile}fetching updates{rst}{…}"
+ builtin cd -q $ZI[BIN_DIR] && command git fetch $opt --jobs $cores --tags --prune --force $origin_url refs/heads/main && \
+ lines=( ${(f)"$(command git log --color --abbrev-commit --decorate --date=short --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' ..FETCH_HEAD)"} )
+
+ # If there are any changes then update the codebase and reload Zi
+ if (( ${#lines} > 0 )); then
+ lines=( "${(S)lines[@]//\(([,[:blank:]]#(origin|HEAD|master|main)[^a-zA-Z]##(HEAD|origin|master|main)[,[:blank:]]#)#\)/}" )
+ lines=( "${lines[@]/ \|\|[[:blank:]]#(#e)/}" )
+ lines=( "${lines[@]/(#b)[[:space:]]#\|\|[[:space:]]#(*)(#e)/|| ${match[1]}}" )
+ lines=( "${lines[@]/(#b)$escape([0-9]##)m[[:space:]]##${escape}m/$escape${match[1]}m${escape}m}" )
+ lines=( "${lines[@]/(#b)[[:blank:]]#\|\|(*)(#e)/| ${${match[1]//$nl/ }[(w)1,(w)10]}}" )
+ (( quiet )) || { builtin print -rl -- "${lines[@]}" | .zi-pager; }
+
+ if (( ! dry_run )); then
+ # Update the codebase
+ command git merge -n $opt --autostash --ff-only FETCH_HEAD || \
+ { (( quiet )) || +zi-message "{mmdsh}{happy} Zi{rst} » {profile}update failed {quos}✘{rst}"; return 1 }
+ .zi-auto-reload $opt
+ fi
+ else
+ (( quiet )) || +zi-message "{mmdsh}{happy} Zi{rst} » {profile}up-to-date {term}✔{rst}"
+ fi
)
- if [[ $1 != -q ]] {
- +zi-message "{profile}Compiling »»»{rst} ❮ {happy}Zi{rst} ❯ {…}{rst}"
- }
- 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 "{profile}Reloading »»»{rst} ❮ {happy}Zi{rst} ❯ {…}{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
- # Read and remember the new modification timestamps
- local file
- .zi-get-mtime-into "${ZI[BIN_DIR]}/zi.zsh" "ZI[mtime]"
- 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).
@@ -709,7 +750,7 @@ ZI[EXTENDED_GLOB]=""
# 0. Call the Zsh Plugin's Standard *_plugin_unload function
# 0. Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update
# 1. Delete bindkeys (...)
-# 2. Delete Zstyles
+# 2. Delete zstyles
# 3. Restore options
# 4. Remove aliases
# 5. Restore Zle state
@@ -1199,7 +1240,7 @@ ZI[EXTENDED_GLOB]=""
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:#(%|/)*}:+/}"\
+ "${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"
@@ -1418,7 +1459,7 @@ ZI[EXTENDED_GLOB]=""
# Effectively return the last != 0 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]}"
+ +zi-message "{warn}Warning{ehi}:{rst} {b}{var}${arr[5]}{rst}{msg} hook returned {b}{num}$hook_rc{rst}"
}
done
if (( ZI[annex-multi-flag:pull-active] >= 2 )) {
@@ -1432,73 +1473,75 @@ ZI[EXTENDED_GLOB]=""
ICE=()
}
}
- if [[ -d $local_dir/.git ]] && ( builtin cd -q $local_dir ; git show-ref --verify --quiet refs/heads/main ); then
+ if [[ -d $local_dir/.git ]] && ( builtin cd -q $local_dir ; command git show-ref --verify --quiet refs/heads/main ); then
local main_branch=main
- else
+ elif [[ -d $local_dir/.git ]] && ( builtin cd -q $local_dir ; command git show-ref --verify --quiet refs/heads/master ); then
local main_branch=master
+ else
+ local main_branch=$(builtin cd -q $local_dir ; command git rev-parse --abbrev-ref HEAD 2>/dev/null)
fi
if (( ! is_release )) {
( builtin cd -q "$local_dir" || return 1
- integer had_output=0
- local IFS=$'\n'
- command git fetch --quiet && \
- declare -a line; line=( ${(f)"$(command git log --color --abbrev-commit --date=short --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' ..FETCH_HEAD)"} )
- if (( ${#line} > 0 )); then
- [[ $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
- } || +zi-message "{nl}Updating{ehi}:{rst} $REPLY{rst}"
- }
- }
- +zi-message "$line"
- fi | 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
- } || +zi-message "{nl}Updating{ehi}:{rst} $REPLY{rst}"
+ integer had_output=0
+ local IFS=$'\n'
+ local cores=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || command getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
+ command git fetch --quiet --jobs $cores && \
+ local -a line; line=( ${(f)"$(command git log --color --abbrev-commit --date=short --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cd) %C(bold blue)<%an>%Creset' ..FETCH_HEAD)"} )
+ if (( ${#line} > 0 )); then
+ [[ $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
+ } || +zi-message "{nl}Updating{ehi}:{rst} $REPLY{rst}"
+ }
}
- } else {
- ZI[annex-multi-flag:pull-active]=0
+ +zi-message "$line" | 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
+ fi
+ if [[ ${#log} -gt 0 ]]; then
+ ZI[annex-multi-flag:pull-active]=2
+ else
+ if (( ${+ice[run-atpull]} || OPTS[opt_-u,--urge] )); then
+ ZI[annex-multi-flag:pull-active]=1
+ # Handle the snippet/plugin boundary in the messages
+ if (( OPTS[opt_-q,--quiet] && !PUPDATE )); then
+ .zi-any-colorify-as-uspl2 "$id_as"
+ (( ZI[first-plugin-mark] )) && \
+ { ZI[first-plugin-mark]=0; } || +zi-message "{nl}Updating{ehi}:{rst} $REPLY{rst}"
+ fi
+ else
+ ZI[annex-multi-flag:pull-active]=0
+ fi
+ fi
+ 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=$?
+ # Effectively return the last != 0 rc
+ [[ "$hook_rc" -ne 0 ]] && {
+ retval="$hook_rc"
+ +zi-message "{warn}Warning{ehi}:{rst} {b}{var}${arr[5]}{rst}{msg} hook returned {b}{num}$hook_rc{rst}"
+ }
+ done
+ ICE=()
+ (( ZI[annex-multi-flag:pull-active] >= 2 )) && command git pull -n ${=ice[pullopts]:---ff-only} origin ${ice[ver]:-$main_branch} |& command grep -E -v '(FETCH_HEAD|up.to.date\.|From.*://)'
}
- }
- 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=$?
- # Effectively return the last != 0 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 grep -E -v '(FETCH_HEAD|up.to.date\.|From.*://)'
- }
return ${ZI[annex-multi-flag:pull-active]}
)
ZI[annex-multi-flag:pull-active]=$?
@@ -1538,7 +1581,7 @@ ZI[EXTENDED_GLOB]=""
# Effectively return the last != 0 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]}"
+ +zi-message "{warn}Warning{ehi}:{rst} {b}{var}${arr[5]}{rst}{msg} hook returned {b}{num}$hook_rc{rst}"
}
done
# Run annexes' atpull hooks (the after atpull-ice ones).
@@ -1555,7 +1598,7 @@ ZI[EXTENDED_GLOB]=""
# Effectively return the last != 0 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]}"
+ +zi-message "{warn}Warning{ehi}:{rst} {b}{var}${arr[5]}{rst}{msg} hook returned {b}{num}$hook_rc{rst}"
}
done
ICE=()
@@ -1578,7 +1621,7 @@ ZI[EXTENDED_GLOB]=""
# Effectively return the last != 0 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]}"
+ +zi-message "{warn}Warning{ehi}:{rst} {b}{var}${arr[5]}{rst}{msg} hook returned {b}{num}$hook_rc{rst}"
}
done
ICE=()
@@ -1644,49 +1687,22 @@ ZI[EXTENDED_GLOB]=""
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
builtin 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 ela elb update_rc
- .zi-get-mtime-into "${ZI[BIN_DIR]}/zi.zsh" ela; (( sum += ela ))
- for file ( side install autoload ) {
- .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/${file}.zsh" elb; (( sum += elb ))
- }
- # Reload ZI?
- if [[ $2 != restart ]] && (( ZI[mtime] + ZI[mtime-side] + ZI[mtime-install] + ZI[mtime-autoload] != sum )) {
- +zi-message "{info2}Detected {rst}❮ {happy}Zi{rst} ❯ {info2}update in another session -" "{pre}reloading {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
- .zi-get-mtime-into "${ZI[BIN_DIR]}/zi.zsh" "ZI[mtime]"
- for file ( side install autoload ) {
- .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/${file}.zsh" "ZI[mtime-${file}]"
- }
- +zi-message "{pname}Done.{rst}"$'\n'
- .zi-update-or-status-all "$1" restart
- return $?
- }
integer retval
if (( OPTS[opt_-p,--parallel] )) && [[ $1 = update ]] {
- (( !OPTS[opt_-q,--quiet] )) && \
- +zi-message '{info}Initiating parallel update {rst}{…}'
- .zi-update-all-parallel
- retval=$?
- .zi-compinit 1 1 &>/dev/null
- rehash
- if (( !OPTS[opt_-q,--quiet] )) {
- +zi-message "{info}The update took {num}${SECONDS}{info} seconds{rst}"
- }
+ (( OPTS[opt_-q,--quiet] )) || +zi-message "{mmdsh}{happy} Zi{rst} » {profile}parallelizing update{rst}{…}"
+ .zi-update-all-parallel; retval=$?
+ .zi-compinit 1 1 &>/dev/null; rehash
+ (( OPTS[opt_-q,--quiet] )) || \
+ +zi-message "{mmdsh}{happy} Zi{rst} » {info3}update took {num}$SECONDS{info3} seconds{rst}{…}"
return $retval
}
- local st=$1 id_as repo snip pd user plugin
- integer PUPDATE=0
+ 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|._zinit|._zplugin)(ND) )
- [[ $st != status && ${OPTS[opt_-q,--quiet]} != 1 && -n $snipps ]] && +zi-message "{note}Note:{rst} update includes unloaded snippets"
+ [[ $st != status && ${OPTS[opt_-q,--quiet]} != 1 && -n $snipps ]] && \
+ +zi-message "{mmdsh}{happy} Zi{rst} » {faint}updating snippets{rst}{…}"
for snip ( ${ZI[SNIPPETS_DIR]}/**/(._zi|._zinit|._zplugin)/mode(D) ) {
[[ ! -f ${snip:h}/url ]] && continue
[[ -f ${snip:h}/id-as ]] && id_as="$(<${snip:h}/id-as)" || id_as=
@@ -1696,13 +1712,11 @@ ZI[EXTENDED_GLOB]=""
[[ -n $snipps ]] && builtin print
}
ICE=()
- if (( OPTS[opt_-s,--snippets] && !OPTS[opt_-l,--plugins] )) {
- return
- }
+ if (( OPTS[opt_-s,--snippets] && !OPTS[opt_-l,--plugins] )) { return; }
if [[ $st = status ]]; then
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{note}Note:{rst} status includes unloaded plugins"
+ (( OPTS[opt_-q,--quiet] )) || +zi-message "{mmdsh}{happy} Zi{rst} » {faint}status for all installed plugins{rst}{…}"
else
- (( !OPTS[opt_-q,--quiet] )) && +zi-message "{note}Note:{rst} update includes unloaded plugins"
+ (( OPTS[opt_-q,--quiet] )) || +zi-message "{mmdsh}{happy} Zi{rst} » {faint}updating plugins{rst}{…}{nl}"
fi
ZI[first-plugin-mark]=init
for repo in ${ZI[PLUGINS_DIR]}/*; do
@@ -1726,27 +1740,25 @@ ZI[EXTENDED_GLOB]=""
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] )) && \
- +zi-message "$REPLY: not a git repository"
+ (( OPTS[opt_-q,--quiet] )) || +zi-message "$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] )) && +zi-message "Updating{ehi}:{rst} $REPLY{rst}" || builtin print -n .
+ (( OPTS[opt_-q,--quiet] )) || +zi-message "Updating{ehi}:{rst} $REPLY{rst}" || builtin print -n .
.zi-update-or-status update "$user" "$plugin"
- update_rc=$?
+ local update_rc=$?
[[ $update_rc -ne 0 ]] && {
- +zi-message "{warn}Warning: {pid}${user}/${plugin} {warn}update returned{ehi}:{rst} {num}${update_rc}"
+ +zi-message "{warn}Warning{ehi}:{rst} {pid}${user}/${plugin} {warn}update returned{ehi}:{rst} {num}$update_rc{rst}"
retval=$?
}
fi
done
- .zi-compinit 1 1 &>/dev/null
- if (( !OPTS[opt_-q,--quiet] )) {
- +zi-message "{ok}The update took {num}${SECONDS}{ok} seconds{rst}"
- }
+ .zi-compinit 1 1 &>/dev/null; rehash
+ (( OPTS[opt_-q,--quiet] )) || \
+ +zi-message "{mmdsh}{happy} Zi{rst} » {info3}update took {num}$SECONDS{info3} seconds{rst}{…}"
return "$retval"
} # ]]]
# FUNCTION: .zi-update-in-parallel [[[
@@ -1840,7 +1852,7 @@ ZI[EXTENDED_GLOB]=""
counter=0
PUAssocArray=()
} elif (( counter == 1 && !OPTS[opt_-q,--quiet] )) {
- +zi-message "{info3}Spawning the next{opt} ${OPTS[value]}{info3} concurrent update jobs{ehi}:{rst} {var}${tpe}{rst} {…}"
+ +zi-message "{info3}Spawning {opt}${OPTS[value]}{info3} concurrent {var}${tpe}{info3} updates{rst}{…}"
}
} # ]]]
# FUNCTION: .zi-show-zstatus [[[
@@ -1908,21 +1920,22 @@ ZI[EXTENDED_GLOB]=""
[[ -z $sni ]] && builtin print -n " "
builtin print '\b\b '
} # ]]]
-# FUNCTION: .zi-show-times [[[
+# FUNCTION: .zi-times [[[
# Shows loading times of all loaded plugins.
#
# User-action entry point.
-.zi-show-times() {
- builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
- builtin setopt extendedglob warncreateglobal noshortloops
+.zi-times() {
+builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
+builtin setopt extended_glob warn_create_global typeset_silent \
+ no_short_loops rc_quotes no_auto_pushd no_bang_hist
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:"
+ { +zi-message "{info2}Plugin loading moments (relative to the first prompt){ehi}:{rst}"; ((1)); } || \
+ +zi-message "{info2}Plugin loading times{ehi}:{rst}"
for entry in "${(@on)ZI[(I)TIME_[0-9]##_*]}"; do
entry2="${entry#TIME_[0-9]##_}"
entry3="AT_$entry"
@@ -1941,8 +1954,8 @@ ZI[EXTENDED_GLOB]=""
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"
+ local time="$ZI[$entry] s"
+ attime="${(M)attime#*.???} s"
else
local time="${(l:5:: :)$(( ZI[$entry] * 1000 ))%%[,.]*} ms"
attime="${(l:5:: :)$(( attime * 1000 ))%%[,.]*} ms"
@@ -1954,20 +1967,20 @@ ZI[EXTENDED_GLOB]=""
elif [[ "$opt" = *-[a-z]#a[a-z]#* ]]; then
line="$attime $line"
fi
- line="$line - $REPLY"
+ line="$line {mdsh} $REPLY {rst}"
if [[ ${sice[as]} == "command" ]]; then
- line="$line (command)"
- elif [[ -n ${sice[sbin]+abc} ]]; then
- line="$line (sbin command)"
- elif [[ -n ${sice[fbin]+abc} ]]; then
- line="$line (fbin command)"
+ line="$line {mdsh} {faint} ({cmd}command{rst}{faint}){rst}"
+ elif [[ -n ${sice[sbin]+abc} || -n ${sice[sbin]} ]]; then
+ line="$line {mdsh} {faint} ({ice}sbin{rst} {cmd}command{rst}{faint}){rst}"
+ elif [[ -n ${sice[fbin]+abc} || -n ${sice[fbin]} ]]; then
+ line="$line {mdsh} {faint} ({ice}fbin{rst} {cmd}command{rst}{faint}){rst}"
elif [[ ( ${sice[pick]} = /dev/null || ${sice[as]} = null ) && ${+sice[make]} = 1 ]]; then
- line="$line (/dev/null make plugin)"
+ line="$line {mdsh} {faint} ({dir}/dev/null{rst} {cmd}make{rst} {p}plugin{rst}{faint}){rst}"
fi
- builtin print "$line"
+ +zi-message "$line"
(( sum += ZI[$entry] ))
done
- builtin print "Total: $sum sec"
+ +zi-message "{mmdsh}{rst} {b}Total{ehi}:{rst} {auto}${sum}s"
} # ]]]
# FUNCTION: .zi-list-bindkeys [[[
.zi-list-bindkeys() {
@@ -2546,10 +2559,9 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
if (( OPTS[opt_-y,--yes] )); then
integer retval
eval "$2"; retval=$?
- (( OPTS[opt_-q,--quiet] )) || builtin print "\nDone (action executed, exit code: $retval)"
+ (( OPTS[opt_-q,--quiet] )) || +zi-message "{nl}Done! (exit code{ehi}:{rst} {num}$retval{rst})"
else
- builtin print -Pr -- "$1"
- builtin print "[yY/n…]"
+ builtin print -Pr -- "$1 - [y/N]?"
local ans
if [[ -t 0 ]] {
read -q ans
@@ -2558,9 +2570,9 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
}
if [[ "$ans" = "y" ]] {
eval "$2"
- builtin print "\nDone (action executed, exit code: $?)"
+ +zi-message "{nl}Done! (exit code{ehi}:{rst} {num}$?{rst})"
} else {
- builtin print "\nBreak, no action"
+ +zi-message "{nl}Break, no action…"
return 1
}
fi
@@ -2603,7 +2615,7 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\""
[[ $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`
+ 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"
@@ -2868,9 +2880,9 @@ EOF
elif (( ${+commands[eza]} )); then
ZI[TREE]="${commands[eza]} --color=always -T -l -L3"
else
- 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'"
+ +zi-message "{auto}Program \`tree\` not found, it is required by the subcommand \`ls\`"
+ +zi-message "Download from{ehi}:{rst} {auto}http://mama.indstate.edu/users/ice/tree/"
+ +zi-message "{auto}It is also available probably in all distributions and Homebrew, as package \`tree\`."
fi
(
builtin cd -q "${ZI[SNIPPETS_DIR]}"
@@ -2942,87 +2954,93 @@ EOF
} || builtin print -r -- "No such plugin or snippet"
} # ]]]
# FUNCTION: .zi-module [[[
-# Function that has sub-commands passed as long-options (with two dashes, --).
-# 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.
+# Builds a module from its git repository and displays information how to load the module in .zshrc,
+# performs checks, verify hard stored values, and rebuilds the module if requested.
.zi-module() {
- if [[ "$1" = "build" ]]; then
+ if [[ "$1" = (-r|--reset) ]]; then
+ [[ -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} ]]; then
+ +zi-message "{warn}Warning{warn}{ehi}:{rst} {lhi}recompilation{rst} of the {bcmd}zpmod{rst} module has been requested…"
+ (( ${+functions[.zi-confirm]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ .zi-confirm "Do you want to proceed?" || return 1
+ command make -C "${ZI[ZMODULES_DIR]}/zpmod" distclean &>/dev/null
+ .zi-module --build
+ fi
+ elif [[ "$1" = (-B|--build|build) ]]; then
builtin autoload -Uz is-at-least
if is-at-least 5.8.1; then
- .zi-build-module "${@[2,-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 -x
+ command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" reset --hard HEAD >/dev/null
+ command git -C "${${ZI[ZMODULES_DIR]}}/zpmod" pull --rebase --progress || {
+ +zi-message "{error}-- Failed to update module repository --{rst}"; return 1
+ }
+ if [[ "$2" = "--clean" ]]; then
+ +zi-message "{p}-- Module {ok}source is clean{p}, {cmd}make distclean{p} not required --{rst}"
+ fi
+ else
+ if ! test -d "${${ZI[ZMODULES_DIR]}}/zpmod"; then
+ command mkdir -p "${${ZI[ZMODULES_DIR]}}/zpmod"; command chmod g-rwX "${${ZI[ZMODULES_DIR]}}/zpmod"
+ fi
+ command git clone --verbose --progress "https://github.com/z-shell/zpmod.git" "${${ZI[ZMODULES_DIR]}}/zpmod" \
+ |& { command ${ZI[BIN_DIR]}/lib/zsh/git-process-output.zsh || cat; } || {
+ +zi-message "{error}-- Failed to clone module repository --{rst}"; return 1
+ }
+ fi
+ ( builtin cd -q "${ZI[ZMODULES_DIR]}/zpmod"
+ +zi-message "{p}-- The module sources are located at{ehi}:{rst} {dir}"${ZI[ZMODULES_DIR]}/zpmod"{p} --{rst}"
+ if [[ -f Makefile ]]; then
+ if [[ "$2" = "--clean" ]]; then
+ +zi-message "{p}-- Building module {bcmd}zi/zpmod{p}, running: {cmd}make distclean{p}, then {cmd}./configure{p} and then {cmd}make{p} --{rst}"
+ +zi-message "{p}-- make distclean --{rst}"
+ command make distclean
+ ((1))
+ else
+ +zi-message "{p}-- Building module {bcmd}zi/zpmod{p}, running: {cmd}make clean{p}, then {cmd}./configure{p} and then {cmd}make{p} --{rst}"
+ +zi-message "{p}-- make clean --{rst}"
+ command make clean
+ fi
+ fi
+ +zi-message "{p}-- ./configure --{rst}"
+ ./configure --enable-cflags='-g -Wall -Wextra -O3' --disable-gdbm --without-tcsetpgrp --quiet
+ +zi-message "{p}-- make --{rst}"
+ local cores=$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || command getconf _NPROCESSORS_ONLN 2>/dev/null || echo 1)
+ local build_log="${ZI[LOG_DIR]}/zpmod/${EPOCHSECONDS}-build.log"
+ command mkdir -p "${ZI[LOG_DIR]}/zpmod" 2>/dev/null
+ command make --jobs=$cores -C "${ZI[ZMODULES_DIR]}/zpmod" | command tee "$build_log" >/dev/null
+ if command make -C "${ZI[ZMODULES_DIR]}/zpmod" &>/dev/null; then
+ [[ -f Src/zi/zpmod.so ]] && command cp -vf Src/zi/zpmod.{so,bundle}
+ builtin print "$EPOCHSECONDS" >! "${ZI[ZMODULES_DIR]}/zpmod/COMPILED_AT"
+ +zi-message "{ok}-- Build successful! --{rst}"
+ +zi-message "{faint}-- Build log{ehi}:{rst} {file}$build_log{faint} --{rst}"
+ .zi-module --info
+ return 0
+ else
+ +zi-message "{error}Build failed{rst}…" \
+ "To report an issue at GitHub, please provide error messages from{ehi}:{rst}{nl}" \
+ "{ndsh} Build log{rst} {dir}${build_log}{rst} if exists{nl}" \
+ "{ndsh} Run '{cmd}make -C ${ZI[ZMODULES_DIR]}/zpmod{rst}' to reproduce{rst}{nl}" \
+ "{ndsh}{rst} {var}URL{rst} to submit{rst} {url}https://github.com/z-shell/zpmod/issues{rst}"
+ return 1
+ fi
+ )
else
+zi-message "{warn}Zsh version{rst} {obj}5.8.1{warn} or higher required{rst}"
return 1
fi
- elif [[ "$1" = "info" ]]; then
- if [[ "$2" = "--link" ]]; then
- +zi-message "Please submit any issues at the address below{ehi}:{rst} " \
- "{nl}{mmdsh}{url} https://github.com/z-shell/zpmod/issues{rst}"
- else
- +zi-message "To load the module, add following 2 lines to .zshrc, at top:{nl}" \
- "{nl}" \
- "{p} module_path+=( \"${ZI[ZMODULES_DIR]}/zpmod/Src\" ){rst}{nl}" \
- "{p} zmodload zi/zpmod{rst}{nl}" \
- "{nl}" \
- "After loading, use command \`zpmod' to communicate with the module.{nl}" \
- "{info2}See \`zpmod -h' for more information.{rst}"
- fi
- elif [[ "$1" = (help|usage) ]]; then
- +zi-message "{info2}Usage{rst}{obj}:{rst}{nl}" \
- "{p}zi module{rst} {info}{build|info|help}{rst} {p}[options]{rst}{nl}" \
- "{p}zi module{rst} {info}build{rst} {p}[--clean]{rst}{nl}" \
- "{p}zi module{rst} {info}info{rst} {p}[--link]{rst}{nl}" \
+ elif [[ "$1" = (-I|--info|info) ]]; then
+ +zi-message "{nl}To load the module, add following {info}2 lines{rst} at the top of {file}.zshrc{ehi}:{nl}" \
"{nl}" \
- "To start using the zpmod module run{rst}{obj}:{rst}{nl}" \
- "{p}zi module{rst} {info}build{rst}{nl}" \
- "Append {p}--clean{rst} to run {cmd}make distclean{rst}{nl}" \
- "To display the instructions on loading the module, run{rst}{obj}:{rst}{nl}" \
- "{p}zi module info{rst}."
- fi
-} # ]]]
-# FUNCTION: .zi-build-module [[[
-# 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 --progress "https://github.com/z-shell/zpmod.git" "${${ZI[ZMODULES_DIR]}}/zpmod" || {
- +zi-message "{error}Failed to clone module repository{rst}"
- return 1
- }
+ "{b}{p} module_path+=( \"${ZI[ZMODULES_DIR]}/zpmod/Src\" ){rst}{nl}" \
+ "{b}{p} zmodload zi/zpmod{rst}{nl}" \
+ "{nl}Reload shell and use command{ehi}:{rst}" \
+ "{nl}{mmdsh}{cmd} zpmod{opt} -h{rst} for more information.{rst}{nl}" \
+ "{nl}Please submit any issues at the address below{ehi}:{rst}" \
+ "{nl}{mmdsh}{url} https://github.com/z-shell/zpmod/issues{rst}"
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 ]]; then
- if [[ "$1" = "--clean" ]]; then
- noglob +zi-message {p}-- make distclean --{rst}
- make distclean
- ((1))
- else
- noglob +zi-message {p}-- make clean --{rst}
- make clean
- fi
- fi
- 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 command make -s; then
- [[ -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
- fi
- builtin print $EPOCHSECONDS >! "${ZI[ZMODULES_DIR]}/zpmod/COMPILED_AT"
- )
} # ]]]
# FUNCTION: .zi-help [[[
# Shows usage information.
@@ -3031,35 +3049,35 @@ EOF
.zi-help() {
# +zi-message "{hi}Welcome ${(%):-%n}"
if (( $+commands[clear] )) { clear; }
-sleep 0.03 && +zi-message "{mmdsh}{rst} ❮ {happy}Zi{rst} ❯ {mmdsh}{info} Usage{ehi}:{rst}"
-sleep 0.03 && +zi-message "❯ analytics {mdsh}{rst} {auto}Statistics, benchmarks, and information"
-sleep 0.03 && +zi-message "❯ subcmds {mdsh}{rst} {auto}Show subcommands registered by the annexes"
-sleep 0.03 && +zi-message "❯ icemods {mdsh}{rst} {auto}Show all registered ice-modifiers"
-sleep 0.03 && +zi-message "❯ self-update {mdsh}{rst} {auto}Self-update and compile"
-sleep 0.04 && +zi-message "❯ compinit {mdsh}{rst} {auto}Refresh completions"
-sleep 0.04 && +zi-message "❯ cclear {mdsh}{rst} {auto}Clear stray and improper completions"
-sleep 0.04 && +zi-message "❯ cdreplay {opt}[-q]{rst} {mdsh}{rst} {auto}Replay compdefs (run after compinit)"
-sleep 0.04 && +zi-message "❯ cdclear {opt}[-q]{rst} {mdsh}{rst} {auto}Clear compdef replay list"
-sleep 0.04 && +zi-message "❯ env-whitelist {opt}[-v][-h]{rst} {mdsh}{rst} {auto}Specify names or patterns of variables left unchanged during an{rst} unload"
-sleep 0.05 && +zi-message "❯ snippet {opt}[-f]{p} [snippet]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Source local or remote file"
-sleep 0.05 && +zi-message "❯ delete {opt}[--all][--clean]{p} [plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Remove 'plugin/snippet' from the disk"
-sleep 0.05 && +zi-message "❯ update {opt}[-L][-s][-v][-q][-r][-p]{p} [plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Git update plugins or snippets"
-sleep 0.05 && +zi-message "❯ load {opt}[-b]{p} [plugin]{rst} {mdsh}{rst} {auto}Load plugin or absolute local path"
-sleep 0.06 && +zi-message "❯ unload {opt}[-q]{p} [plugin]{rst} {mdsh}{rst} {auto}Unload plugin"
-sleep 0.06 && +zi-message "❯ light {opt}[-b]{p} [plugin]{rst} {mdsh}{rst} {auto}Load plugins without 'reporting/tracking'"
-sleep 0.06 && +zi-message "❯ add-fpath {opt}[-f]{p} [plugin]{rst}|{dir}[dir]{rst} {mdsh}{rst} {auto}Append directory to{var} \$fpath{rst}, use -f to prepend instead"
-sleep 0.06 && +zi-message "❯ run {opt}[-l]{p} [plugin]{rst}|{cmd}[cmd]{rst} {mdsh}{rst} {auto}Runs a command in the given plugin's directory"
-sleep 0.07 && +zi-message "❯ compile {opt}[--all]{p} [plugin]{rst} {mdsh}{rst} Compile plugins"
-sleep 0.07 && +zi-message "❯ uncompile {opt}[--all]{p} [plugin]{rst} {mdsh}{rst} Remove compiled plugins"
-sleep 0.07 && +zi-message "❯ cdisable {p}[name]{rst} {mdsh}{rst} {auto}Disable completion"
-sleep 0.07 && +zi-message "❯ cenable {p}[name]{rst} {mdsh}{rst} {auto}Enable completion"
-sleep 0.08 && +zi-message "❯ creinstall {p}[plugin]{rst} {mdsh}{rst} {auto}Install completions for the plugin, can also receive absolute local path"
-sleep 0.08 && +zi-message "❯ cuninstall {p}[plugin]{rst} {mdsh}{rst} {auto}Uninstall completions for plugin"
-sleep 0.08 && +zi-message "❯ recall {p}[plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Fetch saved ice-modifiers and construct the command"
-sleep 0.08 && +zi-message "❯ srv {p}[service]{rst}|{cmd}[cmd]{rst} {mdsh}{rst} Control a service{ehi}:{rst} {auto}'stop,start,restart,next,quit'"
-sleep 0.09 && +zi-message "❯ create {p}[plugin]{rst} {mdsh}{rst} {auto}Create a plugin"
-sleep 0.09 && +zi-message "❯ edit {p}[plugin]{rst} {mdsh}{rst} Edit plugin's file with{var} \$EDITOR{rst}{nl}"
-sleep 0.09 && +zi-message "{mmdsh}{rst} ❮ {happy}Zi{rst} ❯ {mmdsh}{info} Wiki{ehi}:{rst} {url}https://wiki.zshell.dev{rst}{nl}"
+sleep 0.01 && +zi-message "{mmdsh}{rst} ❮ {happy}Zi{rst} ❯ {mmdsh}{info} Usage{ehi}:{rst}{nl}"
+sleep 0.01 && +zi-message "❯ analytics {mdsh}{rst} {auto}Statistics, benchmarks, and information"
+sleep 0.01 && +zi-message "❯ subcmds {mdsh}{rst} {auto}Show subcommands registered by the annexes"
+sleep 0.01 && +zi-message "❯ icemods {mdsh}{rst} {auto}Show all registered ice-modifiers"
+sleep 0.01 && +zi-message "❯ compinit {mdsh}{rst} {auto}Refresh completions"
+sleep 0.01 && +zi-message "❯ cclear {mdsh}{rst} {auto}Clear stray and improper completions"
+sleep 0.02 && +zi-message "❯ cdreplay {opt}[-q]{rst} {mdsh}{rst} {auto}Replay compdefs (run after compinit)"
+sleep 0.02 && +zi-message "❯ cdclear {opt}[-q]{rst} {mdsh}{rst} {auto}Clear compdef replay list"
+sleep 0.01 && +zi-message "❯ self-update {opt}[-q][-D]{rst} {mdsh}{rst} {auto}Self-update and compile codebase"
+sleep 0.02 && +zi-message "❯ env-whitelist {opt}[-v][-h]{rst} {mdsh}{rst} {auto}Specify names or patterns of variables left unchanged during an{rst} unload"
+sleep 0.02 && +zi-message "❯ snippet {opt}[-f]{p} [snippet]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Source local or remote file"
+sleep 0.02 && +zi-message "❯ delete {opt}[-a][-c][-y][-q]{p} [plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Remove 'plugin' or 'snippet' from the disk"
+sleep 0.02 && +zi-message "❯ update {opt}[-L][-s][-v][-q][-r][-p]{p} [plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Git update plugins or snippets"
+sleep 0.02 && +zi-message "❯ load {opt}[-b]{p} [plugin]{rst} {mdsh}{rst} {auto}Load plugin or absolute local path"
+sleep 0.02 && +zi-message "❯ unload {opt}[-q]{p} [plugin]{rst} {mdsh}{rst} {auto}Unload plugin"
+sleep 0.02 && +zi-message "❯ light {opt}[-b]{p} [plugin]{rst} {mdsh}{rst} {auto}Load plugins without 'reporting' or 'tracking'"
+sleep 0.02 && +zi-message "❯ add-fpath {opt}[-f]{p} [plugin]{rst}|{dir}[dir]{rst} {mdsh}{rst} {auto}Append directory to{var} \$fpath{rst}, use {opt}-f{rst} {auto} to prepend instead"
+sleep 0.02 && +zi-message "❯ run {opt}[-l]{p} [plugin]{rst}|{cmd}[cmd]{rst} {mdsh}{rst} {auto}Runs a command in the given plugin's directory"
+sleep 0.02 && +zi-message "❯ compile {opt}[-a]{p} [plugin]{rst} {mdsh}{rst} Compile plugins"
+sleep 0.02 && +zi-message "❯ uncompile {opt}[-a]{p} [plugin]{rst} {mdsh}{rst} Remove compiled plugins"
+sleep 0.02 && +zi-message "❯ cdisable {p}[name]{rst} {mdsh}{rst} {auto}Disable completion"
+sleep 0.03 && +zi-message "❯ cenable {p}[name]{rst} {mdsh}{rst} {auto}Enable completion"
+sleep 0.03 && +zi-message "❯ creinstall {p}[plugin]{rst} {mdsh}{rst} {auto}Install completions for the plugin, can also receive absolute local path"
+sleep 0.03 && +zi-message "❯ cuninstall {p}[plugin]{rst} {mdsh}{rst} {auto}Uninstall completions for plugin"
+sleep 0.03 && +zi-message "❯ recall {p}[plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Fetch saved ice-modifiers and construct the command"
+sleep 0.03 && +zi-message "❯ srv {p}[service]{rst}|{cmd}[cmd]{rst} {mdsh}{rst} Control a service{ehi}:{rst} {auto}'stop,start,restart,next,quit'"
+sleep 0.03 && +zi-message "❯ create {p}[plugin]{rst} {mdsh}{rst} {auto}Create a plugin"
+sleep 0.03 && +zi-message "❯ edit {p}[plugin]{rst} {mdsh}{rst} Edit plugin's file with {var}\$EDITOR{rst}{nl}"
+sleep 0.04 && +zi-message "{mmdsh}{info} Wiki{ehi}:{rst} {url}https://wiki.zshell.dev{rst}{nl}"
} # ]]]
# FUNCTION: .zi-analytics-menu [[[
# Statistics, benchmarks and information.
@@ -3067,30 +3085,30 @@ sleep 0.09 && +zi-message "{mmdsh}{rst} ❮ {happy}Zi{rst} ❯ {mmdsh}{info} Wik
# User-action entry point.
.zi-analytics-menu() {
if (( $+commands[clear] )) { clear; }
-sleep 0.03 && +zi-message "{mmdsh}{rst} ❮ {happy}Zi{rst} ❯ {mmdsh}{info} Analytics{ehi}:{rst}"
-sleep 0.03 && +zi-message "❯ compiled {mdsh}{rst} {auto}List plugins that are compiled"
-sleep 0.03 && +zi-message "❯ zstatus {mdsh}{rst} {auto}Overall status"
-sleep 0.03 && +zi-message "❯ module help {mdsh}{rst} {auto}Manage zpmod"
-sleep 0.03 && +zi-message "❯ dtrace|dstart {mdsh}{rst} {auto}Start tracking what's going on in session"
-sleep 0.04 && +zi-message "❯ dstop {mdsh}{rst} {auto}Stop tracking what's going on in session"
-sleep 0.04 && +zi-message "❯ dreport {mdsh}{rst} {auto}Report what was going on in session"
-sleep 0.04 && +zi-message "❯ dunload {mdsh}{rst} {auto}Revert changes recorded between dstart and dstop"
-sleep 0.04 && +zi-message "❯ dclear {mdsh}{rst} {auto}Clear report of what was going on in session"
-sleep 0.05 && +zi-message "❯ bindkeys {mdsh}{rst} {auto}List bindkeys"
-sleep 0.05 && +zi-message "❯ clist|completions {mdsh}{rst} {auto}List completions in use"
-sleep 0.05 && +zi-message "❯ cdlist {mdsh}{rst} {auto}Show compdef replay list"
-sleep 0.05 && +zi-message "❯ csearch {mdsh}{rst} {auto}Search for available completions from any plugin"
-sleep 0.06 && +zi-message "❯ man {mdsh}{rst} {auto}Show manual"
-sleep 0.06 && +zi-message "❯ ls {mdsh}{rst} {auto}List snippets in formatted and colorized manner"
-sleep 0.06 && +zi-message "❯ status {opt}[--all]{p} [plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Git status for plugin or svn status for snippet"
-sleep 0.06 && +zi-message "❯ report {opt}[--all]{p} [plugin]{rst} {mdsh}{rst} {auto}Show reports"
-sleep 0.07 && +zi-message "❯ times {opt}[-s][-m][-a]{rst} {mdsh}{rst} {auto}Statistics on plugin load times, sorted in order of loading"
-sleep 0.07 && +zi-message "❯ glance {p}[plugin]{rst} {mdsh}{rst} {auto}Look at plugin's source"
-sleep 0.07 && +zi-message "❯ stress {p}[plugin]{rst} {mdsh}{rst} {auto}Test plugin for compatibility with set of options"
-sleep 0.07 && +zi-message "❯ changes {p}[plugin]{rst} {mdsh}{rst} {auto}View plugin's git log"
-sleep 0.08 && +zi-message "❯ recently {p}[time]{rst} {mdsh}{rst} {auto}Show plugins that changed recently (e.g.: 1 month 2 days)"
-sleep 0.08 && +zi-message "❯ cd {p}[plugin]{rst} {mdsh}{rst} {auto}Enter plugin's directory; also support snippets, if feed with URL"
-sleep 0.08 && +zi-message "❯ loaded|lists {p}[keyword]{rst} {mdsh}{rst} {auto}Show what plugins are loaded (filter: keyword)"
+sleep 0.02 && +zi-message "{mmdsh}{rst} ❮ {happy}Zi{rst} ❯ {mmdsh}{info} Analytics{ehi}:{rst}{nl}"
+sleep 0.02 && +zi-message "❯ compiled {mdsh}{rst} {auto}List plugins that are compiled"
+sleep 0.02 && +zi-message "❯ zstatus {mdsh}{rst} {auto}Overall status"
+sleep 0.02 && +zi-message "❯ dtrace|dstart {mdsh}{rst} {auto}Start tracking what's going on in session"
+sleep 0.02 && +zi-message "❯ dstop {mdsh}{rst} {auto}Stop tracking what's going on in session"
+sleep 0.02 && +zi-message "❯ dreport {mdsh}{rst} {auto}Report what was going on in session"
+sleep 0.02 && +zi-message "❯ dunload {mdsh}{rst} {auto}Revert changes recorded between dstart and dstop"
+sleep 0.02 && +zi-message "❯ dclear {mdsh}{rst} {auto}Clear report of what was going on in session"
+sleep 0.03 && +zi-message "❯ bindkeys {mdsh}{rst} {auto}List bindkeys"
+sleep 0.03 && +zi-message "❯ clist|completions {mdsh}{rst} {auto}List completions in use"
+sleep 0.03 && +zi-message "❯ cdlist {mdsh}{rst} {auto}Show compdef replay list"
+sleep 0.03 && +zi-message "❯ csearch {mdsh}{rst} {auto}Search for available completions from any plugin"
+sleep 0.03 && +zi-message "❯ man {mdsh}{rst} {auto}Show manual"
+sleep 0.03 && +zi-message "❯ ls {mdsh}{rst} {auto}List snippets in formatted and colorized manner"
+sleep 0.03 && +zi-message "❯ status {opt}[--all]{p} [plugin]{rst}|{url}[url]{rst} {mdsh}{rst} {auto}Git status for plugin or svn status for snippet"
+sleep 0.03 && +zi-message "❯ report {opt}[--all]{p} [plugin]{rst} {mdsh}{rst} {auto}Show reports"
+sleep 0.04 && +zi-message "❯ module {opt}[-B][-I][-r]{rst} {mdsh}{rst} {auto}Manage zpmod"
+sleep 0.04 && +zi-message "❯ times {opt}[-s][-m][-a]{rst} {mdsh}{rst} {auto}Statistics on plugin load times, sorted in order of loading"
+sleep 0.04 && +zi-message "❯ glance {p}[plugin]{rst} {mdsh}{rst} {auto}Look at plugin's source"
+sleep 0.04 && +zi-message "❯ stress {p}[plugin]{rst} {mdsh}{rst} {auto}Test plugin for compatibility with set of options"
+sleep 0.04 && +zi-message "❯ changes {p}[plugin]{rst} {mdsh}{rst} {auto}View plugin's git log"
+sleep 0.04 && +zi-message "❯ recently {p}[time]{rst} {mdsh}{rst} {auto}Show plugins that changed recently (e.g.: 1 month 2 days)"
+sleep 0.04 && +zi-message "❯ cd {p}[plugin]{rst} {mdsh}{rst} {auto}Enter plugin's directory; also support snippets, if feed with URL"
+sleep 0.04 && +zi-message "❯ loaded|lists {p}[keyword]{rst} {mdsh}{rst} {auto}Show what plugins are loaded (filter: keyword)"
} # ]]]
# FUNCTION: .zi-registered-subcommands [[[
# Shows subcommands registered by annex.
diff --git a/lib/zsh/git-process-output.zsh b/lib/zsh/git-process-output.zsh
index a0b9529..7222c0a 100755
--- a/lib/zsh/git-process-output.zsh
+++ b/lib/zsh/git-process-output.zsh
@@ -3,6 +3,9 @@
builtin emulate -LR zsh
builtin setopt extended_glob warn_create_global typeset_silent
+typeset -Ag ZI_USR
+[[ -z $ZI_USR[GP_COL] ]] && ZI_USR[GP_COL]=46
+
{ typeset -g COLS="$(tput cols)" } 2>/dev/null
if (( COLS < 10 )) {
COLS=40
@@ -41,7 +44,7 @@ local first=1
timeline() {
local sp='▚▞'; sp="${sp:$2%2:1}"
# Maximal width is 24 characters
- local bar="$(builtin print -f "%.$2s█%0$(($3-$2-1))s" "░▒▓█████████████████████" "")"
+ local bar="$(builtin print -f "%.$2s█%0$(($3-$2-1))s" "░▒▓████████████████████" "")"
local -a frames_splitted
frames_splitted=( ${(@zQ)progress_frames[progress_style]} )
if (( SECONDS - last_time >= frames_splitted[1] )) {
@@ -50,7 +53,7 @@ timeline() {
last_time=$SECONDS
}
builtin print -nr -- ${frames_splitted[cur_frame+1]}" "
- builtin print -nPr "%F{201}"
+ builtin print -nPr "%F{$ZI_USR[GP_COL]}"
builtin print -f "%s %s" "${bar// /░}" ""
builtin print -nPr "%f"
}
@@ -98,10 +101,10 @@ IFS=''
[[ $+ZI_CIVIS == 1 && -n $TERM ]] && eval $ZI_CIVIS
if [[ -n $TERM ]] {
+[[ $COLORTERM == (24bit|truecolor) || ${terminfo[colors]} -eq 16777216 ]] || \
+ zmodload zsh/nearcolor &>/dev/null
{ command perl -pe 'BEGIN { $|++; $/ = \1 }; tr/\r/\n/' || \
- gstdbuf -o0 gtr '\r' '\n' || \
- cat } |& \
-while read -r line; do
+ gstdbuf -o0 gtr '\r' '\n' || cat; } |& while read -r line; do
(( ++ loop_count ))
if [[ "$line" = "Cloning into"* ]]; then
builtin print $line
diff --git a/lib/zsh/install.zsh b/lib/zsh/install.zsh
index 8df2c07..104a416 100755
--- a/lib/zsh/install.zsh
+++ b/lib/zsh/install.zsh
@@ -325,7 +325,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
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
+ ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst ${TMPDIR:-/tmp}/zi.compiled.$$.lst
if [[ $tpe != tarball ]] {
if [[ -z $update ]] {
@@ -511,7 +511,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
# $3 - if 1, then reinstall, otherwise only install completions that aren't there
.zi-install-completions() {
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
- builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops
+ builtin setopt null_glob extended_glob warn_create_global typeset_silent no_short_loops
local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}}
local reinstall=${3:-0} quiet=${${4:+1}:-0}
@@ -549,6 +549,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
]]; then
if [[ $reinstall = 1 ]]; then
# Remove old files
+ command rm -f "${ZI[ZCOMPDUMP_PATH]}"
command rm -f "${ZI[COMPLETIONS_DIR]}/${cfile}" "${ZI[COMPLETIONS_DIR]}/${bkpfile}"
fi
INSTALLED_COMPS+=( $cfile )
@@ -577,43 +578,17 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
builtin print -rl -- $SKIPPED_COMPS >! ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst
}
- .zi-compinit 1 1 &>/dev/null
+ .zi-compinit 1 1 &>/dev/null; rehash
} # ]]]
# 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 ❯ completions.
-#
-# No arguments.
.zi-compinit() {
[[ -n ${OPTS[opt_-p,--parallel]} && $1 != 1 ]] && return
builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
- builtin setopt nullglob extendedglob warncreateglobal typesetsilent
+ builtin setopt null_glob extended_glob warn_create_global typeset_silent
integer use_C=$2
- typeset -a symlinked backup_comps
- local c cfile bkpfile action
-
- 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#_}"
-
- #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]}"
-
- # Workaround for a nasty trick in _vim
- (( ${+functions[_vim_files]} )) && unfunction _vim_files
+ +zi-message "{mmdsh}{happy} Zi{rst} » {faint}initializing {func}compinit{rst}{…}"
builtin autoload -Uz compinit
compinit ${${(M)use_C:#1}:+-C} -d "${ZI[ZCOMPDUMP_PATH]}" "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
@@ -773,6 +748,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col
(( quiet || first )) || builtin print
unfunction -- 2>/dev/null "$f"
+ .zi-compinit 1 1 &>/dev/null; rehash
} # ]]]
# FUNCTION: .zi-compile-plugin [[[
# Compiles given plugin (its main source file, and also an additional "....zsh" file if it exists).
@@ -1790,9 +1766,6 @@ ziextract() {
)
}
# ]]]
-# FUNCTION: zpextract [[[
-zpextract() { ziextract "$@"; }
-# ]]]
# FUNCTION: .zi-at-eval [[[
.zi-at-eval() {
local atpull="$1" atclone="$2"
diff --git a/lib/zsh/rpm2cpio.zsh b/lib/zsh/rpm2cpio.zsh
index 2ea7858..26d12d5 100755
--- a/lib/zsh/rpm2cpio.zsh
+++ b/lib/zsh/rpm2cpio.zsh
@@ -15,7 +15,7 @@ set -- ${(s: :)$(od -j $o -N 8 -t u1 $pkg)}
local i=$(( 256 * ( 256 * ( 256 * $2 + $3 ) + $4 ) + $5 ))
local d=$(( 256 * ( 256 * ( 256 * $6 + $7 ) + $8 ) + $9 ))
-sigsize=$(( 8 + 16 * $i + $d ))
+local sigsize=$(( 8 + 16 * $i + $d ))
o=$(( $o + $sigsize + ( 8 - ( $sigsize % 8 ) ) % 8 + 8 ))
set -- ${(s: :)$(od -j $o -N 8 -t u1 $pkg)}
i=$(( 256 * ( 256 * ( 256 * $2 + $3 ) + $4 ) + $5 ))
diff --git a/lib/zsh/side.zsh b/lib/zsh/side.zsh
index 3017c21..abb6935 100755
--- a/lib/zsh/side.zsh
+++ b/lib/zsh/side.zsh
@@ -229,7 +229,7 @@
(
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
+ builtin autoload -Uz zmv
( zmv -W '**/._zplugin' '**/._zi' ) &>/dev/null
builtin cd -q ${ZI[SNIPPETS_DIR]} || return 1
( zmv -W '**/._zplugin' '**/._zi' ) &>/dev/null
@@ -242,7 +242,7 @@
(
builtin print -Pr -- "${ZI[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" "FOR THE ZINIT -> ZI RENAME…%f"
builtin cd -q ${ZI[PLUGINS_DIR]} || return 1
- autoload -Uz zmv
+ builtin autoload -Uz zmv
( zmv -W '**/.zinit' '**/._zi' ) &>/dev/null
builtin cd -q ${ZI[SNIPPETS_DIR]} || return 1
( zmv -W '**/._zinit' '**/._zi' ) &>/dev/null
@@ -341,7 +341,7 @@
} # ]]]
# 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.
+# successfully reaches 0, or 1 if Ctrl-C will be pressed.
.zi-countdown() {
(( !${+ICE[countdown]} )) && return 0
builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
@@ -358,28 +358,3 @@
+zi-message -r -- "{b}{error}0 {rst}{…}"
return 0
} # ]]]
-# FUNCTION: .zi-check-module. [[[
-# Check module. Don't trust access times and verify hard stored values.
-.zi-check-module() {
- [[ -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} ]]; then
- +zi-message "{u-warn}WARNING{b-warn}:{rst}{msg} A {lhi}recompilation{rst}" \
- "of the zpmod 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}"
- return 0
- 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]}"
- return 1
- fi
- fi
-} # ]]]
diff --git a/zi.zsh b/zi.zsh
old mode 100755
new mode 100644
index 200a749..4563e8a
--- a/zi.zsh
+++ b/zi.zsh
@@ -27,16 +27,23 @@ multisrc|compile|nocompile|nocompletions|reset-prompt|wrap|reset|sh|\!sh|bash|\!
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"
+# Determine ZI[VERSION]
+if [[ -d "${ZI[BIN_DIR]:-$PWD}/.git" || -e "${ZI[BIN_DIR]:-$PWD}/.git" ]]; then
+ ZI[VERSION]=$(git -C "${ZI[BIN_DIR]:-$PWD}" describe --tags --exact-match 2>/dev/null) || ZI[VERSION]=$(git -C "${ZI[BIN_DIR]:-$PWD}" rev-parse --short HEAD 2>/dev/null) || ZI[VERSION]="unknown"
+else
+ ZI[VERSION]="unknown"
+fi
+
# In no value, i.e. not designed to hold value.
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|reset"
# Subcommands list
-ZI[cmd-list]="-h|--help|help|subcmds|icemods|analytics|man|self-update|times|zstatus|load|light|unload|\
+ZI[cmd-list]="-V|--version|version|-h|--help|help|subcmds|icemods|analytics|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"
+uncompile|compiled|cdlist|cdreplay|cdclear|srv|recall|env-whitelist|bindkeys|module|add-fpath|run|version"
# Establish ZI[BIN_DIR]
[[ ! -e ${ZI[BIN_DIR]}/zi.zsh ]] && ZI[BIN_DIR]=
@@ -113,8 +120,6 @@ fi
: ${ZI[ZMODULES_DIR]:=${ZI[HOME_DIR]}/zmodules}
: ${ZI[ZCOMPDUMP_PATH]:=${ZI[CACHE_DIR]}/.zcompdump}
: ${ZI[COMPLETIONS_DIR]:=${ZI[HOME_DIR]}/completions}
-# Additional/Optional directories for software/data files.
-: ${ZI[NODE_PATH_DIR]:=${ZPFX}/lib/node_modules}
# Base Directory Specification (XDG)
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
@@ -122,8 +127,13 @@ fi
: ${XDG_ZI_CACHE:=${ZI[CACHE_DIR]}}
: ${XDG_ZI_CONFIG:=${ZI[CONFIG_DIR]}}
-# Options Specification
+# Disable aliases.
: ${ZI[ALIASES_OPT]:=${${options[aliases]:#off}:+1}}
+
+# Disable Zi's internal aliases.
+: ${ZI[INTERNAL_ALIASES]:=0}
+
+# Set owner of the Zi's packages. It allows to use the packages from specific user instead of the z-shell organization.
: ${ZI[PKG_OWNER]:=z-shell}
ZI[HOME_DIR]=${~ZI[HOME_DIR]}
@@ -140,7 +150,6 @@ ZI[SERVICES_DIR]=${~ZI[SERVICES_DIR]}
ZI[ZMODULES_DIR]=${~ZI[ZMODULES_DIR]}
ZI[ZCOMPDUMP_PATH]=${~ZI[ZCOMPDUMP_PATH]}
ZI[COMPLETIONS_DIR]=${~ZI[COMPLETIONS_DIR]}
-ZI[NODE_PATH_DIR]=${~ZI[NODE_PATH_DIR]}
ZPFX=${~ZPFX}
XDG_ZI_HOME=${~ZI[HOME_DIR]}
@@ -148,49 +157,43 @@ XDG_ZI_CACHE=${~ZI[CACHE_DIR]}
XDG_ZI_CONFIG=${~ZI[CONFIG_DIR]}
if [[ -z ${manpath[(re)${ZI[MAN_DIR]}]} ]] && [[ -d ${ZI[MAN_DIR]} ]]; then
- manpath=( "${ZI[MAN_DIR]}" "${manpath[@]}" )
typeset -gxU manpath
+ manpath=( "${ZI[MAN_DIR]}" "${manpath[@]}" )
fi
if [[ -z ${cdpath[(re)${ZI[CDPATH_DIR]}]} ]] && [[ -d ${ZI[CDPATH_DIR]} ]]; then
builtin setopt auto_cd
- cdpath=( "${ZI[CDPATH_DIR]}" "${cdpath[@]}" )
typeset -gxU cdpath CDPATH
+ cdpath=( "${ZI[CDPATH_DIR]}" "${cdpath[@]}" )
fi
if [[ -z ${mailpath[(re)${ZI[MAIL_DIR]}]} ]]; then
- mailpath=( "${ZI[MAIL_DIR]}" "${mailpath[@]}" )
typeset -gxU mailpath MAILPATH
+ mailpath=( "${ZI[MAIL_DIR]}" "${mailpath[@]}" )
fi
if [[ -z ${path[(re)${ZPFX}/bin]} ]] && [[ -d ${ZPFX}/bin ]]; then
- path=( "${ZPFX}/bin" "${path[@]}" )
typeset -gxU path PATH
+ path=( "${ZPFX}/bin" "${path[@]}" )
fi
if [[ -z ${path[(re)${ZPFX}/sbin]} ]] && [[ -d ${ZPFX}/sbin ]]; then
- path=( "${ZPFX}/sbin" "${path[@]}" )
typeset -gxU path PATH
+ path=( "${ZPFX}/sbin" "${path[@]}" )
fi
if [[ -z ${fpath[(re)${ZI[COMPLETIONS_DIR]}]} ]]; then
- fpath=( "${ZI[COMPLETIONS_DIR]}" "${fpath[@]}" )
typeset -gxU fpath FPATH
+ fpath=( "${ZI[COMPLETIONS_DIR]}" "${fpath[@]}" )
fi
# Export/assign/tie new paths.
if [[ -z ${logpath[(re)${ZI[LOG_DIR]}]} ]] && [[ -d ${ZI[LOG_DIR]} ]]; then
- logpath=( "${ZI[LOG_DIR]}" "${logpath[@]}" )
typeset -gxU logpath LOG_PATH
+ logpath=( "${ZI[LOG_DIR]}" "${logpath[@]}" )
typeset -gxTU LOG_PATH logpath
fi
-if [[ -z ${nodepath[(re)${ZI[NODE_PATH_DIR]}]} ]] && [[ -d ${ZI[NODE_PATH_DIR]} ]]; then
- nodepath=( "${ZI[NODE_PATH_DIR]}" "${nodepath[@]}" )
- typeset -gxU nodepath NODE_PATH
- typeset -gxTU NODE_PATH nodepath
-fi
-
ZI[UPAR]=";:^[[A;:^[OA;:\\e[A;:\\eOA;:${termcap[ku]/$'\e'/^\[};:${terminfo[kcuu1]/$'\e'/^\[};:"
ZI[DOWNAR]=";:^[[B;:^[OB;:\\e[B;:\\eOB;:${termcap[kd]/$'\e'/^\[};:${terminfo[kcud1]/$'\e'/^\[};:"
ZI[RIGHTAR]=";:^[[C;:^[OC;:\\e[C;:\\eOC;:${termcap[kr]/$'\e'/^\[};:${terminfo[kcuf1]/$'\e'/^\[};:"
@@ -1147,9 +1150,6 @@ builtin setopt noaliases
if [[ ! -d ${ZPFX}/bin ]]; then
command mkdir -p "${ZPFX}/bin"
fi
- if [[ ! -d ${ZPFX}/sbin ]]; then
- command mkdir -p "${ZPFX}/sbin"
- fi
if [[ ! -d ${ZPFX}/lib ]]; then
command mkdir -p "${ZPFX}/lib"
command chmod go-w "${ZPFX}/lib"
@@ -1186,7 +1186,7 @@ builtin setopt noaliases
(( ${+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
+ .zi-compinit 1 1 &>/dev/null
fi
if [[ ! -d ${ZI[COMPLETIONS_DIR]} ]]; then
command mkdir "${ZI[COMPLETIONS_DIR]}"
@@ -1194,12 +1194,12 @@ builtin setopt noaliases
# Symlink _zi completion into _local---zi directory.
command ln -s "${ZI[PLUGINS_DIR]}/_local---zi/_zi" "${ZI[COMPLETIONS_DIR]}"
(( ${+functions[.zi-setup-plugin-dir]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- .zi-compinit &>/dev/null
+ .zi-compinit 1 1 &>/dev/null
fi
if [[ ! -d ${ZI[SNIPPETS_DIR]} ]]; then
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; )
+ ( builtin cd -q ${ZI[SNIPPETS_DIR]}; command ln -s OMZ::plugins plugins; )
command mkdir -p "${ZI[SERVICES_DIR]}"
command chmod go-w "${ZI[SERVICES_DIR]}"
fi
@@ -1333,8 +1333,8 @@ builtin setopt noaliases
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)
+ builtin setopt local_options extended_glob
+ builtin autoload $local_dir/$dirname/functions/^([_.]*|prompt_*_setup|README*)(D-.N:t)
}
}
# Source.
@@ -1571,6 +1571,7 @@ builtin setopt noaliases
[[ -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
+ # 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
@@ -1756,17 +1757,19 @@ builtin setopt noaliases
# formats, and colorizes the following pieces of text:
# [URLs], [plugin IDs (user/repo) if exists on the disk], [numbers], [time], [single-word id-as plugins],
# [single word commands], [single word functions], [zi commands], [ice modifiers (e.g: mv'a -> b')],
-# [single-char bits and quoted strings (`...', ,'...', "...")].
+# [single-char bits and quoted strings (`...`, ,'...', "...")].
.zi-formatter-auto() {
- builtin emulate -L zsh ${=${options[xtrace]:#off}:+-o xtrace}
- builtin setopt extendedglob warncreateglobal typesetsilent
- local out in=$1 i rwmsg match spaces rest
- integer mbegin mend
- local -a ice_order ecmds
+ builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
+ builtin setopt extended_glob warn_create_global typeset_silent no_short_loops rc_quotes no_auto_pushd
+
+ local MATCH in=$1 out rwmsg spaces rest; integer MBEGIN MEND
+ local -a match mbegin mend ice_order ecmds
+
ice_order=( ${(As:|:)ZI[ice-list]} ${(@)${(@Akons:|:u)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/} )
ecmds=( ${ZI_EXTS[(I)z-annex subcommand:*]#z-annex subcommand:} )
in=${(j: :)${${(Z+Cn+)in}//[$'\t ']/$'\u00a0'}}
rwmsg=$in
+
while [[ $in == (#b)([[:space:]]#)([^[:space:]]##)(*) ]]; do
spaces=$match[1]
rest=$match[3]
@@ -1775,31 +1778,30 @@ builtin setopt noaliases
if [[ $rwmsg == ([[:space:]]##|(#s))[0-9.]##([[:space:]]##|(#e)) && \
$rest == ([[:space:]]#|(#s))[sm]([[:space:]]##*|(#e)) || $rwmsg == ([[:space:]]##|(#s))[0-9.]##[sm]([[:space:]]##|(#e)) ]]; then
REPLY=${ZI[col-time]}$rwmsg${ZI[col-rst]}
- if [[ $rwmsg != *[sm]* ]]; then
- rest=$ZI[col-time]${(M)rest##[[:space:]]#[sm]}$ZI[col-rst]${rest##[[:space:]]#[sm]}
- fi
+ [[ $rwmsg != *[sm]* ]] && rest=$ZI[col-time]${(M)rest##[[:space:]]#[sm]}$ZI[col-rst]${rest##[[:space:]]#[sm]}
elif [[ $rwmsg == ([[:space:]]##|(#s))[0-9.]##([[:space:]]##|(#e)) ]]; then
REPLY=${ZI[col-num]}$rwmsg${ZI[col-rst]}
- elif [[ $rwmsg == (#b)((http(s|)|ftp(s|)|rsync|ssh|scp|ntp|file)://[[:alnum:].:+/]##) ]]; then
- .zi-formatter-url $rwmsg
- elif [[ $rwmsg == (--|)(${(~j:|:)ice_order})[:=\"\'\!a-zA-Z0-9-]* ]]; then
+ elif [[ $rwmsg == (#b)(--|)(${(~j:|:)ice_order})([:=\"\'\!a-zA-Z0-9-][^\"\']##[^a-zA-Z0-9]##) ]]; then
REPLY=${ZI[col-ice]}$rwmsg${ZI[col-rst]}
- elif [[ $rwmsg == (OMZ|PZT|PZTM|OMZP|OMZT|OMZL)::* || $rwmsg == [^/]##/[^/]## || -d ${ZI[PLUGINS_DIR]}/${rwmsg//\//---} ]]; then
- .zi-formatter-pid $rwmsg
elif [[ $rwmsg == (${~ZI[cmd-list]}|${(~j:|:)ecmds}) ]]; then
REPLY=${ZI[col-cmd]}$rwmsg${ZI[col-rst]}
- elif (( $+commands[$1] )); then
+ elif (( $+commands[$rwmsg] )); then
REPLY=${ZI[col-bcmd]}$rwmsg${ZI[col-rst]}
- elif (( $+functions[$1] )); then
+ elif (( $+functions[$rwmsg] )); then
REPLY=${ZI[col-func]}$rwmsg${ZI[col-rst]}
- elif [[ $rwmsg == (#b)(*)('<->'|'<–>'|'<—>')(*) || $rwmsg == (#b)(*)(…|–|—|↔|...)(*) ]]; then
- local -A map=( … … - dsh – ndsh — mdsh '<->' ↔ '<–>' ↔ '<—>' ↔ ↔ ↔ ... …)
- REPLY=$match[1]$ZI[col-$map[$rwmsg]]$match[3]
+ elif [[ $rwmsg == (#b)((http(s|)|ftp(s|)|rsync|ssh|scp|ntp|file)://[[:alnum:].:+/]##) ]]; then
+ .zi-formatter-url $rwmsg
+ elif [[ $rwmsg == (OMZ|PZT|PZTM|OMZP|OMZT|OMZL)::* || $rwmsg == [^/]##/[^/]## || -d ${ZI[PLUGINS_DIR]}/${rwmsg//\//---} ]]; then
+ .zi-formatter-pid $rwmsg
+ elif [[ $rwmsg == (#b)(*)(...|'<->'|'<–>'|'<—>')(*) || $rwmsg == (#b)(*)(…|–|—|――|↔|...)(*) ]]; then
+ local -A map=( … … - dsh – ndsh — mdsh ―― mmdsh '<->' ↔ '<–>' ↔ '<—>' ↔ ↔ ↔ ... … )
+ local openq=$match[2] str=$match[3] closeq=$match[4] RST=$ZI[col-rst]
+ REPLY=$match[1]$ZI[col-${map[$openq]}]$str$RST$ZI[col-${map[$closeq]}]$match[5]$ZI[col-rst]
# \1 - preceding \2 - open, \3 - string, \4 - close, \5 - following
elif [[ $rwmsg == (#b)(*)([\'\`\"])([^\'\`\"]##)([\'\`\"])(*) ]]; then
local -A map=( \` bapo \' apo \" quo x\` baps x\' aps x\" quos )
local openq=$match[2] str=$match[3] closeq=$match[4] RST=$ZI[col-rst]
- REPLY=$match[1]$ZI[col-$map[$openq]]$openq$RST$ZI[col-$map[x$openq]]$str$RST$ZI[col-$map[$closeq]]$closeq$RST$match[5]
+ REPLY=$match[1]$ZI[col-${map[$openq]}]$openq$RST$ZI[col-${map[x$openq]}]$str$RST$ZI[col-${map[$closeq]}]$closeq$RST$match[5]$ZI[col-rst]
fi
in=$rest
out+=${spaces//$'\n'/$'\013\015'}$REPLY
@@ -1895,8 +1897,12 @@ builtin setopt noaliases
} # ]]]
# FUNCTION: +zi-message. [[[
+zi-message() {
- builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
- local opt msg
+ builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
+ builtin setopt extended_glob warn_create_global typeset_silent no_short_loops rc_quotes no_auto_pushd
+
+ local MATCH opt msg; integer MBEGIN MEND
+ local -a match mbegin mend
+
[[ $1 = -* ]] && { local opt=$1; shift; }
ZI[__last-formatter-code]=
@@ -1904,8 +1910,7 @@ builtin setopt noaliases
# 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):-←→}}:-$(.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]}}}:+}}}//←→}
+ 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):-←→}}:-$(.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]}}}:+}}}//←→}
# Reset color attributes at the end of the message.
msg=$msg$ZI[col-rst]
# Output the processed message:
@@ -1919,14 +1924,15 @@ builtin setopt noaliases
# FUNCTION: +zi-prehelp-usage-message. [[[
# Prints the usage message.
+zi-prehelp-usage-message() {
- builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace}
+ builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
+ builtin setopt extended_glob warn_create_global typeset_silent no_short_loops rc_quotes no_auto_pushd
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}"
+ +zi-message "Available options for {apo}\`{cmd}$cmd{apo}\`{rst} subcommand{ehi}:{rst}"
local opt
for opt ( ${(kos:|:)allowed} ) {
[[ $opt == --* ]] && continue
@@ -1940,9 +1946,7 @@ builtin setopt noaliases
}
} 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}"
+ +zi-message "{error}Error{ehi}:{rst} Incorrect options given{ehi}:{rst} ${(Mpj:$sep:)@:#-*}{rst}. Allowed for the subcommand{ehi}:{rst} {apo}\`{cmd}$cmd{apo}\`{rst} are{ehi}:{rst} {nl}{mmdsh}{opt} ${allowed//\|/$sep2}{rst}{nl}{nl}To see the general help message, type: {cmd}zi help"
} else {
local -a cmds
cmds=( load snippet update delete )
@@ -1957,11 +1961,11 @@ builtin setopt noaliases
"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 ${=${options[xtrace]:#off}:+-o xtrace}
+ builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace}
+ builtin setopt extended_glob typeset_silent no_short_loops rc_quotes no_auto_pushd
reply=( "${(@)${@[2,-1]//([ $'\t']##|(#s))(#b)(${(~j.|.)${(@s.|.)___opt_map[$1]}})(#B)([ $'\t']##|(#e))/${OPTS[${___opt_map[${match[1]}]%%:*}]::=1}ß←↓→}:#1ß←↓→}" )
} # ]]]
@@ -2145,7 +2149,6 @@ return retval
# (delay), i.e. "burst" allows to run package installations from
# script, not from prompt.
#
-
@zi-scheduler() {
integer ___ret="${${ZI[lro-data]%:*}##*:}"
# lro stands for lastarg-retval-option.
@@ -2244,6 +2247,17 @@ return retval
[[ ${ZI[lro-data]##*:} = on ]] && return 0 || return ___ret
} # ]]]
+# FUNCTION: .zi-set-mtime. [[[
+# Stores mtime of zi.zsh and its lib files into ZI[mtime] and ZI[mtime-{side,install,autoload,additional}].
+# This is used to determine if the files were changed and need to be reloaded.
+.zi-set-mtime() {
+ local set_mtime
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/zi.zsh" "ZI[mtime]"
+ for set_mtime ( side install autoload additional ) {
+ .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/${set_mtime}.zsh" "ZI[mtime-${set_mtime}]"
+ }
+}
+
#
# Exposed functions.
#
@@ -2274,21 +2288,29 @@ zi() {
--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)."
+ -d opt_-d,--debug:"Turn on debug messages from the operation."
+ --debug opt_-d,--debug
+ -D opt_-D,--dry-run:"Turn on dry-run mode, which means that no changes will be made to the filesystem."
+ --dry-run opt_-D,--dry-run
+ -r opt_-r,--reset:"update:[Reset/clean the repository before updating.] module:[Check and rebuild the module if needed.]"
--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.]"
+ -a opt_-a,--all:"delete:[Delete {hi}all{rst} plugins and snippets.] update:[Update {b-lhi}all{rst} plugins and snippets.] report:[Show report of {b-lhi}all{rst} plugins and snippets.] compile:[Compile {b-lhi}all{rst} plugins and snippets] uncompile:[Uncompile {b-lhi}all{rst} plugins and snippets] times:[Show loading times and moments.]"
--all opt_-a,--all
+ -B opt_-B,--build:"Build the module, append {p}--clean{rst} to run distclean."
+ --build opt_-B,--build
-c opt_-c,--clean:"Delete {b-lhi}only{rst} the {b-lhi}currently-not loaded{rst} plugins and snippets."
--clean opt_-c,--clean
+ -I opt_-I,--info:"Display additional information."
+ --info opt_-I,--info
-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.]"
+ -s opt_-s,--snippets:"Update only snippets (i.e.: skip updating plugins)."
--snippets opt_-s,--snippets
- -L opt_-l,--plugins:"Update only plugins (i.e.: skip updating 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
@@ -2296,25 +2318,32 @@ zi() {
--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."
+ -m opt_-m,--moments:"Show the loading {apo}*{b-lhi}moments{apo}*{rst} of of the objects relative to the first prompt."
--moments opt_-m,--moments
+ -S opt_-S,--seconds:"Show times in seconds."
+ --seconds opt_-S,--seconds
-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"
+ update "-h|--help|-l|--plugins|-s|--snippets|-p|--parallel|-a|--all|-q|--quiet|-r|--reset|-u|--urge|-n|--no-pager|-v|--verbose"
+ self-update "-h|--help|-q|--quiet|-D|--dry-run"
+ compile "-h|--help|-a|--all|-q|--quiet"
+ uncompile "-h|--help|-a|--all|-q|--quiet"
+ delete "-h|--help|-a|--all|-c|--clean|-y|--yes|-q|--quiet"
unload "-h|--help|-q|--quiet"
cdclear "-h|--help|-q|--quiet"
cdreplay "-h|--help|-q|--quiet"
- times "-h|--help|-m|-s|-a"
- light "-h|--help|-b"
+ module "-h|--help|-B|--build|-I|--info|-r|--reset"
+ times "-h|--help|-m|--moments|-S|--seconds|-a|--all"
+ light "-h|--help|-b|--bindkeys"
+ report "-h|--help|-a|--all"
snippet "-h|--help|-f|--force|--command|-x"
)
cmd="$1"
- if [[ $cmd == (times|unload|env-whitelist|update|snippet|load|light|cdreplay|cdclear|delete) ]]; then
+ if [[ $cmd == (times|unload|env-whitelist|update|self-update|compile|uncompile|snippet|load|light|report|cdreplay|module|cdclear|delete) ]]; then
if (( $@[(I)-*] || OPTS[opt_-h,--help] )); then
.zi-parse-opts "$cmd" "$@"
if (( OPTS[opt_-h,--help] )); then
@@ -2344,17 +2373,14 @@ zi() {
ICE=() ZI_ICE=()
1="${1:+@}${1#@}${2:+/$2}"
(( $# > 1 )) && { shift -p $(( $# - 1 )); }
- [[ -z $1 ]] && {
- +zi-message "Argument needed, try: {cmd}help."
- return 1
- }
+ [[ -z $1 ]] && { +zi-message "{mmdsh}{rst} {auto}Argument is missing. See \`zi 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-message -n "{error}Error{ehi}:{rst} Unknown subcommand{ehi}:{rst} {apo}\`{cmd}$1{apo}\`{rst} "
+zi-prehelp-usage-message rst
return 1
} elif (( $# == 0 )) {
@@ -2380,7 +2406,7 @@ zi() {
ICE=( "${___ices[@]}" "${(kv)ZI_ICES[@]}" )
ZI_ICE=( "${(kv)ICE[@]}" ) ZI_ICES=()
integer ___msgs=${+ICE[debug]}
- (( ___msgs )) && +zi-message "{profile}zi-main{ehi}:{faint} Processing {pname}$1{faint}{…}{rst}"
+ (( ___msgs )) && +zi-message "{mmdsh}{happy} Zi{rst} » {faint}processing {pname}$1{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.
@@ -2607,22 +2633,19 @@ zi() {
(zstatus)
.zi-show-zstatus
;;
- (times)
- .zi-show-times "${@[2-correct,-1]}"
- ;;
- (self-update)
- .zi-self-update "$2"
- ;;
(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
+ +zi-message "{mmdsh}{rst} {auto}Argument is missing. See \`zi 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
;;
+ (version)
+ +zi-message "Zi version: ${ZI[VERSION]}"
+ ;;
(bindkeys)
.zi-list-bindkeys
;;
@@ -2637,7 +2660,7 @@ zi() {
.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; }
+ [[ -z $1$2 && $(( OPTS[opt_-a,--all] + OPTS[opt_-p,--parallel] + OPTS[opt_-s,--snippets] + OPTS[opt_-l,--plugins] )) -eq 0 ]] && { +zi-message "{mmdsh}{happy} Zi{rst} » {faint}initializing{rst}{…}"; sleep 2; }
(( OPTS[opt_-p,--parallel] )) && OPTS[value]=${1:-15}
.zi-update-or-status-all update; ___retval=$?
else
@@ -2648,7 +2671,7 @@ zi() {
;;
(status)
if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
- [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 3; }
+ [[ -z $2 ]] && { +zi-message "{mmdsh}{happy} Zi{rst} » {faint}initializing status{rst}{…}"; sleep 2; }
.zi-update-or-status-all status; ___retval=$?
else
.zi-update-or-status status "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
@@ -2656,8 +2679,8 @@ zi() {
;;
(report)
if [[ $2 = --all || ( -z $2 && -z $3 ) ]]; then
- [[ -z $2 ]] && { builtin print -r -- "Assuming --all is passed"; sleep 4; }
- .zi-show-all-reports
+ [[ -z $2 ]] && { +zi-message "{mmdsh}{happy} Zi{rst} » {faint}initializing report{rst}{…}"; sleep 2; }
+ .zi-show-all-reports
else
.zi-show-report "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
fi
@@ -2677,16 +2700,14 @@ zi() {
;;
(cdisable)
if [[ -z $2 ]]; then
- builtin print "Argument needed, try: help"; ___retval=1
+ +zi-message "{mmdsh}{rst} {auto}Argument is missing. See \`zi 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]}" "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
+ .zi-compinit 1 1 &>/dev/null
else
___retval=1
fi
@@ -2694,17 +2715,14 @@ zi() {
;;
(cenable)
if [[ -z $2 ]]; then
- builtin print "Argument needed, try: help"; ___retval=1
+ +zi-message "{mmdsh}{rst} {auto}Argument is missing. See \`zi help\`"; ___retval=1
else
local ___f="_${2#_}"
- # Enable completion given by completion function name
- # with or without leading _, e.g. cp, _cp.
+ # 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]}" "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
+ .zi-compinit 1 1 &>/dev/null
else
___retval=1
fi
@@ -2712,31 +2730,25 @@ zi() {
;;
(creinstall)
(( ${+functions[.zi-install-completions]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- # Installs completions for plugin. Enables them all. It is a
- # reinstallation, thus every obstacle gets overwritten or removed.
+ # Installs completions for plugin. Enables them all.
+ # It is 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]}" "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"
;;
(cuninstall)
if [[ -z $2 && -z $3 ]]; then
- builtin print "Argument needed, try: help"; ___retval=1
+ +zi-message "{mmdsh}{rst} {auto}Argument is missing. See \`zi help\`"; ___retval=1
else
- (( ${+functions[.zi-forget-completion]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
- # Uninstalls completions for plugin.
+ (( ${+functions[.zi-uninstall-completions]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ # Uninstalls completions for plugin. Disables them all.
.zi-uninstall-completions "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
- +zi-message "Initializing completion ({func}compinit{rst}){…}"
- builtin autoload -Uz compinit
- compinit -d "${ZI[ZCOMPDUMP_PATH]}" "${(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
+ (( ${+functions[.zi-compinit]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/install.zsh" || return 1
.zi-compinit; ___retval=$?
;;
(dreport)
@@ -2751,18 +2763,30 @@ zi() {
.zi-debug-unload
;;
(compile)
+ .zi-parse-opts compile "$@"
+ builtin set -- "${reply[@]}"
(( ${+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=$?
+ if (( OPTS[opt_-a,--all] )) || [[ -z $2 && -z $3 ]]; then
+ if (( OPTS[opt_-q,--quiet] )); then
+ .zi-compile-uncompile-all 1 >/dev/null; ___retval=$?
+ else
+ +zi-message "{mmdsh}{happy} Zi{rst} » {faint}compiling{rst}{…}"; sleep 2
+ .zi-compile-uncompile-all 1; ___retval=$?
+ fi
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=$?
+ .zi-parse-opts uncompile "$@"
+ builtin set -- "${reply[@]}"
+ if (( OPTS[opt_-a,--all] )) || [[ -z $2 && -z $3 ]]; then
+ if (( OPTS[opt_-q,--quiet] )); then
+ .zi-compile-uncompile-all 0 >/dev/null; ___retval=$?
+ else
+ +zi-message "{mmdsh}{happy} Zi{rst} » {faint}uncompiling{rst}{…}"; sleep 2
+ .zi-compile-uncompile-all 0; ___retval=$?
+ fi
else
.zi-uncompile-plugin "${2%%(///|//|/)}" "${3%%(///|//|/)}"; ___retval=$?
fi
@@ -2773,7 +2797,7 @@ zi() {
(cdlist)
.zi-list-compdef-replay
;;
- (cd|delete|recall|edit|glance|changes|create|stress)
+ (cd|delete|recall|edit|glance|changes|create|stress|self-update|times)
.zi-"$1" "${@[2-correct,-1]%%(///|//|/)}"; ___retval=$?
;;
(recently)
@@ -2808,14 +2832,18 @@ zi() {
} "$@"
;;
(module)
- .zi-module "${@[2-correct,-1]}"; ___retval=$?
+ if [[ -z $2 ]]; then
+ +zi-message "{b}{error}Error{ehi}:{rst} Argument required, try{ehi}:{rst} {cmd}zi module {opt}-h{rst}"; ___retval=1
+ else
+ .zi-module "$2" "${@[3-correct,-1]}"; ___retval=$?
+ fi
;;
(*)
if [[ -z $1 ]] {
- +zi-message -n "{b}{u-warn}ERROR{b-warn}:{rst} Missing a {cmd}subcommand "
+ +zi-message -n "{error}Error{ehi}:{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-message -n "{error}Error{ehi}:{rst} Unknown subcommand{ehi}:{rst} {apo}\`{error}$1{apo}\`{rst} "
+zi-prehelp-usage-message rst
}
___retval=1
@@ -2839,37 +2867,37 @@ zicdclear() { .zi-compdef-clear -q; }
# A function that can be invoked from within `atinit', `atload', etc. ice-mod.
# It runs `autoload compinit; compinit' and respects
# ZI[ZCOMPDUMP_PATH] and ZI[COMPINIT_OPTS].
-zicompinit() { autoload -Uz compinit; compinit -d "${ZI[ZCOMPDUMP_PATH]}" "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"; }
+zicompinit() { builtin autoload -Uz compinit; compinit -d "${ZI[ZCOMPDUMP_PATH]}" "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"; }
# ]]]
# FUNCTION: zicompinit_fast. [[[
-# Checking the cached .zcompdump file to see if it must be regenerated adds a noticable delay to zsh startup.
+# Checks the cached .zcompdump file to see if it must be regenerated adds a noticable delay to zsh startup.
# This restricts checking it once a day, determines when to regenerate, as compinit doesn't always need to
# modify the compdump and compiles mapped to share (total mem reduction) run in background in multiple shells.
-# A function that can be invoked from within `atinit', `atload'
+# A function that can be invoked from within `atinit', `atload', e.g: zi ice atinit'zicompinit_fast'.
zicompinit_fast() {
- autoload -Uz compinit
- local zcompf="${ZI[ZCOMPDUMP_PATH]}"
- #local check_ub="$(awk -F= '/^NAME/{print $2}' /etc/os-release | grep 'Ubuntu')"
- local zcompf_a="${zcompf}.augur"
- #[[ $check_ub ]] && export skip_global_compinit=1
+ builtin autoload -Uz compinit zrecompile
+
+ if grep -q '^ID.*=.*ubuntu' /etc/os-release 2>/dev/null; then
+ typeset -gx skip_global_compinit=1
+ fi
# Globbing (#qN.mh+24):
# - '#q' is an explicit glob qualifier that makes globbing work within zsh's [[ ]] construct.
# - 'N' makes the glob pattern evaluate to nothing when it doesn't match (rather than throw a globbing error)
# - '.' matches "regular files"
# - 'mh+24' matches files, directories and etc., that are older than 24 hours.
- if [[ -e "$zcompf_a" && -f "$zcompf_a"(#qN.mh+24) ]]; then
- compinit -d "$zcompf"
- command touch "$zcompf_a"
+
+ # If the .lock file exists and is older than 24 hours, then regenerate the zcompdump
+ if [[ -e "${ZI[ZCOMPDUMP_PATH]}.lock" && -f "${ZI[ZCOMPDUMP_PATH]}.lock"(#qN.mh+24) ]]; then
+ compinit -d "$ZI[ZCOMPDUMP_PATH]"
+ command touch "${ZI[ZCOMPDUMP_PATH]}.lock"
else
- compinit -C -d "$zcompf"
+ compinit -C -d "$ZI[ZCOMPDUMP_PATH]"
fi
- # if .zcompdump exists (and is non-zero), and is older than the .zwc file, then regenerate
- if [[ -s "$zcompf" && (! -s "${zcompf}.zwc" || "$zcompf" -nt "${zcompf}.zwc") ]]; then
- # since file is mapped, it might be mapped right now (current shells), so rename it then make a new one
- [[ -e "$zcompf.zwc" ]] && command mv -f "$zcompf.zwc" "$zcompf.zwc.old"
- # compile it mapped, so multiple shells can share it (total mem reduction) run in background
- { zcompile -M "$zcompf" && command rm -f "$zcompf.zwc.old" }&!
+
+ # If zcompdump exists (and is non-zero), and is older than the .zwc file, then regenerate in the background
+ if [[ -s "$ZI[ZCOMPDUMP_PATH]" && (! -s "${ZI[ZCOMPDUMP_PATH]}.zwc" || "$ZI[ZCOMPDUMP_PATH]" -nt "${ZI[ZCOMPDUMP_PATH]}.zwc") ]]; then
+ { zrecompile -q -p "$ZI[ZCOMPDUMP_PATH]" && command rm -f "$ZI[ZCOMPDUMP_PATH].zwc.old" } &!
fi
}
# ]]]
@@ -2888,12 +2916,6 @@ zicompdef() { ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
# Default ices depth'3' and lucid, allowed values [0-9][a-c].
zi-turbo() { zi depth'3' lucid ${1/#[0-9][a-c]/wait"${1}"} "${@:2}"; }
# ]]]
-# Compatibility functions. [[[
-❮▼❯() { zi "$@"; }
-zpcdreplay() { .zi-compdef-replay -q; }
-zpcdclear() { .zi-compdef-clear -q; }
-zpcompinit() { autoload -Uz compinit; compinit -d "${ZI[ZCOMPDUMP_PATH]}" "${(Q@)${(z@)ZI[COMPINIT_OPTS]}}"; }
-zpcompdef() { ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
#
# Source-executed code.
@@ -2902,26 +2924,24 @@ zpcompdef() { ZI_COMPDEF_REPLAY+=( "${(j: :)${(q)@}}" ); }
(( ZI[ALIASES_OPT] )) && builtin setopt aliases
(( ZI[SOURCED] ++ )) && return
-autoload add-zsh-hook
+builtin 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
}
+
functions -M -- zi_scheduler_add 1 1 -zi_scheduler_add_sh 2>/dev/null
+
zmodload zsh/zpty zsh/system 2>/dev/null
zmodload -F zsh/stat b:zstat 2>/dev/null && ZI[HAVE_ZSTAT]=1
# code. [[[
-builtin alias zini=zi zinit=zi zplugin=zi
+# Internal aliases for compatibility with deprecated names. Can be enabled with ZI[INTERNAL_ALIASES]=1.
+(( ZI[INTERNAL_ALIASES] )) && builtin alias zinit=zi zplugin=zi
.zi-prepare-home
-
-# Remember source's timestamps for the automatic-reload feature.
-typeset -g ZI_TMP
-.zi-get-mtime-into "${ZI[BIN_DIR]}/zi.zsh" "ZI[mtime]"
-for ZI_TMP ( side install autoload ) {
- .zi-get-mtime-into "${ZI[BIN_DIR]}/lib/zsh/${ZI_TMP}.zsh" "ZI[mtime-${ZI_TMP}]"
-}
+.zi-set-mtime
# 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}" )
@@ -2935,12 +2955,14 @@ zstyle ':completion:*:zi:argument-rest:plugins' list-colors '=(#b)(*)/(*)==1;34=
zstyle ':completion:*:zi:argument-rest:plugins' matcher 'r:|=** l:|=*'
zstyle ':completion:*:*:zi:*' group-name ""
# ]]]
-# Check module built / compile status [[[
+
+# Check the module compiled timestamps and recompile if needed,
+# if no action is required, then no message will be printed. [[[
if [[ -e "${ZI[ZMODULES_DIR]}/zpmod/Src/zi/zpmod.so" ]]; then
if [[ ! -f ${ZI[ZMODULES_DIR]}/zpmod/COMPILED_AT || \
( ${ZI[ZMODULES_DIR]}/zpmod/COMPILED_AT -ot ${ZI[ZMODULES_DIR]}/zpmod/RECOMPILE_REQUEST ) ]]; then
- (( ${+functions[.zi-check-module]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || return 1
- .zi-check-module
+ (( ${+functions[.zi-module]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/autoload.zsh" || return 1
+ .zi-module --reset
fi
fi # ]]]