From e9e6257f470a10a72bfda046630863bf1d465f78 Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Sat, 28 May 2022 17:18:47 +0100 Subject: [PATCH 1/9] [WIP] --- lib/_zi | 171 ++++++++++++----------- lib/zsh/autoload.zsh | 248 ++++++++++++++++----------------- lib/zsh/git-process-output.zsh | 64 ++++----- lib/zsh/install.zsh | 6 +- zi.zsh | 15 +- 5 files changed, 252 insertions(+), 252 deletions(-) diff --git a/lib/_zi b/lib/_zi index 841ebee6..baa155c2 100755 --- a/lib/_zi +++ b/lib/_zi @@ -1,4 +1,5 @@ #compdef zi +# shellcheck disable=SC2034,SC2039,SC2059,SC2086,SC2129,SC2181,SC2296,SC2170,SC2128,SC2206,SC1036,SC2039,SC2068,SC2076,SC2155,SC2162,SC2181,SC2201,SC2207,SC2208,SC2236,SC2255,SC2270,SC2273,SC2274,SC2275,SC2276,SC2277,SC2278,SC2279,SC2280,SC2281,SC2282,SC2283,SC2284,SC2285,SC2286,SC2287,SC2288,SC2289,SC2290,SC2291,SC2292,SC2293,SC2294,SC2295,SC2296,SC2297,SC2298,SC2299,SC2300,SC2301,SC2302,SC2303,SC2304,SC2305,SC2306,SC2307,SC2308,SC2309,SC2310,SC2311,SC2312,SC2313,SC2314,SC2315,SC2316,SC2317,SC2318,SC2319,SC2320,SC2321,SC2322,SC2323,SC2324,SC2325,SC2326,SC2327,SC2328,SC2329,SC2330,SC2331,SC2332,SC2333,SC2334,SC2335,SC2336,SC2337,SC2338,SC2339,SC2340,SC2341,SC2342,SC2343,SC2344,SC2345,SC2346,SC2347,SC2348,SC2349,SC2350,SC2351,SC2352,SC2353,SC2354,SC2355,SC2356,SC2357,SC2358,SC2359,SC2360,SC2361,SC2362,SC2363,SC2364,SC2365,SC2366,SC2367,SC2368,SC2369,SC2370,SC2371,SC2372,SC2373,SC2374,SC2375,SC2376,SC2377,SC2378,SC2379,SC2380,SC2381,SC2382,SC2383,SC2384,SC2203,SC2168,SC2154 setopt localoptions warncreateglobal typesetsilent @@ -7,74 +8,77 @@ local -a expl typeset -a commands commands=( - analytics:'Show ❮ ZI ❯ Analytics' - control:'❮ ZI ❯ Control commands' - zstatus:'Checks ❮ ZI ❯ Status' - times:'Statistics on plugin loading times' - self-update:'Updates and Compile ❮ ZI ❯' - help:'Usage Information' - man:'Manpage' - load:'Load plugin' - delete:'Delete plugin' - unload:'Unload plugin' - snippet:"Source (or add to PATH with --command) local or remote file (-f: force - don't use cache)" - update:'Git update plugin (or all plugins and snippets if --all passed)' - status:'Git status for plugin (or all plugins if --all passed)' - report:'Show plugin'"'"'s report (or all plugins'"'"' if --all passed)' - loaded:'Show what plugins are loaded' - list:'Show what plugins are loaded' - ls:'List snippets in formatted and colorized manner' - cd:"Go into plugin's directory" - create:'Create plugin (also together with Github repository)' + analytics:"Statistics, benchmarks and information" + subcmds:"Shows subcommands registered by annex" + icemods:"Shows ice-modifiers registered by annex" + zstatus:"Check and provide status information" + times:"Statistics on plugin loading times" + self-update:"Updates and compiles ❮ ZI ❯" + help:"Usage information" + man:"Manpage" + load:"Load plugin" + light:"Light load plugin" + delete:"Delete plugin" + unload:"Unload plugin" + snippet:"Source (or add to PATH with --command) local or remote file (-f: force - do not use cache)" + update:"Git update plugin (or all plugins and snippets if --all passed)" + status:"Git status for plugin (or all plugins if --all passed)" + report:"Show plugins report (or all plugins if --all passed)" + loaded:"Show loaded plugins" + list:"List loaded plugins" + ls:"List snippets in formatted and colorized manner" + cd:"Go into plugin directory" + create:"Create plugin (also together with Github repository)" edit:"Edit plugin's file with \$EDITOR" - glance:"Look at plugin's source (pygmentize, {,source-}highlight)" - stress:'Test plugin for compatibility with set of options' - changes:"View plugin's git log" + glance:"View the plugin source" + stress:"Test the plugin for compatibility with set of options" + changes:"View the plugin git log" recently:"Show plugins that changed recently, argument is e.g. 1 month 2 days" - clist:'List completions in use' - cclear:'Clear stray and improper completions' - completions:'List completions in use' - cdisable:'Disable completion' - cenable:'Enable completion' - creinstall:'Install completions for plugin' - cuninstall:'Uninstall completions for plugin' - csearch:'Search for available completions from any plugin' - compinit:'Refresh installed completions' + clist:"List completions in use" + cclear:"Clear stray and improper completions" + completions:"List completions in use" + cdisable:"Disable completion" + cenable:"Enable completion" + creinstall:"Install completions for plugin" + cuninstall:"Uninstall completions for plugin" + csearch:"Search for available completions from any plugin" + compinit:"Refresh installed completions" dtrace:"Start tracking what's going on in session" dstart:"Start tracking what's going on in session" dstop:"Stop tracking what's going on in session" - dunload:'Revert changes recorded between dstart and dstop' + dunload:"Revert changes recorded between dstart and dstop" dreport:"Report what was going on in session" - dclear:'Clear report of what was going on in session' - compile:'Compile plugin (or all plugins if --all passed)' - uncompile:'Remove compiled version of plugin (or of all plugins if --all passed)' - compiled:'Show which plugins are compiled' - cdlist:'Show compdef replay list' - cdreplay:'Replay compdefs (to be done after compinit)' - cdclear:'Clear compdef replay list' - srv:'Control a service, command can be: stop,start,restart,next,quit; `next'' moves the service to another Zshell' - recall:'Fetch saved ice modifiers and construct `zi ice ...'' command' - bindkeys:'Lists bindkeys set up by each plugin' - module:'Manage binary Zsh module shipped with ❮ ZI ❯, see `zi module help''' + dclear:"Clear report of what was going on in session" + compile:"Compile plugin (or all plugins if --all passed)" + uncompile:"Remove compiled version of plugin (or of all plugins if --all passed)" + compiled:"Show which plugins are compiled" + cdlist:"Show compdef replay list" + cdreplay:"Replay compdefs (to be done after compinit)" + cdclear:"Clear compdef replay list" + srv:"Control a service, command can be: stop,start,restart,next,quit; next'' moves the service to another Zshell" + recall:"Fetch saved ice modifiers and construct 'zi ice ...' command" + bindkeys:"Lists bindkeys set up by each plugin" + module:"Manage binary Zsh module, see 'zi module help' for more info" 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' + env-whitelist:"Allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose" + add-fpath:"Add plugin folder to $fpath" ) -_arguments -C \ - '1: :->command'\ - '*: :->argument' && ret=0 +_arguments -C '1: :->command' '*: :->argument' && ret=0 case $state in command) - _describe -t commands "❮ ZI ❯ commands" commands && ret=0 + _describe -t commands "❮ ZI ❯ commands:" commands && ret=0 ;; argument) - case $words[2] in + case ${words[2]} in help) _message "Hit enter to get usage information" && ret=0 ;; - control) + subcmds) + _message "Hit enter to get commands list" && ret=0 + ;; + icemods) _message "Hit enter to get commands list" && ret=0 ;; analytics) @@ -104,7 +108,7 @@ case $state in plugins=( "${plugins[@]:#_local/zi}" ) plugins=( "${plugins[@]:#custom}" ) local -a opts - if [[ $words[2] = run ]]; then + if [[ ${words[2]} = run ]]; then opts=( -l ) else opts=( -f --front ) @@ -122,17 +126,16 @@ case $state in local -a snippets snippets_alreadyld local sni snippets=( "${ZI[SNIPPETS_DIR]}"/*/._zi(D/:h) ) - snippets=( ${snippets[@]#${ZI[SNIPPETS_DIR]}/} ) - snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) - snippets=( ${snippets[@]/--//} ) - for sni ( ${snippets[@]} ) { - if [[ -n ${ZI_SNIPPETS[$sni]} ]]; then - snippets_alreadyld+=( $sni ) - snippets=( ${snippets[@]:#$sni} ) + snippets=( "${snippets[@]#${ZI[SNIPPETS_DIR]}/}" ) + snippets=( "${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://}" ) + snippets=( "${snippets[@]/--//}" ) + for sni in "${snippets[@]}"; do + if [[ -n "${ZI_SNIPPETS[$sni]}" ]]; then + snippets_alreadyld+=( "${sni}" ) + snippets=( "${snippets[@]:#$sni}" ) fi - } - _alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \ - 'plugins:-- Plugin --:compadd -a - plugins' && ret=0 + done + _alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' 'plugins:-- Plugin --:compadd -a - plugins' && ret=0 ;; unload|report) typeset -a plugins absolute normal @@ -142,7 +145,7 @@ case $state in absolute=( "${absolute[@]/\%\/\//%/}" ) local hm="${HOME%/}" absolute=( "${absolute[@]/$hm/HOME}" ) - plugins=( $normal $absolute ) + plugins=( "${normal}" "${absolute}" ) _wanted plugins expl "-- Plugin --" compadd "$@" -a - plugins && ret=0 ;; all-reports) @@ -177,35 +180,34 @@ case $state in typeset -a plugins completions local p c user plugin for p in "${ZI[PLUGINS_DIR]}"/*; do - completions=( "$p"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|_zsh_highlight*|/zsdoc/*)(DN) ) + completions=( "${p}"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|_zsh_highlight*|/zsdoc/*)(DN) ) for c in "${completions[@]}"; do p="${p:t}" user="${p%%---*}" plugin="${p#*---}" - [[ "$user" = "$plugin" && "${user}---${plugin}" != "$p" ]] && user="" - plugins+=( "${user:+$user/}$plugin" ) + [[ "${user}" = "${plugin}" && "${user}---${plugin}" != "${p}" ]] && user="" + plugins+=( "${user:+${user}/}${plugin}" ) break done done _wanted plugins expl "-- Plugin --" compadd "$@" -a - plugins && ret=0 ;; cuninstall) - # We must iterate each plugin and check if - # it has completions that are installed + # We must iterate each plugin and check if it has completions that are installed typeset -a plugins completions local p c user plugin cfile bkpfile for p in "${ZI[PLUGINS_DIR]}"/*; do - completions=( "$p"/**/_[^_.][^.]#(N) ) + completions=( "${p}"/**/_[^_.][^.]#(N) ) for c in "${completions[@]}"; do cfile="${c:t}" bkpfile="${cfile#_}" # Completion installed, either enabled or disabled? - if [[ -e "${ZI[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZI[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then + if [[ -e "${ZI[COMPLETIONS_DIR]}"/"${cfile}" || -e "${ZI[COMPLETIONS_DIR]}"/"${bkpfile}" ]]; then p="${p:t}" user="${p%%---*}" plugin="${p#*---}" - [[ "$user" = "$plugin" && "${user}---${plugin}" != "$p" ]] && user="" - plugins+=( "${user:+$user/}$plugin" ) + [[ "${user}" = "${plugin}" && "${user}---${plugin}" != "${p}" ]] && user="" + plugins+=( "${user:+${user}/}${plugin}" ) break fi done @@ -219,17 +221,16 @@ case $state in local -a snippets snippets_alreadyld local sni snippets=( "${ZI[SNIPPETS_DIR]}"/**/._zi(D/:h) ) - snippets=( ${snippets[@]#${ZI[SNIPPETS_DIR]}/} ) - snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) - snippets=( ${snippets[@]/--//} ) - for sni ( ${snippets[@]} ) { + snippets=( "${snippets[@]#${ZI[SNIPPETS_DIR]}/}" ) + snippets=( "${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://}" ) + snippets=( "${snippets[@]/--//}" ) + for sni in "${snippets[@]}"; do if [[ -n ${ZI_SNIPPETS[$sni]} ]]; then - snippets_alreadyld+=( $sni ) - snippets=( ${snippets[@]:#$sni} ) + snippets_alreadyld+=( "${sni}" ) + snippets=( "${snippets[@]:#$sni}" ) fi - } - _alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \ - 'files:-- File --:_files' && ret=0 + done + _alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' 'files:-- File --:_files' && ret=0 ;; dstart|dtrace) _message "Hit enter to start tracking this session" && ret=0 @@ -254,13 +255,13 @@ case $state in plugins=( "${ZI[PLUGINS_DIR]}"/*(N) ) typeset -a show_plugins p matches for p in "${plugins[@]}"; do - matches=( $p/*.zwc(N) ) + matches=( "${p}"/*.zwc(N) ) if [ "$#matches" -ne "0" ]; then p="${p:t}" - [ "$p" = "_local---zi" ] && continue - [ "$p" = "custom" ] && continue + [ "${p}" = "_local---zi" ] && continue + [ "${p}" = "custom" ] && continue p="${p//---//}" - show_plugins+=( "$p" ) + show_plugins+=( "${p}" ) fi done _wanted show_plugins expl "-- Plugin --" compadd "$@" -a - show_plugins && ret=0 diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh index f78429cb..1ac19d0c 100755 --- a/lib/zsh/autoload.zsh +++ b/lib/zsh/autoload.zsh @@ -655,7 +655,7 @@ ZI[EXTENDED_GLOB]="" } ) if [[ $1 != -q ]] { - +zi-message "Compiling »»» ❮ ZI ❯ {…}" + +zi-message "{profile}Compiling »»»{rst} ❮ {happy}ZI{rst} ❯ {…}" } command rm -f ${ZI[BIN_DIR]}/*.zwc(DN) command rm -f ${ZI[BIN_DIR]}/lib/zsh/*.zwc(DN) @@ -666,7 +666,7 @@ ZI[EXTENDED_GLOB]="" zcompile -U ${ZI[BIN_DIR]}/lib/zsh/additional.zsh zcompile -U ${ZI[BIN_DIR]}/lib/zsh/git-process-output.zsh # Load for the current session - [[ $1 != -q ]] && +zi-message "Reloading »»» ❮ ZI ❯ for the current session{…}" + [[ $1 != -q ]] && +zi-message "{profile}Reloading »»»{rst} ❮ {happy}ZI{rst} ❯ {…}" source ${ZI[BIN_DIR]}/zi.zsh source ${ZI[BIN_DIR]}/lib/zsh/side.zsh source ${ZI[BIN_DIR]}/lib/zsh/install.zsh @@ -1657,7 +1657,7 @@ fi } # Reload ZI? if [[ $2 != restart ]] && (( ZI[mtime] + ZI[mtime-side] + ZI[mtime-install] + ZI[mtime-autoload] != sum )) { - +zi-message "{msg2}Detected ❮ ZI ❯ update in another session -" "{pre}reloading{msg2}{…}{rst}" + +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 @@ -1673,13 +1673,13 @@ fi integer retval if (( OPTS[opt_-p,--parallel] )) && [[ $1 = update ]] { (( !OPTS[opt_-q,--quiet] )) && \ - +zi-message '{info2}Parallel Update Starts Now{…}{rst}' + +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 "{msg2}The update took {obj}${SECONDS}{msg2} seconds{rst}" + +zi-message "{ok}The update took {num}${SECONDS}{ok} seconds{rst}" } return $retval } @@ -1689,7 +1689,7 @@ fi 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 "{info}Note:{rst} updating also unloaded snippets" + [[ $st != status && ${OPTS[opt_-q,--quiet]} != 1 && -n $snipps ]] && +zi-message "{note}Note:{rst} update includes unloaded snippets" 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= @@ -1703,9 +1703,9 @@ fi return } if [[ $st = status ]]; then - (( !OPTS[opt_-q,--quiet] )) && +zi-message "{info}Note:{rst} status done also for unloaded plugins" + (( !OPTS[opt_-q,--quiet] )) && +zi-message "{note}Note:{rst} status includes unloaded plugins" else - (( !OPTS[opt_-q,--quiet] )) && +zi-message "{info}Note:{rst} updating also unloaded plugins" + (( !OPTS[opt_-q,--quiet] )) && +zi-message "{note}Note:{rst} update includes unloaded plugins" fi ZI[first-plugin-mark]=init for repo in ${ZI[PLUGINS_DIR]}/*; do @@ -1737,18 +1737,18 @@ fi builtin print "\nStatus for plugin $REPLY" ( builtin cd -q "$repo"; command git status ) else - (( !OPTS[opt_-q,--quiet] )) && builtin print "Updating $REPLY" || builtin print -n . + (( !OPTS[opt_-q,--quiet] )) && +zi-message "Updating{ehi}:{rst} ${REPLY}" || builtin print -n . .zi-update-or-status update "$user" "$plugin" update_rc=$? [[ $update_rc -ne 0 ]] && { - +zi-message "{warn}Warning: {pid}${user}/${plugin} {warn}update returned {obj}$update_rc" + +zi-message "{warn}Warning: {pid}${user}/${plugin} {warn}update returned{ehi}: {num}${update_rc}" retval=$? } fi done .zi-compinit 1 1 &>/dev/null if (( !OPTS[opt_-q,--quiet] )) { - +zi-message "{msg2}The update took {obj2}${SECONDS}{msg2} seconds{rst}" + +zi-message "{ok}The update took {num}${SECONDS}{ok} seconds{rst}" } return "$retval" } # ]]] @@ -1843,7 +1843,7 @@ fi counter=0 PUAssocArray=() } elif (( counter == 1 && !OPTS[opt_-q,--quiet] )) { - +zi-message "{obj}Spawning the next{num}" "${OPTS[value]}{obj} concurrent update jobs" "({msg2}${tpe}{obj}){…}{rst}" + +zi-message "{info3}Spawning the next{opt} ${OPTS[value]}{info3} concurrent update jobs{ehi}: {var}${tpe}{rst} {…}" } } # ]]] # FUNCTION: .zi-show-zstatus [[[ @@ -1856,15 +1856,15 @@ fi local infoc="${ZI[col-info2]}" - +zi-message "Home directory: {file}${ZI[HOME_DIR]}{rst}" - +zi-message "Binary directory: {file}${ZI[BIN_DIR]}{rst}" - +zi-message "Plugin directory: {file}${ZI[PLUGINS_DIR]}{rst}" - +zi-message "Snippet directory: {file}${ZI[SNIPPETS_DIR]}{rst}" - +zi-message "Service directory: {file}${ZI[SERVICES_DIR]}{rst}" - +zi-message "Modules directory: {file}${ZI[ZMODULES_DIR]}{rst}" - +zi-message "Completions directory: {file}${ZI[COMPLETIONS_DIR]}{rst}" + +zi-message "{slight}Home directory{ehi}: {tab}{tab}{tab}{tab}{tab}{tab}{tab}{dir}${ZI[HOME_DIR]}{rst}" + +zi-message "{slight}Binary directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[BIN_DIR]}{rst}" + +zi-message "{slight}Plugin directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[PLUGINS_DIR]}{rst}" + +zi-message "{slight}Snippet directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SNIPPETS_DIR]}{rst}" + +zi-message "{slight}Service directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SERVICES_DIR]}{rst}" + +zi-message "{slight}Modules directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[ZMODULES_DIR]}{rst}" + +zi-message "{slight}Completions directory{ehi}:{tab}{dir}${ZI[COMPLETIONS_DIR]}{rst}" # Without _zlocal/zi - +zi-message "Loaded plugins: {num}$(( ${#ZI_REGISTERED_PLUGINS[@]} - 1 )){rst}" + +zi-message "{info}Loaded plugins{ehi}: {num}$(( ${#ZI_REGISTERED_PLUGINS[@]} - 1 )){rst}" # Count light-loaded plugins integer light=0 local s @@ -1872,43 +1872,43 @@ fi [[ "$s" = 1 ]] && (( light ++ )) done # Without _zlocal/zi - +zi-message "Light loaded: {num}$(( light - 1 )){rst}" + +zi-message "{info}Light loaded: {num}$(( light - 1 )){rst}" # Downloaded plugins, without _zlocal/zi, custom typeset -a plugins plugins=( "${ZI[PLUGINS_DIR]}"/*(DN) ) - +zi-message "Downloaded plugins: {num}$(( ${#plugins} - 1 )){rst}" + +zi-message "{info}Downloaded plugins: {num}$(( ${#plugins} - 1 )){rst}" + # Number of compiled plugins + typeset -a matches m + integer count=0 + matches=( ${ZI[PLUGINS_DIR]}/*/*.zwc(DN) ) + local cur_plugin="" uspl1 + for m in "${matches[@]}"; do + uspl1="${${m:h}:t}" + if [[ "$cur_plugin" != "$uspl1" ]]; then + (( count ++ )) + cur_plugin="$uspl1" + fi + done + +zi-message "{info}Compiled plugins: {num}$count{rst}" # Number of enabled completions, with _zlocal/zi typeset -a completions completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) ) - +zi-message "Enabled completions: {num}${#completions[@]}{rst}" + +zi-message "{info}Enabled completions: {num}${#completions[@]}{rst}" # Number of disabled completions, with _zlocal/zi completions=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) ) - +zi-message "Disabled completions: {num}${#completions[@]}{rst}" + +zi-message "{info}Disabled completions: {num}${#completions[@]}{rst}" # Number of completions existing in all plugins completions=( "${ZI[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/tests/*|/zsdoc/*|*.ps1)(DN) ) - +zi-message "Completions available overall: {num}${#completions[@]}{rst}" + +zi-message "{info}Completions available overall: {num}${#completions[@]}{rst}" # Enumerate snippets loaded # }, ${infoc}{rst}", j:, :, {msg}"$'\e[0m, +zi-message h - +zi-message -n "Snippets loaded: " + +zi-message -n "{info}Snippets loaded: " local sni for sni in ${(onv)ZI_SNIPPETS[@]}; do +zi-message -n "{url}${sni% <[^>]#>}{rst} ${(M)sni%<[^>]##>}, " done [[ -z $sni ]] && builtin print -n " " builtin print '\b\b ' - # Number of compiled plugins - typeset -a matches m - integer count=0 - matches=( ${ZI[PLUGINS_DIR]}/*/*.zwc(DN) ) - local cur_plugin="" uspl1 - for m in "${matches[@]}"; do - uspl1="${${m:h}:t}" - if [[ "$cur_plugin" != "$uspl1" ]]; then - (( count ++ )) - cur_plugin="$uspl1" - fi - done - +zi-message "Compiled plugins: {num}$count{rst}" } # ]]] # FUNCTION: .zi-show-times [[[ # Shows loading times of all loaded plugins. @@ -2038,10 +2038,10 @@ fi if [[ "$cur_plugin" != "$uspl1" ]]; then [[ -n "$cur_plugin" ]] && builtin print # newline .zi-any-colorify-as-uspl2 "$user" "$plugin" - builtin print -r -- "$REPLY:" + +zi-message "$REPLY:" cur_plugin="$uspl1" fi - builtin print "$file" + +zi-message "$file" done } # ]]] # FUNCTION: .zi-compile-uncompile-all [[[ @@ -2078,7 +2078,6 @@ fi # $2 - plugin (only when $1 - i.e. user - given) .zi-uncompile-plugin() { builtin setopt localoptions nullglob - .zi-any-to-user-plugin "$1" "$2" local user="${reply[-2]}" plugin="${reply[-1]}" silent="$3" # There are plugins having ".plugin.zsh" @@ -2092,12 +2091,12 @@ fi builtin print "not compiled" else .zi-any-colorify-as-uspl2 "$user" "$plugin" - builtin print -r -- "$REPLY not compiled" + +zi-message "$REPLY not compiled" fi return 1 fi for m in "${matches[@]}"; do - builtin print "Removing ${ZI[col-info]}${m:t}${ZI[col-rst]}" + +zi-message "Removing {info}${m:t}{rst}" command rm -f "$m" done } # ]]] @@ -2848,7 +2847,7 @@ EOF for i in "${ZI_STRESS_TEST_OPTIONS[@]}"; do builtin setopt "$i" builtin print -n "Stress-testing ${fname:t} for option $i " - zcompile -UR "$fname" 2>/dev/null && { + zcompile -UR "${fname}" 2>/dev/null && { builtin print "[${ZI[col-success]}Success${ZI[col-rst]}]" } || { builtin print "[${ZI[col-failure]}Fail${ZI[col-rst]}]" @@ -2857,7 +2856,7 @@ EOF done ) command rm -f "${fname}.zwc" - (( compiled )) && zcompile -U "$fname" + (( compiled )) && zcompile -U "${fname}" } # ]]] # FUNCTION: .zi-list-compdef-replay [[[ # Shows recorded compdefs (called by plugins loaded earlier). Plugins often call `compdef' hoping @@ -2943,7 +2942,7 @@ EOF } } if [[ ${#output} = 0 ]]; then - builtin print -zr "# No Ice modifiers" + builtin print -zr "# No ice modifiers" else builtin print -zr "zi ice ${output[*]}; zi " fi @@ -3032,33 +3031,80 @@ EOF fi builtin print $EPOCHSECONDS >! "${ZI[ZMODULES_DIR]}/zpmod/COMPILED_AT" ) -} -# ]]] - -# -# Help function -# - +} # ]]] # FUNCTION: .zi-help [[[ # Shows usage information. # # User-action entry point. .zi-help() { - builtin print -r -- "${ZI[col-pname]}❮ ZI ❯ Usage${ZI[col-rst]}: -❯ analytics – Analytics -❯ control – Control options -❯ self-update – Self update and compile -❯ module help – Manage zpmod (binary Zsh module) -❯ compinit – Refresh completions -❯ cdreplay [-q] – Replay compdefs (run after compinit) -❯ cdclear [-q] – Clear compdef replay list -❯ env-whitelist [-v|-h] – Specify names or paterns of variables left unchanged during an unload -❯ bindkeys – Lists bindkeys -❯ man – Manual - -${ZI[col-info]}❮ ZI ❯ WIKI${ZI[col-rst]}: ${ZI[col-p]}https://z.digitalclouds.dev${ZI[col-rst]} - -${ZI[col-pname]}Available sub-commands${ZI[col-rst]}:" +# +zi-message "{hi}Welcome ${(%):-%n}" +if (( $+commands[clear] )) { clear; } +sleep 0.08 && +zi-message "{info}- {rst}❮ {happy}ZI{rst} ❯{info} Usage{ehi}:{rst}" +sleep 0.08 && +zi-message "❯ analytics - Statistics, benchmarks and information" +sleep 0.08 && +zi-message "❯ subcmds - Show subcommands registered by annex" +sleep 0.08 && +zi-message "❯ icemods - Show all registerted ice-modifiers" +sleep 0.08 && +zi-message "❯ self-update - Self update and compile" +sleep 0.08 && +zi-message "❯ compinit – Refresh completions" +sleep 0.08 && +zi-message "❯ cdreplay {opt}[-q]{rst} – Replay compdefs (run after compinit)" +sleep 0.08 && +zi-message "❯ cdclear {opt}[-q]{rst} – Clear compdef replay list" +sleep 0.08 && +zi-message "❯ env-whitelist {opt}[-v][-h]{rst} – Specify names or paterns of variables left unchanged during an unload" +sleep 0.08 && +zi-message "❯ snippet {opt}[-f] {p}[snippet]|{url}URL{rst} – Source local or remote file" +sleep 0.08 && +zi-message "❯ delete {opt}[--all][--clean] {p}[plugin]|{url}URL{rst} – Remove plugin or snippet from disk" +sleep 0.08 && +zi-message "❯ update {opt}[-L][-s][-v][-q][-r][-p] {p}[plugin]|{url}URL{rst} – Git update plugins or snippets" +sleep 0.08 && +zi-message "❯ load {opt}[-b] {p}[plugin]{rst} – Load plugin or absolute local path" +sleep 0.08 && +zi-message "❯ unload {opt}[-q] {p}[plugin]{rst} – Unload plugin" +sleep 0.08 && +zi-message "❯ light {opt}[-b] {p}[plugin]{rst}{msg} – Load plugins without reporting/tracking" +sleep 0.08 && +zi-message "❯ add-fpath {opt}[-f] {p}[plugin]|{dir}DIR{rst} – Append directory to \$fpath; use -f to prepend instead" +sleep 0.08 && +zi-message "❯ run {opt}[-l] {p}[plugin]|{cmd}CMD{rst} – Runs command in the given plugin's directory" +sleep 0.08 && +zi-message "❯ compile {opt}[--all] {p}[plugin]{rst} – Compile plugins" +sleep 0.08 && +zi-message "❯ uncompile {opt}[--all] {p}[plugin]{rst} – Remove compiled version of plugins." +sleep 0.08 && +zi-message "❯ cdisable {p}[name]{rst} – Disable completion" +sleep 0.08 && +zi-message "❯ cenable {p}[name]{rst} – Enable completion" +sleep 0.08 && +zi-message "❯ creinstall {p}[plugin]{rst} – Install completions for plugin, can also receive absolute local path" +sleep 0.08 && +zi-message "❯ cuninstall {p}[plugin]{rst} – Uninstall completions for plugin" +sleep 0.08 && +zi-message "❯ recall {p}[plugin]|{url}URL{rst} – Fetch saved ice modifiers and construct command" +sleep 0.08 && +zi-message "❯ srv {p}[service]|{cmd}CMD{rst} – Control a service: stop,start,restart,next,quit" +sleep 0.08 && +zi-message "❯ create {p}[plugin]{rst} – Create plugin" +sleep 0.08 && +zi-message "❯ edit {p}[plugin]{rst} – Edit plugin's file with \$EDITOR{nl}" +sleep 0.08 && +zi-message "{info}- {rst}❮ {happy}ZI{rst} ❯ {info}WIKI{ehi}: {url}https://z.digitalclouds.dev{rst}{nl}" +} # ]]] +# FUNCTION: .zi-analytics-menu [[[ +# Statistics, benchmarks and information. +# +# User-action entry point. +.zi-analytics-menu() { +if (( $+commands[clear] )) { clear; } +sleep 0.08 && +zi-message "{info}- {rst}❮ {happy}ZI{rst} ❯{info} Analytics{ehi}:{rst}" +sleep 0.08 && +zi-message "❯ compiled – List plugins that are compiled" +sleep 0.08 && +zi-message "❯ zstatus – Overall status" +sleep 0.08 && +zi-message "❯ module help – Manage zpmod" +sleep 0.08 && +zi-message "❯ dtrace|dstart – Start tracking what's going on in session" +sleep 0.08 && +zi-message "❯ dstop – Stop tracking what's going on in session" +sleep 0.08 && +zi-message "❯ dreport – Report what was going on in session" +sleep 0.08 && +zi-message "❯ dunload – Revert changes recorded between dstart and dstop" +sleep 0.08 && +zi-message "❯ dclear – Clear report of what was going on in session" +sleep 0.08 && +zi-message "❯ bindkeys – List bindkeys" +sleep 0.08 && +zi-message "❯ clist|completions – List completions in use" +sleep 0.08 && +zi-message "❯ cdlist – Show compdef replay list" +sleep 0.08 && +zi-message "❯ csearch – Search for available completions from any plugin" +sleep 0.08 && +zi-message "❯ man – Show manual" +sleep 0.08 && +zi-message "❯ ls – List snippets in formatted and colorized manner" +sleep 0.08 && +zi-message "❯ status {opt}[--all] {p}[plugin]|{url}URL{rst} – Git status for plugin or svn status for snippet" +sleep 0.08 && +zi-message "❯ report {opt}[--all] {p}[plugin]{rst} – Show reports" +sleep 0.08 && +zi-message "❯ times {opt}[-s][-m][-a]{rst} – Statistics on plugin load times, sorted in order of loading" +sleep 0.08 && +zi-message "❯ glance {p}[plugin]{rst} – Look at plugin's source" +sleep 0.08 && +zi-message "❯ stress {p}[plugin]{rst} – Test plugin for compatibility with set of options" +sleep 0.08 && +zi-message "❯ changes {p}[plugin]{rst} – View plugin's git log" +sleep 0.08 && +zi-message "❯ recently {p}[time]{rst} – Show plugins that changed recently (e.g.: 1 month 2 days)" +sleep 0.08 && +zi-message "❯ cd {p}[plugin]{rst} – Enter plugin's directory; also support snippets, if feed with URL" +sleep 0.08 && +zi-message "❯ loaded|lists {p}[keyword]{rst} – Show what plugins are loaded (filter: keyword)" +} # ]]] +# FUNCTION: .zi-registered-subcommands [[[ +# Shows subcommands registered by annex. +# +# User-action entry point. +.zi-registered-subcommands() { + +zi-message "{info}- Registered subcommands{ehi}:{rst}" integer idx local type key local -a arr @@ -3068,64 +3114,18 @@ ${ZI[col-pname]}Available sub-commands${ZI[col-rst]}:" [[ -z "$key" || "$key" != "z-annex $type:"* ]] && continue arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" ) (( ${+functions[${arr[6]}]} )) && { "${arr[6]}"; ((1)); } || \ - { builtin print -rl -- "(Couldn't find the help-handler \`${arr[6]}' of the z-annex \`${arr[3]}')"; } + { +zi-message -l "(Couldn't find the help-handler \`${arr[6]}' of the z-annex \`${arr[3]}')"; } done done -local -a ice_order -ice_order=( ${${(s.|.)ZI[ice-list]}:#teleid} ${(@)${(@)${(@Akons:|:u)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}:#(.*|dynamic-unscope)} ) - builtin print -r -- "${ZI[col-pname]}Available ice-modifiers${ZI[col-rst]}:" - +zi-message "${ice_order[*]}" } # ]]] -# FUNCTION: .zi-analytics-menu [[[ -# Shows ❮ ZI ❯ analytics. +# FUNCTION: .zi-registered-ice-mods [[[ +# Shows all registerted ice-modifiers. +# Internal and registered by annex. # # User-action entry point. -.zi-analytics-menu() { - builtin print -r -- "${ZI[col-pname]}❮ ZI ❯ Analytics${ZI[col-rst]}: -❯ cd ${ZI[col-p]}[plugin]${ZI[col-rst]} – Enter plugin's directory; also support snippets, if feed with URL -❯ status ${ZI[col-p]}[plugin]${ZI[col-rst]}|URL – Git status for plugin or svn status for snippet; – accepts --all -❯ report ${ZI[col-p]}[plugin]${ZI[col-rst]} – Show plugin's report; – accepts --all -❯ glance ${ZI[col-p]}[plugin]${ZI[col-rst]} – Look at plugin's source (pygmentize, {,source-}highlight) -❯ stress ${ZI[col-p]}[plugin]${ZI[col-rst]} – Test plugin for compatibility with set of options -❯ changes ${ZI[col-p]}[plugin]${ZI[col-rst]} – View plugin's git log -❯ recently ${ZI[col-info]}[time]${ZI[col-rst]} – Show plugins that changed recently, argument is e.g. 1 month 2 days -❯ times [-s] [-m] [-a] – Statistics on plugin load times, sorted in order of loading; -s – use seconds instead of milliseconds, -m – loading moments, -a – show both -❯ zstatus – Overall ❮ ZI ❯ status -❯ dtrace|dstart – Start tracking what's going on in session -❯ dstop – Stop tracking what's going on in session -❯ dreport – Report what was going on in session -❯ dunload – Revert changes recorded between dstart and dstop -❯ dclear – Clear report of what was going on in session -❯ loaded|list {keyword} – Show what plugins are loaded (filter with \'keyword') -❯ compiled – List plugins that are compiled -❯ clist|completions – List completions in use -❯ cdlist – Show compdef replay list -❯ csearch – Search for available completions from any plugin -❯ ls – List snippets in formatted and colorized manner" -} # ]]] -# FUNCTION: .zi-control-menu [[[ -# Shows control options. -# -# User-action entry point. -.zi-control-menu() { - builtin print -r -- "${ZI[col-pname]}❮ ZI ❯ Control${ZI[col-rst]}: -❯ update [-q] ${ZI[col-p]}[plugin]${ZI[col-rst]}|URL – Git update plugin or snippet; – accepts --all; -q/--quiet; -r/--reset causes to run 'git reset --hard' or 'svn revert' -❯ load ${ZI[col-p]}[plugin]${ZI[col-rst]} – Load plugin, can also receive absolute local path -❯ light [-b] ${ZI[col-p]}[plugin]${ZI[col-rst]} – Light plugin load, without reporting/tracking (-b – do track but bindkey-calls only) -❯ unload ${ZI[col-p]}[plugin]${ZI[col-rst]} – Unload plugin; -q – quiet -❯ snippet [-f] ${ZI[col-p]}{url}${ZI[col-rst]} – Source local or remote file (by direct URL), -f: force – don't use cache -❯ cdisable ${ZI[col-info]}[cname]${ZI[col-rst]} – Disable completion \`cname' -❯ cenable ${ZI[col-info]}[cname]${ZI[col-rst]} – Enable completion \`cname' -❯ delete ${ZI[col-p]}[plugin]${ZI[col-rst]}|URL – Remove plugin or snippet from disk (good to forget wrongly passed ice-mods); --all – purge, --clean – delete plugins and snippets that are not loaded -❯ create ${ZI[col-p]}[plugin]${ZI[col-rst]} – Create plugin (also together with Github repository) -❯ edit ${ZI[col-p]}[plugin]${ZI[col-rst]} – Edit plugin's file with \$EDITOR -❯ recall ${ZI[col-p]}[plugin]${ZI[col-rst]}|URL – Fetch saved ice modifiers and construct \`zi ice ...' command -❯ add-fpath ${ZI[col-p]}[plugin]${ZI[col-rst]}|DIR – Adds given plugin directory to \$fpath; second argument is appended to the directory path; use -f/--front to prepend instead. -❯ compile ${ZI[col-p]}[plugin]${ZI[col-rst]} – Compile plugin (or all plugins if --all passed) -❯ uncompile ${ZI[col-p]}[plugin]${ZI[col-rst]} – Remove compiled version of plugin (or of all plugins if --all passed) -❯ creinstall ${ZI[col-p]}[plugin]${ZI[col-rst]} – Install completions for plugin, can also receive absolute local path; -q – quiet -❯ cuninstall ${ZI[col-p]}[plugin]${ZI[col-rst]} – Uninstall completions for plugin -❯ run [-l] ${ZI[col-p]}[plugin]${ZI[col-rst]}|CMD – Runs command in the given plugin's directory; if -l given then plugin should be skipped – the option will cause the previous plugin to be reused -❯ ice ${ZI[col-pname]}${ZI[col-rst]} – Add ICE to next command, e.g. from\"gitlab\" -❯ srv ${ZI[col-p]}{service-id}${ZI[col-rst]}|CMD – Control a service, command can be: stop,start,restart,next,quit; \`next' moves the service to another Z Shell" +.zi-registered-ice-mods() { + +zi-message "{info}- Registered ice-modifiers{ehi}:{rst}" + local -a ice_order + ice_order=( ${${(s.|.)ZI[ice-list]}:#teleid} ${(@)${(@)${(@Akons:|:u)${ZI_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}:#(.*|dynamic-unscope)} ) + +zi-message "${ice_order[*]}" } # ]]] diff --git a/lib/zsh/git-process-output.zsh b/lib/zsh/git-process-output.zsh index 2977916b..2fc8c74e 100755 --- a/lib/zsh/git-process-output.zsh +++ b/lib/zsh/git-process-output.zsh @@ -11,16 +11,19 @@ if (( COLS < 10 )) { # Credit to molovo/revolver for the ideas typeset -ga progress_frames progress_frames=( - '0.2 ▹▹▹▹▹ ▸▹▹▹▹ ▹▸▹▹▹ ▹▹▸▹▹ ▹▹▹▸▹ ▹▹▹▹▸' - '0.2 ▁ ▃ ▄ ▅ ▆ ▇ ▆ ▅ ▄ ▃' - '0.2 ▏ ▎ ▍ ▌ ▋ ▊ ▉ ▊ ▋ ▌ ▍ ▎' - '0.2 ▖ ▘ ▝ ▗' - '0.2 ◢ ◣ ◤ ◥' - '0.2 ▌ ▀ ▐ ▄' - '0.2 ✶ ✸ ✹ ✺ ✹ ✷' + '0.08 ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧ ⠇ ⠏' + '0.08 ⣾ ⣽ ⣻ ⢿ ⡿ ⣟ ⣯ ⣷' + '0.08 ⢹ ⢺ ⢼ ⣸ ⣇ ⡧ ⡗ ⡏' +# '0.2 ▹▹▹▹▹ ▸▹▹▹▹ ▹▸▹▹▹ ▹▹▸▹▹ ▹▹▹▸▹ ▹▹▹▹▸' +# '0.2 ▁ ▃ ▄ ▅ ▆ ▇ ▆ ▅ ▄ ▃' +# '0.2 ▏ ▎ ▍ ▌ ▋ ▊ ▉ ▊ ▋ ▌ ▍ ▎' +# '0.2 ▖ ▘ ▝ ▗' +# '0.2 ◢ ◣ ◤ ◥' +# '0.2 ▌ ▀ ▐ ▄' +# '0.2 ✶ ✸ ✹ ✺ ✹ ✷' ) -integer -g progress_style=$(( RANDOM % 7 + 1 )) cur_frame=1 +integer -g progress_style=$(( RANDOM % 2 + 1 )) cur_frame=1 typeset -F SECONDS=0 last_time=0 # Alpine Linux doesn't have tput; FreeBSD and Dragonfly BSD have termcap @@ -37,9 +40,7 @@ if whence tput &> /dev/null; then fi if (( $+ZI_CNORM )); then - trap $ZI_CNORM EXIT - trap $ZI_CNORM INT - trap $ZI_CNORM TERM + trap $ZI_CNORM EXIT INT TERM fi local first=1 @@ -48,8 +49,7 @@ local first=1 timeline() { local sp='▚▞'; sp="${sp:$2%2:1}" # Maximal width is 24 characters - local bar="$(print -f "%.$2s█%0$(($3-$2-1))s" "████████████████████████" "")" - + local bar="$(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] )) { @@ -58,7 +58,7 @@ timeline() { last_time=$SECONDS } print -nr -- ${frames_splitted[cur_frame+1]}" " - print -nPr "%F{183}" + print -nPr "%F{165}" print -f "%s %s" "${bar// /░}" "" print -nPr "%f" } @@ -68,9 +68,9 @@ timeline() { # $4 - receiving percentage # $5 - resolving percentage print_my_line() { - local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}" - [[ -n "${4#...}" && -z "${5#...}" ]] && col3="%F{81}" - [[ -n "${5#...}" ]] && col4="%F{81}" + local col="%F{200}" col3="%F{200}" col4="%F{200}" col5="%F{200}" + [[ -n "${4#...}" && -z "${5#...}" ]] && col3="%F{201}" + [[ -n "${5#...}" ]] && col4="%F{201}" if (( COLS >= 70 )) { print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3${${4:#...}:+, ${col3}REC%f: $4%}${${5:#...}:+, ${col4}RES%f: $5%} " } elif (( COLS >= 60 )) { @@ -82,10 +82,10 @@ print_my_line() { } print_my_line_compress() { - local col="%F{155}" col3="%F{155}" col4="%F{155}" col5="%F{155}" - [[ -n "${4#...}" && -z "${5#...}" && -z "${6#...}" ]] && col3="%F{81}" - [[ -n "${5#...}" && -z "${6#...}" ]] && col4="%F{81}" - [[ -n "${6#...}" ]] && col5="%F{81}" + local col="%F{201}" col3="%F{201}" col4="%F{201}" col5="%F{201}" + [[ -n "${4#...}" && -z "${5#...}" && -z "${6#...}" ]] && col3="%F{201}" + [[ -n "${5#...}" && -z "${6#...}" ]] && col4="%F{201}" + [[ -n "${6#...}" ]] && col5="%F{201}" if (( COLS >= 80 )) { print -Pnr -- "${col}OBJ%f: $1, ${col}PACK%f: $2/$3, ${col3}COMPR%f: $4%%${${5:#...}:+, ${col4}REC%f: $5%%}${${6:#...}:+, ${col5}RES%f: $6%%} " } elif (( COLS >= 65 )) { @@ -111,10 +111,10 @@ if [[ -n $TERM ]] { while read -r line; do (( ++ loop_count )) if [[ "$line" = "Cloning into"* ]]; then - print; print $line + print $line continue elif [[ "$line" = (#i)*user*name* || "$line" = (#i)*password* ]]; then - print; print $line + print $line continue elif [[ "$line" = remote:*~*(Counting|Total|Compressing|Enumerating)* || "$line" = fatal:* ]]; then print $line @@ -156,17 +156,17 @@ while read -r line; do timeline "" $pr 11 if (( have_5_compress )); then print_my_line_compress "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \ - "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \ - "${${${(M)have_2_total:#1}:+$total_2}:-0}" \ - "${${${(M)have_5_compress:#1}:+$compress_5}:-...}" \ - "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \ - "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}" + "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \ + "${${${(M)have_2_total:#1}:+$total_2}:-0}" \ + "${${${(M)have_5_compress:#1}:+$compress_5}:-...}" \ + "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \ + "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}" else print_my_line "${${${(M)have_1_counting:#1}:+$counting_1}:-...}" \ - "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \ - "${${${(M)have_2_total:#1}:+$total_2}:-0}" \ - "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \ - "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}" + "${${${(M)have_2_total:#1}:+$total_packed_2}:-0}" \ + "${${${(M)have_2_total:#1}:+$total_2}:-0}" \ + "${${${(M)have_3_receiving:#1}:+$receiving_3}:-...}" \ + "${${${(M)have_4_deltas:#1}:+$deltas_4}:-...}" fi fi done diff --git a/lib/zsh/install.zsh b/lib/zsh/install.zsh index fb5fb55b..00a9795f 100755 --- a/lib/zsh/install.zsh +++ b/lib/zsh/install.zsh @@ -332,7 +332,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col .zi-any-colorify-as-uspl2 "$user" "$plugin" local pid_hl='{pid}' id_msg_part=" (at label{ehi}:{rst} {id-as}$id_as{rst}{…})" (( $+ICE[pack] )) && local infix_m="({b}{ice}pack{apo}''{rst}) " - +zi-message "{nl}Downloading $infix_m{pid}$user${user:+/}$plugin{…}${${${id_as:#$user/$plugin}}:+$id_msg_part}" + +zi-message "{nl}Downloading{ehi}:{rst} $infix_m{pid}$user${user:+/}$plugin{…}${${${id_as:#$user/$plugin}}:+$id_msg_part}" } local site @@ -811,7 +811,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col first=${reply[-1]} local fname=${first#$pdir_path/} - +zi-message -n "{note}Note:{rst} Compiling{ehi}:{rst} {b}{file}$fname{rst}{…}" + +zi-message -n "Compiling{ehi}:{rst} {b}{file}$fname{rst}{…}" if [[ -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} ]] { () { builtin emulate -LR zsh -o extendedglob @@ -819,7 +819,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col +zi-message "{msg2}Warning:{rst} Compilation failed. Don't worry, the plugin will work also without compilation." +zi-message "{msg2}Warning:{rst} Consider submitting an error report to ❮ ZI ❯ or to the plugin's author." } else { - +zi-message " {ok}OK{rst}." + +zi-message " {info}✔{rst}" } # Try to catch possible additional file zcompile -U "${${first%.plugin.zsh}%.zsh-theme}.zsh" 2>/dev/null diff --git a/zi.zsh b/zi.zsh index 84da09d3..152e0106 100755 --- a/zi.zsh +++ b/zi.zsh @@ -2128,7 +2128,7 @@ zi() { unload "-h|--help|-q|--quiet" cdclear "-h|--help|-q|--quiet" cdreplay "-h|--help|-q|--quiet" - times "-h|--help|-m|-s" + times "-h|--help|-m|-s|-a" light "-h|--help|-b" snippet "-h|--help|-f|--force|--command|-x" ) @@ -2146,11 +2146,7 @@ zi() { reply=( ${ZI_EXTS[(I)z-annex subcommand:*]} ) - [[ -n $1 && $1 != (-h|--help|help|analytics|control|man|self-update|times|zstatus|load|light|unload|snippet|ls|ice|\ -update|status|report|delete|loaded|list|cd|create|edit|glance|stress|changes|recently|clist|completions|cclear|\ -cdisable|cenable|creinstall|cuninstall|csearch|compinit|dtrace|dstart|dstop|dunload|dreport|dclear|compile|uncompile|\ -compiled|cdlist|cdreplay|cdclear|srv|recall|env-whitelist|bindkeys|module|add-fpath|run\ -${reply:+|${(~j:|:)"${reply[@]#z-annex subcommand:}"}}) || $1 = (load|light|snippet) ]] && { + [[ -n $1 && $1 != (-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${reply:+|${(~j:|:)"${reply[@]#z-annex subcommand:}"}}) || $1 = (load|light|snippet) ]] && { integer ___error if [[ $1 = (load|light|snippet) ]] { integer ___is_snippet @@ -2604,8 +2600,11 @@ ${reply:+|${(~j:|:)"${reply[@]#z-annex subcommand:}"}}) || $1 = (load|light|snip shift .zi-recently "$@"; ___retval=$? ;; - (control) - .zi-control-menu + (subcmds) + .zi-registered-subcommands + ;; + (icemods) + .zi-registered-ice-mods ;; (analytics) .zi-analytics-menu From fd5fa830a117f9305d2c9b70fc443830fcac7a6f Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Sun, 29 May 2022 06:23:06 +0100 Subject: [PATCH 2/9] fix(escape variable) --- lib/_zi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_zi b/lib/_zi index baa155c2..80a55e41 100755 --- a/lib/_zi +++ b/lib/_zi @@ -61,7 +61,7 @@ commands=( module:"Manage binary Zsh module, see 'zi module help' for more info" 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" + add-fpath:"Add plugin folder to \$fpath" ) _arguments -C '1: :->command' '*: :->argument' && ret=0 From 0eea9814f8d2420dcb9c500028e447066d068738 Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Sun, 29 May 2022 06:44:26 +0100 Subject: [PATCH 3/9] style(zstatus output) --- lib/zsh/autoload.zsh | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh index 1ac19d0c..4d3179eb 100755 --- a/lib/zsh/autoload.zsh +++ b/lib/zsh/autoload.zsh @@ -1856,12 +1856,12 @@ fi local infoc="${ZI[col-info2]}" - +zi-message "{slight}Home directory{ehi}: {tab}{tab}{tab}{tab}{tab}{tab}{tab}{dir}${ZI[HOME_DIR]}{rst}" - +zi-message "{slight}Binary directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[BIN_DIR]}{rst}" - +zi-message "{slight}Plugin directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[PLUGINS_DIR]}{rst}" - +zi-message "{slight}Snippet directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SNIPPETS_DIR]}{rst}" - +zi-message "{slight}Service directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SERVICES_DIR]}{rst}" - +zi-message "{slight}Modules directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[ZMODULES_DIR]}{rst}" + +zi-message "{slight}Home directory{ehi}: {tab}{tab}{tab}{tab}{tab}{tab}{tab}{dir}${ZI[HOME_DIR]}{rst}" + +zi-message "{slight}Binary directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[BIN_DIR]}{rst}" + +zi-message "{slight}Plugin directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[PLUGINS_DIR]}{rst}" + +zi-message "{slight}Snippet directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SNIPPETS_DIR]}{rst}" + +zi-message "{slight}Service directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SERVICES_DIR]}{rst}" + +zi-message "{slight}Modules directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[ZMODULES_DIR]}{rst}" +zi-message "{slight}Completions directory{ehi}:{tab}{dir}${ZI[COMPLETIONS_DIR]}{rst}" # Without _zlocal/zi +zi-message "{info}Loaded plugins{ehi}: {num}$(( ${#ZI_REGISTERED_PLUGINS[@]} - 1 )){rst}" @@ -1872,11 +1872,11 @@ fi [[ "$s" = 1 ]] && (( light ++ )) done # Without _zlocal/zi - +zi-message "{info}Light loaded: {num}$(( light - 1 )){rst}" + +zi-message "{info}Light loaded{ehi}: {num}$(( light - 1 )){rst}" # Downloaded plugins, without _zlocal/zi, custom typeset -a plugins plugins=( "${ZI[PLUGINS_DIR]}"/*(DN) ) - +zi-message "{info}Downloaded plugins: {num}$(( ${#plugins} - 1 )){rst}" + +zi-message "{info}Downloaded plugins{ehi}: {num}$(( ${#plugins} - 1 )){rst}" # Number of compiled plugins typeset -a matches m integer count=0 @@ -1889,20 +1889,20 @@ fi cur_plugin="$uspl1" fi done - +zi-message "{info}Compiled plugins: {num}$count{rst}" + +zi-message "{info}Compiled plugins{ehi}: {num}$count{rst}" # Number of enabled completions, with _zlocal/zi typeset -a completions completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc(DN) ) - +zi-message "{info}Enabled completions: {num}${#completions[@]}{rst}" + +zi-message "{info}Enabled completions{ehi}: {num}${#completions[@]}{rst}" # Number of disabled completions, with _zlocal/zi completions=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) ) - +zi-message "{info}Disabled completions: {num}${#completions[@]}{rst}" + +zi-message "{info}Disabled completions{ehi}: {num}${#completions[@]}{rst}" # Number of completions existing in all plugins completions=( "${ZI[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/tests/*|/zsdoc/*|*.ps1)(DN) ) - +zi-message "{info}Completions available overall: {num}${#completions[@]}{rst}" + +zi-message "{info}Completions available overall{ehi}: {num}${#completions[@]}{rst}" # Enumerate snippets loaded # }, ${infoc}{rst}", j:, :, {msg}"$'\e[0m, +zi-message h - +zi-message -n "{info}Snippets loaded: " + +zi-message -n "{info}Snippets loaded{ehi}: " local sni for sni in ${(onv)ZI_SNIPPETS[@]}; do +zi-message -n "{url}${sni% <[^>]#>}{rst} ${(M)sni%<[^>]##>}, " @@ -2170,7 +2170,7 @@ fi [[ "${#unpacked[1]}" -gt "$longest" ]] && longest="${#unpacked[1]}" done for c in "${packs[@]}"; do - unpacked=( "${(Q@)${(z@)c}}" ) # TODO: #112 ${(Q)${(z@)c}[@]} ? + unpacked=( "${(Q)${(z@)c}[@]}" ) .zi-any-colorify-as-uspl2 "$unpacked[2]" builtin print -n "${(r:longest+1:: :)unpacked[1]} $REPLY" @@ -2222,10 +2222,10 @@ fi [[ ! -f "$cpath" ]] && stray=1 fi if (( unknown == 1 || stray == 1 )); then - builtin print -n "Removing completion: ${(r:longest+1:: :)c} $REPLY" - (( disabled )) && builtin print -n " ${ZI[col-error]}[disabled]${ZI[col-rst]}" - (( unknown )) && builtin print -n " ${ZI[col-error]}[unknown file]${ZI[col-rst]}" - (( stray )) && builtin print -n " ${ZI[col-error]}[stray]${ZI[col-rst]}" + +zi-message -n "Removing completion{ehi}:{rst} ${(r:longest+1:: :)c} $REPLY" + (( disabled )) && +zi-message -n " {error}[disabled]{col-rst]}" + (( unknown )) && +zi-message -n " {error}[unknown file]{rst}" + (( stray )) && +zi-message -n " {error}[stray]{rst}" builtin print command rm -f "$cpath" fi From 2b9e05b14c8e2591b4101b8b24d45c6267953161 Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Sun, 29 May 2022 07:15:57 +0100 Subject: [PATCH 4/9] style(zstatus: add /home/sall/.zi/polaris) --- lib/zsh/autoload.zsh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh index 4d3179eb..69430f76 100755 --- a/lib/zsh/autoload.zsh +++ b/lib/zsh/autoload.zsh @@ -1855,14 +1855,15 @@ fi builtin setopt localoptions nullglob extendedglob nokshglob noksharrays local infoc="${ZI[col-info2]}" - - +zi-message "{slight}Home directory{ehi}: {tab}{tab}{tab}{tab}{tab}{tab}{tab}{dir}${ZI[HOME_DIR]}{rst}" - +zi-message "{slight}Binary directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[BIN_DIR]}{rst}" - +zi-message "{slight}Plugin directory{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[PLUGINS_DIR]}{rst}" - +zi-message "{slight}Snippet directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SNIPPETS_DIR]}{rst}" - +zi-message "{slight}Service directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SERVICES_DIR]}{rst}" - +zi-message "{slight}Modules directory{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[ZMODULES_DIR]}{rst}" - +zi-message "{slight}Completions directory{ehi}:{tab}{dir}${ZI[COMPLETIONS_DIR]}{rst}" + +zi-message "{info}Directories set{ehi}: " + +zi-message "{msg}Home{ehi}: {tab}{tab}{tab}{tab}{tab}{tab}{tab}{dir}${ZI[HOME_DIR]}{rst}" + +zi-message "{msg}Binary{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[BIN_DIR]}{rst}" + +zi-message "{msg}Plugin{ehi}: {tab}{tab}{tab}{tab}{tab}{dir}${ZI[PLUGINS_DIR]}{rst}" + +zi-message "{msg}Snippet{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SNIPPETS_DIR]}{rst}" + +zi-message "{msg}Service{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[SERVICES_DIR]}{rst}" + +zi-message "{msg}Modules{ehi}: {tab}{tab}{tab}{tab}{dir}${ZI[ZMODULES_DIR]}{rst}" + +zi-message "{msg}User-land{ehi}: {tab}{tab}{dir}${ZPFX}{rst}" + +zi-message "{msg}Completions{ehi}:{tab}{dir}${ZI[COMPLETIONS_DIR]}{rst}" # Without _zlocal/zi +zi-message "{info}Loaded plugins{ehi}: {num}$(( ${#ZI_REGISTERED_PLUGINS[@]} - 1 )){rst}" # Count light-loaded plugins @@ -1898,11 +1899,11 @@ fi completions=( "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc(DN) ) +zi-message "{info}Disabled completions{ehi}: {num}${#completions[@]}{rst}" # Number of completions existing in all plugins - completions=( "${ZI[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/tests/*|/zsdoc/*|*.ps1)(DN) ) + completions=( "${ZI[PLUGINS_DIR]}"/*/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/test*|/zsdoc/*|*.ps1)(DN) ) +zi-message "{info}Completions available overall{ehi}: {num}${#completions[@]}{rst}" # Enumerate snippets loaded # }, ${infoc}{rst}", j:, :, {msg}"$'\e[0m, +zi-message h - +zi-message -n "{info}Snippets loaded{ehi}: " + +zi-message -n "{info}Snippets loaded{ehi}: {nl}" local sni for sni in ${(onv)ZI_SNIPPETS[@]}; do +zi-message -n "{url}${sni% <[^>]#>}{rst} ${(M)sni%<[^>]##>}, " From d39820deb2b3c380961ef5a77244c1146ff237b5 Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Fri, 3 Jun 2022 18:36:54 +0100 Subject: [PATCH 5/9] workspace(maintenance) --- lib/zsh/autoload.zsh | 14 +++++++------- lib/zsh/install.zsh | 43 ++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh index 69430f76..dc2324bf 100755 --- a/lib/zsh/autoload.zsh +++ b/lib/zsh/autoload.zsh @@ -2690,10 +2690,10 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\"" # Copyright (c) $year $user_name # According to the Zsh Plugin Standard: -# https://github.com/z-shell/zi/wiki/Zsh-Plugin-Standard +# https://z.digitalclouds.dev/community/zsh_plugin_standard -0=\${\${ZERO:-\${0:#\$ZSH_ARGZERO}}:-\${(%):-%N}} -0=\${\${(M)0:#/*}:-\$PWD/\$0} +0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}" +0="${${(M)0:#/*}:-$PWD/$0}" # Then \${0:h} to get plugin's directory @@ -2757,7 +2757,7 @@ EOF .zi-exists-physically-message "$user" "$plugin" || return 1 .zi-first "$1" "$2" || { - builtin print "${ZI[col-error]}No source file found, cannot glance${ZI[col-rst]}" + +zi-message "{error}No source file found, cannot glance{rst}" return 1 } local fname="${reply[-1]}" @@ -2766,17 +2766,17 @@ EOF [[ "$TERM" = xterm* || "$TERM" = "screen" ]] && has_256_colors=1 { if (( ${+commands[pygmentize]} )); then - builtin print "Glancing with ${ZI[col-info]}pygmentize${ZI[col-rst]}" + +zi-message "Glancing with {info}pygmentize{rst}" pygmentize -l bash -g "$fname" elif (( ${+commands[highlight]} )); then - builtin print "Glancing with ${ZI[col-info]}highlight${ZI[col-rst]}" + +zi-message "Glancing with {info}highlight{rst}" if (( has_256_colors )); then highlight -q --force -S sh -O xterm256 "$fname" else highlight -q --force -S sh -O ansi "$fname" fi elif (( ${+commands[source-highlight]} )); then - builtin print "Glancing with ${ZI[col-info]}source-highlight${ZI[col-rst]}" + +zi-message "Glancing with {info}source-highlight{rst}" source-highlight -fesc --failsafe -s zsh -o STDOUT -i "$fname" else cat "$fname" diff --git a/lib/zsh/install.zsh b/lib/zsh/install.zsh index 00a9795f..ddee0a3f 100755 --- a/lib/zsh/install.zsh +++ b/lib/zsh/install.zsh @@ -1475,16 +1475,16 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # $1 - url # $2 - file ziextract() { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} setopt extendedglob typesetsilent noshortloops # warncreateglobal - if (( $+commands[file] != 1 )) { +zi-message "{error}ziextract:{msg2} The {obj}file{msg2} command is required for recognizing the type of data to be processed.{rst}" + if (( $+commands[file] != 1 )) { +zi-message "{annex}ziextract{ehi}:{error} The {cmd}file{error} command is required for recognizing the type of data to be processed{rst}" return 1 } local -a opt_move opt_move2 opt_norm opt_auto opt_nobkp zparseopts -D -E -move=opt_move -move2=opt_move2 -norm=opt_norm -auto=opt_auto -nobkp=opt_nobkp || \ - { +zi-message "{error}ziextract:{msg2} Incorrect options given to" "\`{pre}ziextract{msg2}' (available are: {meta}--auto{msg2}," \ - "{meta}--move{msg2}, {meta}--move2{msg2}, {meta}--norm{msg2}," "{meta}--nobkp{msg2}).{rst}"; return 1; } + { +zi-message "{annex}ziextract{ehi}:{error} Incorrect options given to" "\`{annex}ziextract{error}' {rst}({p}available are{ehi}: {opt}--auto{msg2}," \ + "{opt}--move{msg2}, {opt}--move2{msg2}, {opt}--norm{msg2}, {opt}--nobkp{rst})"; return 1; } local file="$1" ext="$2" integer move=${${${(M)${#opt_move}:#0}:+0}:-1} \ @@ -1515,7 +1515,7 @@ ziextract() { type=${(L)desc/(#b)(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) */$match[2]} if [[ $type = (zip|rar|xz|7-zip|gzip|bzip2|tar|exe|pe32) ]] { (( !OPTS[opt_-q,--quiet] )) && \ - +zi-message "{pre}ziextract:{info2} Note:{rst}" "detected a {meta}$type{rst} archive in the file" "{file}$fname{rst}." + +zi-message "{annex}ziextract{ehi}:{note} Detected a {obj2}$type{note} archive in the file {file}$fname{rst}" ziextract "$fname" "$type" $opt_move $opt_move2 $opt_norm --norm ${${${#archives}:#1}:+--nobkp} integer iret_val=$? ret_val+=iret_val @@ -1538,7 +1538,7 @@ ziextract() { # TODO: #115 If multiple archives are really in the archive, this might delete too soon… However, it's unusual case. [[ $fname != $infname && $norm -eq 0 ]] && command rm -f "$infname" (( !OPTS[opt_-q,--quiet] )) && \ - +zi-message "{pre}ziextract:{info2} Note:{rst}" "detected a {obj}${type2}{rst} archive in the" " file {file}${fname}{rst}." + +zi-message "{annex}ziextract{ehi}:{note} Detected a {obj2}${type2}{note} archive in the file {file}${fname}{rst}" ziextract "$fname" "$type2" $opt_move $opt_move2 $opt_norm ${${${#archives}:#1}:+--nobkp} ret_val+=$? stage2_processed+=( $fname ) @@ -1556,11 +1556,11 @@ ziextract() { } if [[ -z $file ]] { - +zi-message "{error}ziextract:{msg2} ERROR:{msg} argument" "needed (the file to extract) or the {meta}--auto{msg} option." + +zi-message "{annex}ziextract{ehi}:{error} Argument required for {file}file{error} to extract or the {opt}--auto{error} option{rst}" return 1 } if [[ ! -e $file ]] { - +zi-message "{error}ziextract:{msg2} ERROR:{msg}" "the file \`{meta}${file}{msg}' doesn't exist.{rst}" + +zi-message "{annex}ziextract{ehi}:{error} The {file}file{error} \`{pname}${file}{error}' does not exist{rst}" return 1 } if (( !nobkp )) { @@ -1571,7 +1571,7 @@ ziextract() { .zi-extract-wrapper() { local file="$1" fun="$2" retval - (( !OPTS[opt_-q,--quiet] )) && +zi-message "{pre}ziextract:{msg} Unpacking the files from: \`{obj}$file{msg}'{…}{rst}" + (( !OPTS[opt_-q,--quiet] )) && +zi-message "{annex}ziextract{ehi}:{rst} Unpacking the files from: \`{file}$file{rst}'{…}{rst}" $fun; retval=$? if (( retval == 0 )) { local -a files @@ -1581,9 +1581,7 @@ ziextract() { return $retval } - →zi-check() { (( ${+commands[$1]} )) || +zi-message "{error}ziextract:{msg2} Error:{msg} No command {data}$1{msg}," \ - "it is required to unpack {file}$2{rst}." - } + →zi-check() { (( ${+commands[$1]} )) || +zi-message "{annex}ziextract{ehi}:{error} No command {cmd}$1{msg2},{error} it is required to unpack {file}$2{rst}"; } case "${${ext:+.$ext}:-$file}" in ((#i)*.zip) @@ -1666,8 +1664,7 @@ ziextract() { command hdiutil detach $attached_vol if (( retval )) { - +zi-message "{error}ziextract:{msg2} WARNING:{msg} problem occurred when attempted to copy the files" \ - "from the mounted image: \`{obj}${file}{msg}'.{rst}" + +zi-message "{annex}ziextract{ehi}:{warn} Problem occurred when attempted to copy the files from the mounted image{ehi}:{rst} \`{file}${file}{rst}'" } return $retval } @@ -1688,11 +1685,11 @@ ziextract() { if [[ $(typeset -f + →zi-extract) == "→zi-extract" ]] { .zi-extract-wrapper "$file" →zi-extract || { - +zi-message -n "{error}ziextract:{msg2} WARNING:{msg} extraction of the archive \`{file}${file}{msg}' had problems" + +zi-message -n "{annex}ziextract{ehi}:{warn} Problem occurred while extracting \`{file}${file}{warn}'{rst}" local -a bfiles bfiles=( ._backup/*(DN) ) if (( ${#bfiles} && !nobkp )) { - +zi-message -n ", restoring the previous version of the plugin/snippet" + +zi-message -n ", restoring the previous version of the {pname}plugin{ehi}/{apo}snippet{rst}" command mv ._backup/*(DN) . 2>/dev/null } +zi-message ".{rst}" @@ -1718,21 +1715,21 @@ ziextract() { command chmod a+x "${execs[@]}" if (( !OPTS[opt_-q,--quiet] )) { if (( ${#execs} == 1 )); then - +zi-message "{pre}ziextract:{rst}" "Successfully extracted and assigned +x chmod to the file:" "\`{obj}${execs[1]}{rst}'." + +zi-message "{annex}ziextract{ehi}:{rst} Successfully extracted and assigned {b}{opt}+x{rst} chmod to the file{ehi}:{rst}" "\`{file}${execs[1]}{rst}'" else local sep="$ZI[col-rst],$ZI[col-obj] " if (( ${#execs} > 7 )) { - +zi-message "{pre}ziextract:{rst} Successfully" "extracted and marked executable the appropriate files" "({obj}${(pj:$sep:)${(@)execs[1,5]:t}},…{rst}) contained" \ - "in \`{file}$file{rst}'. All the extracted" "{obj}${#execs}{rst} executables are" "available in the {msg2}INSTALLED_EXECS{rst}" "array." + +zi-message "{annex}ziextract{ehi}:{rst} Successfully" "extracted and assigned {b}{opt}+x{rst} chmod to the files" "({obj2}${(pj:$sep:)${(@)execs[1,5]:t}},…{rst}) contained" \ + "in \`{file}$file{rst}'. All the extracted" "{obj2}${#execs}{rst} executables are available in the {var}INSTALLED_EXECS{rst} array" } else { - +zi-message "{pre}ziextract:{rst} Successfully" "extracted and marked executable the appropriate files" \ - "({obj}${(pj:$sep:)${execs[@]:t}}{rst}) contained" "in \`{file}$file{rst}'." + +zi-message "{annex}ziextract{ehi}:{rst} Successfully" "extracted and assigned {b}{opt}+x{rst} chmod to the files" \ + "({obj2}${(pj:$sep:)${execs[@]:t}}{rst}) contained" "in \`{file}$file{rst}'" } fi } } elif (( warning )) { - +zi-message "{pre}ziextract:" "{error}WARNING: {msg}didn't recognize the archive" "type of \`{obj}${file}{msg}'" \ - "${ext:+/ {obj2}${ext}{msg} }" "(no extraction has been done).%f%b" + +zi-message "{annex}ziextract{ehi}:" "{error}Did not recognize the archive" "type of \`{file}${file}{rst}'" \ + "${ext:+/ {obj2}${ext}{rst} }" "{rst}({p}no extraction has been done{rst})" } if (( move | move2 )) { From 7d58ddf2874df5d37d0fe8e7392005869bf46579 Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Fri, 3 Jun 2022 21:09:01 +0100 Subject: [PATCH 6/9] =?UTF-8?q?style(general):=20=F0=9F=8E=A8=20standard-r?= =?UTF-8?q?ecommended-options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://z.digitalclouds.dev/community/zsh_plugin_standard#standard-recommended-options Signed-off-by: Salvydas Lukosius --- lib/zsh/additional.zsh | 6 +-- lib/zsh/autoload.zsh | 77 +++++++++++++------------- lib/zsh/install.zsh | 119 ++++++++++++++++++++--------------------- lib/zsh/side.zsh | 16 +++--- zi.zsh | 88 +++++++++++++++--------------- 5 files changed, 154 insertions(+), 152 deletions(-) diff --git a/lib/zsh/additional.zsh b/lib/zsh/additional.zsh index 3ef1e6cc..d8f4b4b9 100755 --- a/lib/zsh/additional.zsh +++ b/lib/zsh/additional.zsh @@ -22,7 +22,7 @@ local ___data="$(<$1)" () { - builtin emulate -LR zsh -o extendedglob -o interactivecomments + builtin emulate -LR zsh -o extendedglob -o interactivecomments ${=${options[xtrace]:#off}:+-o xtrace} local ___subst ___tabspc=$'\t' for ___subst ( "${___substs[@]}" ) { ___ab=( "${(@)${(@)${(@s:->:)___subst}##[[:space:]]##}%%[[:space:]]##}" ) @@ -42,8 +42,8 @@ # $2 - mode - for plugin (light or load) # $3 - id - URL or plugin ID or alias name (from id-as'') .zi-service() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops local ___tpe="$1" ___mode="$2" ___id="$3" ___fle="${ZI[SERVICES_DIR]}/${ICE[service]}.lock" ___fd ___cmd ___tmp ___lckd ___strd=0 { builtin print -n >! "$___fle"; } 2>/dev/null 1>&2 [[ ! -e ${___fle:r}.fifo ]] && command mkfifo "${___fle:r}.fifo" 2>/dev/null 1>&2 diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh index dc2324bf..683bc2e2 100755 --- a/lib/zsh/autoload.zsh +++ b/lib/zsh/autoload.zsh @@ -419,7 +419,8 @@ ZI[EXTENDED_GLOB]="" # $1 - absolute path to completion file (in COMPLETIONS_DIR) # $2 - readlink command (":" or "readlink") .zi-get-completion-owner() { - setopt localoptions extendedglob nokshglob noksharrays noshwordsplit + builtin setopt localoptions extendedglob nokshglob noksharrays noshwordsplit + local cpath="$1" local readlink_cmd="$2" local in_plugin_path tmp @@ -453,7 +454,7 @@ ZI[EXTENDED_GLOB]="" # $2 - readlink command (":" or "readlink") .zi-get-completion-owner-uspl2col() { # "cpath" "readline_cmd" - .zi-get-completion-owner "$1" "$2" + .zi-get-completion-owner "${1}" "${2}" .zi-any-colorify-as-uspl2 "$REPLY" } # ]]] # FUNCTION: .zi-find-completions-of-plugin [[[ @@ -464,7 +465,7 @@ ZI[EXTENDED_GLOB]="" # $2 - plugin (only when $1 - i.e. user - given) .zi-find-completions-of-plugin() { builtin setopt localoptions nullglob extendedglob nokshglob noksharrays - .zi-any-to-user-plugin "$1" "$2" + .zi-any-to-user-plugin "${1}" "${2}" local user="${reply[-2]}" plugin="${reply[-1]}" uspl [[ "$user" = "%" ]] && uspl="${user}${plugin}" || uspl="${reply[-2]}${reply[-2]:+---}${reply[-1]//\//---}" reply=( "${ZI[PLUGINS_DIR]}/$uspl"/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|*.yml|*.ri|_zsh_highlight*|/zsdoc/*|*.ps1)(DN) ) @@ -538,7 +539,7 @@ ZI[EXTENDED_GLOB]="" # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - plugin (only when $1 - i.e. user - given) .zi-uninstall-completions() { - builtin emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops typeset -a completions symlinked backup_comps local c cfile bkpfile @@ -589,7 +590,7 @@ ZI[EXTENDED_GLOB]="" # FUNCTION: .zi-pager [[[ .zi-pager() { - setopt LOCAL_OPTIONS EQUALS + builtin setopt LOCAL_OPTIONS EQUALS # Quiet mode ? → no pager. if (( OPTS[opt_-n,--no-pager] )) { cat @@ -627,8 +628,8 @@ ZI[EXTENDED_GLOB]="" # # User-action entry point. .zi-self-update() { - emulate -LR zsh - setopt extendedglob typesetsilent warncreateglobal + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob typesetsilent warncreateglobal [[ $1 = -q ]] && +zi-message "{info2}Updating »»» ❮ ZI ❯ {…}{rst}" local nl=$'\n' escape=$'\x1b[' current_branch=$(command git rev-parse --abbrev-ref HEAD 2>/dev/null) local -a lines @@ -683,8 +684,8 @@ ZI[EXTENDED_GLOB]="" # # User-action entry point. .zi-show-registered-plugins() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops typeset -a filtered local keyword="$1" keyword="${keyword## ##}" @@ -759,9 +760,9 @@ tmp=( "${(z@)ZI_SICE[$uspl2]}" ) if [[ -n ${sice[ps-on-unload]} ]]; then (( quiet )) || builtin print -r "Running plugin's provided unload code: ${ZI[col-info]}${sice[ps-on-unload][1,50]}${sice[ps-on-unload][51]:+…}${ZI[col-rst]}" local ___oldcd="$PWD" - () { setopt localoptions noautopushd; builtin cd -q "$___dir"; } + () { builtin setopt localoptions noautopushd; builtin cd -q "$___dir"; } eval "${sice[ps-on-unload]}" - () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } + () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } fi # @@ -787,7 +788,7 @@ for sw in "${(Oa)string_widget[@]}"; do if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then if [[ -n "$sw_arr3" ]]; then () { - emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" } bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3" @@ -820,7 +821,7 @@ for sw in "${(Oa)string_widget[@]}"; do else if [[ -n "$sw_arr3" ]]; then () { - emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3" } bindkey "$sw_arr1" "$sw_arr3" @@ -938,7 +939,7 @@ local -a keys keys=( "${(@on)ZI[(I)TIME_<->_*]}" ) integer keys_size=${#keys} () { - setopt localoptions extendedglob noksharrays typesetsilent + builtin setopt localoptions extendedglob noksharrays typesetsilent typeset -a restore_widgets skip_delete local wid restore_widgets=( "${(z)ZI[WIDGETS_SAVED__$uspl2]}" ) @@ -1192,7 +1193,7 @@ fi # $1 - plugin spec (4 formats: user---plugin, user/plugin, user (+ plugin in $2), plugin) # $2 - plugin (only when $1 - i.e. user - given) .zi-show-report() { - setopt localoptions extendedglob warncreateglobal typesetsilent noksharrays + builtin setopt localoptions extendedglob warncreateglobal typesetsilent noksharrays .zi-any-to-user-plugin "$1" "$2" local user="${reply[-2]}" plugin="${reply[-1]}" uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" # Allow debug report @@ -1214,7 +1215,7 @@ fi ) # Print report gathered via shadowing () { - setopt localoptions extendedglob + builtin setopt localoptions extendedglob builtin print -rl -- "${(@)${(f@)ZI_REPORTS[$uspl2]}/(#b)(#s)([^[:space:]]##)([[:space:]]##)/${map[${match[1]}]:-${ZI[col-keyword]}}${match[1]}${ZI[col-rst]}${match[2]}}" } # Print report gathered via $functions-diffing @@ -1296,8 +1297,8 @@ fi # $3 - plugin (only when $1 - i.e. user - given) .zi-update-or-status() { # Set the localtraps option. - emulate -LR zsh - setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops local -a arr ZI[first-plugin-mark]=${${ZI[first-plugin-mark]:#init}:-1} ZI[-r/--reset-opt-hook-has-been-run]=0 @@ -1644,8 +1645,8 @@ fi # # User-action entry point. .zi-update-or-status-all() { - emulate -LR zsh - setopt extendedglob nullglob warncreateglobal typesetsilent noshortloops + 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' @@ -1754,8 +1755,8 @@ fi } # ]]] # FUNCTION: .zi-update-in-parallel [[[ .zi-update-all-parallel() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops nomonitor nonotify + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops nomonitor nonotify local id_as repo snip uspl user plugin PUDIR="$(mktemp -d)" local -A PUAssocArray map map=( / -- "=" -EQ- "?" -QM- "&" -AMP- : - ) @@ -1916,8 +1917,9 @@ fi # # User-action entry point. .zi-show-times() { - emulate -LR zsh - setopt extendedglob warncreateglobal noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal noshortloops + local opt="$1 $2 $3" entry entry2 entry3 user plugin float -F 3 sum=0.0 local -A sice @@ -2079,7 +2081,7 @@ fi # $2 - plugin (only when $1 - i.e. user - given) .zi-uncompile-plugin() { builtin setopt localoptions nullglob - .zi-any-to-user-plugin "$1" "$2" + .zi-any-to-user-plugin "${1}" "${2}" local user="${reply[-2]}" plugin="${reply[-1]}" silent="$3" # There are plugins having ".plugin.zsh" # in ${plugin} directory name, also some @@ -2112,6 +2114,7 @@ fi # User-action entry point. .zi-show-completions() { builtin setopt localoptions nullglob extendedglob nokshglob noksharrays + local count="${1:-3}" typeset -a completions completions=( "${ZI[COMPLETIONS_DIR]}"/_[^_.]*~*.zwc "${ZI[COMPLETIONS_DIR]}"/[^_.]*~*.zwc ) @@ -2377,7 +2380,7 @@ fi # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - plugin (only when $1 - i.e. user - given) .zi-cd() { - builtin emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob warncreateglobal typesetsilent rcquotes .zi-get-path "$1" "$2" && { @@ -2422,8 +2425,9 @@ fi # $1 - snippet URL or plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - plugin (only when $1 - i.e. user - given) .zi-delete() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent + local -a opts match mbegin mend local MATCH; integer MBEGIN MEND _retval # Parse options @@ -2588,7 +2592,7 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\"" # # $1 - time spec, e.g. "1 week" .zi-recently() { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops local IFS=. local gitout @@ -2620,8 +2624,8 @@ builtin print -Pr \"\$ZI[col-obj]Done (with the exit code: \$_retval).%f%b\"" # $1 - (optional) plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - (optional) plugin (only when $1 - i.e. user - given) .zi-create() { - emulate -LR zsh - setopt localoptions extendedglob warncreateglobal typesetsilent noshortloops rcquotes + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt localoptions extendedglob warncreateglobal typesetsilent noshortloops rcquotes .zi-any-to-user-plugin "$1" "$2" local user="${reply[-2]}" plugin="${reply[-1]}" @@ -2843,7 +2847,7 @@ EOF "SH_GLOB" "CSH_JUNKIE_QUOTES" "NO_MULTI_FUNC_DEF" ) ( - emulate -LR ksh + builtin emulate -LR ksh ${=${options[xtrace]:#off}:+-o xtrace} builtin unsetopt shglob kshglob for i in "${ZI_STRESS_TEST_OPTIONS[@]}"; do builtin setopt "$i" @@ -2905,16 +2909,17 @@ EOF # Returns path of given ID-string, which may be a plugin-spec (like "user/plugin" or "user" "plugin"), an absolute path # ("%" "/home/..." and also "%SNIPPETS/..." etc.), or a plugin nickname (i.e. id-as'' ice-mod), or a snippet nickname. .zi-get-path() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops [[ $1 == % ]] && local id_as=%$2 || local id_as=$1${1:+/}$2 .zi-get-object-path snippet "$id_as" || .zi-get-object-path plugin "$id_as" return $(( 1 - reply[3] )) } # ]]] # FUNCTION: .zi-recall [[[ .zi-recall() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops + local -A ice local el val cand1 cand2 local_dir filename is_snippet local -a ice_order nval_ices output diff --git a/lib/zsh/install.zsh b/lib/zsh/install.zsh index ddee0a3f..4971ceda 100755 --- a/lib/zsh/install.zsh +++ b/lib/zsh/install.zsh @@ -9,8 +9,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # FUNCTION: .zi-parse-json [[[ # Retrievies the ice-list from given profile from the JSON of the package.json. .zi-parse-json() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent local -A ___pos_to_level ___level_to_pos ___pair_map ___final_pairs ___Strings ___Counts local ___input=$1 ___workbuf=$1 ___key=$2 ___varname=$3 ___style ___quoting @@ -115,8 +115,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # ]]] # FUNCTION: .zi-get-package [[[ .zi-get-package() { - emulate -LR zsh - setopt extended_glob warn_create_global typeset_silent no_short_loops rc_quotes no_auto_pushd + 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 user=$1 pkg=$2 plugin=$2 id_as=$3 dir=$4 profile=$5 local_path=${ZI[PLUGINS_DIR]}/${3//\//---} pkgjson tmpfile=${$(mktemp):-${TMPDIR:-/tmp}/zsh.xYzAbc123} local URL=https://raw.githubusercontent.com/z-shell/$2/HEAD/package.json @@ -253,7 +253,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col if { ! .zi-download-file-stdout "$URL" 0 1 >! "$fname" } { if { ! .zi-download-file-stdout "$URL" 1 1 >! "$fname" } { command rm -f "$fname" - +zi-message "Download of the file {apo}\`{file}$fname{apo}\`{rst} failed. No available download tool? One of:" "{cmd}${(pj:$tool_sep:)${=:-curl wget lftp lynx}}{rst}." + +zi-message "Download of the file {apo}\`{file}$fname{apo}\`{rst} failed. No available download tool? One of{ehi}:{rst}" "{cmd}${(pj:$tool_sep:)${=:-curl wget lftp lynx}}{rst}." return 1 } } @@ -283,8 +283,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # $1 - user # $2 - plugin .zi-setup-plugin-dir() { - emulate -LR zsh - setopt extendedglob warncreateglobal noshortloops rcquotes + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal noshortloops rcquotes local user=$1 plugin=$2 id_as=$3 remote_url_path=${1:+$1/}$2 local_path tpe=$4 update=$5 version=$6 @@ -351,7 +351,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col command mkdir -p "$local_path" [[ -d "$local_path" ]] || return 1 ( - () { setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1 + () { builtin setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1 integer count for REPLY ( $reply ) { @@ -389,7 +389,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col command mkdir -p "$local_path/._zi" [[ -d "$local_path" ]] || return 1 ( - () { setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1 + () { builtin setopt localoptions noautopushd; builtin cd -q "$local_path"; } || return 1 .zi-get-cygwin-package "$remote_url_path" || return 1 builtin print -r -- $REPLY >! ._zi/is_release ziextract "$REPLY" @@ -503,8 +503,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # $2 - plugin (only when $1 - i.e. user - given) # $3 - if 1, then reinstall, otherwise only install completions that aren't there .zi-install-completions() { - builtin emulate -LR zsh - setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt nullglob extendedglob warncreateglobal typesetsilent noshortloops local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}} local reinstall=${3:-0} quiet=${${4:+1}:-0} @@ -579,8 +579,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # No arguments. .zi-compinit() { [[ -n ${OPTS[opt_-p,--parallel]} && $1 != 1 ]] && return - - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt nullglob extendedglob warncreateglobal typesetsilent integer use_C=$2 @@ -618,9 +617,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # Used by snippet loading. .zi-download-file-stdout() { local url="$1" restart="$2" progress="${(M)3:#1}" - - emulate -LR zsh - setopt localtraps extendedglob + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt localtraps extendedglob if (( restart )) { (( ${path[(I)/usr/local/bin]} )) || { @@ -671,7 +669,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col local url="$1" IFS line header local -a cmd - setopt localoptions localtraps + builtin setopt localoptions localtraps (( !${path[(I)/usr/local/bin]} )) && { path+=( "/usr/local/bin" ); @@ -713,14 +711,14 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # $2 - mode, "" - normal, "-u" - update, "-t" - test # $3 - subdirectory (not path) with working copy, needed for -t and -u .zi-mirror-using-svn() { - setopt localoptions extendedglob warncreateglobal + builtin setopt localoptions extendedglob warncreateglobal local url="$1" update="$2" directory="$3" (( ${+commands[svn]} )) || \ builtin print -Pr -- "${ZI[col-error]}Warning:%f%b Subversion not found" ", please install it to use \`${ZI[col-obj]}svn%f%b' ice." if [[ "$update" = "-t" ]]; then - ( () { setopt localoptions noautopushd; builtin cd -q "$directory"; } + ( () { builtin setopt localoptions noautopushd; builtin cd -q "$directory"; } local -a out1 out2 out1=( "${(f@)"$(LANG=C svn info -r HEAD)"}" ) out2=( "${(f@)"$(LANG=C svn info)"}" ) @@ -733,7 +731,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col return $? fi if [[ "$update" = "-u" && -d "$directory" && -d "$directory/.svn" ]]; then - ( () { setopt localoptions noautopushd; builtin cd -q "$directory"; } + ( () { builtin setopt localoptions noautopushd; builtin cd -q "$directory"; } command svn update return $? ) else @@ -748,8 +746,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # # $1 - completion function name, e.g. "_cp"; can also be "cp" .zi-forget-completion() { - emulate -LR zsh - setopt extendedglob typesetsilent warncreateglobal + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob typesetsilent warncreateglobal local f="$1" quiet="$2" @@ -775,7 +773,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - plugin (only when $1 - i.e. user - given) .zi-compile-plugin() { - builtin emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes local id_as=$1${2:+${${${(M)1:#%}:+$2}:-/$2}} first plugin_dir filename is_snippet @@ -841,7 +839,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col integer retval for first in $list; do () { - builtin emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} zcompile -U "$first"; retval+=$? } done @@ -863,8 +861,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # with Subversion – when svn-ICE is active. Github supports Subversion protocol and allows # to clone subdirectories. This is used to provide a layer of support for Oh-My-Zsh and Prezto. .zi-download-snippet() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent local save_url=$1 url=$2 id_as=$3 local_dir=$4 dirname=$5 filename=$6 update=$7 @@ -928,7 +926,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col if [[ $url = (http|https|ftp|ftps|scp)://* ]] { # URL ( - () { setopt localoptions noautopushd; builtin cd -q "$local_dir"; } || return 4 + () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir"; } || return 4 (( !OPTS[opt_-q,--quiet] )) && \ +zi-message "Downloading {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" (with Subversion)"}:-" (with curl, wget, lftp)"}{…}" @@ -986,7 +984,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col fi if [[ -e ${list[1]} && ${list[1]} != */dev/null && -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} && ${+ICE[nocompile]} -eq 0 ]] { () { - builtin emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} zcompile -U "${list[1]}" &>/dev/null || \ +zi-message "{u-warn}Warning{b-warn}:{rst} couldn't compile {apo}\`{file}${list[1]}{apo}\`{rst}." } @@ -1075,7 +1073,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col fi if [[ -e $file_path && -z ${ICE[(i)(\!|)(sh|bash|ksh|csh)]} && $file_path != */dev/null && ${+ICE[nocompile]} -eq 0 ]] { () { - builtin emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} if ! zcompile -U "$file_path" 2>/dev/null; then builtin print -r "Couldn't compile \`${file_path:t}', it MIGHT be wrongly downloaded" builtin print -r "(snippet URL points to a directory instead of a file?" @@ -1267,8 +1265,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # ]]] # FUNCTION: .zi-update-snippet [[[ .zi-update-snippet() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes local -a tmp opts local url=$1 @@ -1358,8 +1356,8 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # Gets version string of latest release of given Github package. # Connects to Github releases page. .zi-get-latest-gh-r-url-part() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops REPLY= local user=$1 plugin=$2 urlpart=$3 @@ -1476,14 +1474,14 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # $2 - file ziextract() { builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} - setopt extendedglob typesetsilent noshortloops # warncreateglobal + builtin setopt extendedglob typesetsilent noshortloops # warncreateglobal - if (( $+commands[file] != 1 )) { +zi-message "{annex}ziextract{ehi}:{error} The {cmd}file{error} command is required for recognizing the type of data to be processed{rst}" + if (( $+commands[file] != 1 )) { +zi-message "{annex}ziextract{ehi}:{rst} {error}The {cmd}file{error} command is required for recognizing the type of data to be processed{rst}" return 1 } local -a opt_move opt_move2 opt_norm opt_auto opt_nobkp zparseopts -D -E -move=opt_move -move2=opt_move2 -norm=opt_norm -auto=opt_auto -nobkp=opt_nobkp || \ - { +zi-message "{annex}ziextract{ehi}:{error} Incorrect options given to" "\`{annex}ziextract{error}' {rst}({p}available are{ehi}: {opt}--auto{msg2}," \ + { +zi-message "{annex}ziextract{ehi}:{error} Incorrect options given to" "\`{annex}ziextract{error}' {rst}({p}available are{ehi}:{rst} {opt}--auto{msg2}," \ "{opt}--move{msg2}, {opt}--move2{msg2}, {opt}--norm{msg2}, {opt}--nobkp{rst})"; return 1; } local file="$1" ext="$2" @@ -1515,7 +1513,7 @@ ziextract() { type=${(L)desc/(#b)(#i)(* |(#s))(zip|rar|xz|7-zip|gzip|bzip2|tar|exe|PE32) */$match[2]} if [[ $type = (zip|rar|xz|7-zip|gzip|bzip2|tar|exe|pe32) ]] { (( !OPTS[opt_-q,--quiet] )) && \ - +zi-message "{annex}ziextract{ehi}:{note} Detected a {obj2}$type{note} archive in the file {file}$fname{rst}" + +zi-message "{annex}ziextract{ehi}:{rst} {note}Detected a {obj2}$type{note} archive in the file{ehi}:{rst} {file}$fname{rst}" ziextract "$fname" "$type" $opt_move $opt_move2 $opt_norm --norm ${${${#archives}:#1}:+--nobkp} integer iret_val=$? ret_val+=iret_val @@ -1538,7 +1536,7 @@ ziextract() { # TODO: #115 If multiple archives are really in the archive, this might delete too soon… However, it's unusual case. [[ $fname != $infname && $norm -eq 0 ]] && command rm -f "$infname" (( !OPTS[opt_-q,--quiet] )) && \ - +zi-message "{annex}ziextract{ehi}:{note} Detected a {obj2}${type2}{note} archive in the file {file}${fname}{rst}" + +zi-message "{annex}ziextract{ehi}:{rst} {note}Detected a {obj2}${type2}{note} archive in the file{ehi}:{rst} {file}${fname}{rst}" ziextract "$fname" "$type2" $opt_move $opt_move2 $opt_norm ${${${#archives}:#1}:+--nobkp} ret_val+=$? stage2_processed+=( $fname ) @@ -1556,11 +1554,11 @@ ziextract() { } if [[ -z $file ]] { - +zi-message "{annex}ziextract{ehi}:{error} Argument required for {file}file{error} to extract or the {opt}--auto{error} option{rst}" + +zi-message "{annex}ziextract{ehi}:{rst} {error}Argument required for {file}file{error} to extract or the {opt}--auto{error} option{rst}" return 1 } if [[ ! -e $file ]] { - +zi-message "{annex}ziextract{ehi}:{error} The {file}file{error} \`{pname}${file}{error}' does not exist{rst}" + +zi-message "{annex}ziextract{ehi}:{rst} {error} The {file}file{error} \`{pname}${file}{error}' does not exist{rst}" return 1 } if (( !nobkp )) { @@ -1571,7 +1569,7 @@ ziextract() { .zi-extract-wrapper() { local file="$1" fun="$2" retval - (( !OPTS[opt_-q,--quiet] )) && +zi-message "{annex}ziextract{ehi}:{rst} Unpacking the files from: \`{file}$file{rst}'{…}{rst}" + (( !OPTS[opt_-q,--quiet] )) && +zi-message "{annex}ziextract{ehi}:{rst} Unpacking the files from{ehi}:{rst} \`{file}$file{rst}'{…}{rst}" $fun; retval=$? if (( retval == 0 )) { local -a files @@ -1581,7 +1579,7 @@ ziextract() { return $retval } - →zi-check() { (( ${+commands[$1]} )) || +zi-message "{annex}ziextract{ehi}:{error} No command {cmd}$1{msg2},{error} it is required to unpack {file}$2{rst}"; } + →zi-check() { (( ${+commands[$1]} )) || +zi-message "{annex}ziextract{ehi}:{rst} {error}No command {cmd}$1{msg2},{error} it is required to unpack {file}$2{rst}"; } case "${${ext:+.$ext}:-$file}" in ((#i)*.zip) @@ -1719,11 +1717,10 @@ ziextract() { else local sep="$ZI[col-rst],$ZI[col-obj] " if (( ${#execs} > 7 )) { - +zi-message "{annex}ziextract{ehi}:{rst} Successfully" "extracted and assigned {b}{opt}+x{rst} chmod to the files" "({obj2}${(pj:$sep:)${(@)execs[1,5]:t}},…{rst}) contained" \ + +zi-message "{annex}ziextract{ehi}:{rst} Successfully" "extracted and assigned {b}{opt}+x{rst} chmod to the files{ehi}:{rst}" "({obj2}${(pj:$sep:)${(@)execs[1,5]:t}},…{rst}) contained" \ "in \`{file}$file{rst}'. All the extracted" "{obj2}${#execs}{rst} executables are available in the {var}INSTALLED_EXECS{rst} array" } else { - +zi-message "{annex}ziextract{ehi}:{rst} Successfully" "extracted and assigned {b}{opt}+x{rst} chmod to the files" \ - "({obj2}${(pj:$sep:)${execs[@]:t}}{rst}) contained" "in \`{file}$file{rst}'" + +zi-message "{annex}ziextract{ehi}:{rst} Successfully" "extracted and assigned {b}{opt}+x{rst} chmod to the files{ehi}:{rst}" "({obj2}${(pj:$sep:)${execs[@]:t}}{rst}) contained" "in \`{file}$file{rst}'" } fi } @@ -1754,8 +1751,8 @@ ziextract() { } # ]]] # FUNCTION: .zi-extract() [[[ .zi-extract() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent local tpe=$1 extract=$2 local_dir=$3 ( builtin cd -q "$local_dir" || { @@ -1793,8 +1790,8 @@ zpextract() { ziextract "$@"; } } # ]]] # FUNCTION: .zi-get-cygwin-package [[[ .zi-get-cygwin-package() { - emulate -LR zsh - setopt extended_glob warn_create_global typeset_silent no_short_loops rc_quotes no_auto_pushd + 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 REPLY= @@ -1879,8 +1876,8 @@ zpextract() { ziextract "$@"; } # ]]] # FUNCTION zicp [[[ zicp() { - emulate -LR zsh - setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes local -a mbegin mend match local cmd=cp @@ -2038,13 +2035,13 @@ zimv() { local ___oldcd=$PWD (( ${+ICE[nocd]} == 0 )) && { () { - setopt localoptions noautopushd + builtin setopt localoptions noautopushd builtin cd -q "$dir" } } eval "$atclone" rc="$?" - () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } + () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } } return "$rc" } # ]]] @@ -2068,7 +2065,7 @@ zimv() { @zi-substitute from to local -a mv_args=("-f") local -a afr - ( () { setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1 + ( () { builtin setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1 afr=( ${~from}(DN) ) if (( ! ${#afr} )) { @@ -2099,7 +2096,7 @@ zimv() { @zi-substitute from to local -a afr - ( () { setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1 + ( () { builtin setopt localoptions noautopushd; builtin cd -q "$dir"; } || return 1 afr=( ${~from}(DN) ) if (( ${#afr} )) { if (( !OPTS[opt_-q,--quiet] )) { @@ -2121,8 +2118,8 @@ zimv() { # Compile plugin if [[ -z $ICE[(i)(\!|)(sh|bash|ksh|csh)] ]] { () { - emulate -LR zsh - setopt extendedglob warncreateglobal + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob warncreateglobal if [[ $tpe == snippet ]] { .zi-compile-plugin "%$dir" "" } else { @@ -2144,11 +2141,11 @@ zimv() { .zi-countdown atpull && { local ___oldcd=$PWD (( ${+ICE[nocd]} == 0 )) && { - () { setopt localoptions noautopushd; builtin cd -q "$dir"; } + () { builtin setopt localoptions noautopushd; builtin cd -q "$dir"; } } .zi-at-eval "$atpull" "$ICE[atclone]" rc="$?" - () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; + () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } return "$rc" } # ]]] @@ -2164,11 +2161,11 @@ zimv() { .zi-countdown atpull && { local ___oldcd=$PWD (( ${+ICE[nocd]} == 0 )) && { - () { setopt localoptions noautopushd; builtin cd -q "$dir"; } + () { builtin setopt localoptions noautopushd; builtin cd -q "$dir"; } } .zi-at-eval "$atpull" $ICE[atclone] rc="$?" - () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; + () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } return "$rc" } # ]]] diff --git a/lib/zsh/side.zsh b/lib/zsh/side.zsh index 1aae3e83..468dc131 100755 --- a/lib/zsh/side.zsh +++ b/lib/zsh/side.zsh @@ -2,7 +2,7 @@ # vim: ft=zsh sw=2 ts=2 et # # Copyright (c) 2016-2020 Sebastian Gniazdowski and contributors. -# Copyright (c) 2021 Salvydas Lukosius and Z-Shell ZI contributors. +# Copyright (c) 2021 Salvydas Lukosius and Z-Shell Community. # FUNCTION: .zi-exists-physically [[[ # Checks if directory of given plugin exists in PLUGIN_DIR. @@ -16,7 +16,7 @@ if [[ ${reply[-2]} = % ]]; then [[ -d ${reply[-1]} ]] && return 0 || return 1 else - [[ -d ${ZI[PLUGINS_DIR]}/${reply[-2]:+${reply[-2]}---}${reply[-1]//\//---} ]] && return 0 || return 1 + [[ -d ${ZI[PLUGINS_DIR]}/${reply[-2]:+${reply[-2]}---}${reply[-1]//\//---} ]] && return 0 || return 1 fi } # ]]] # FUNCTION: .zi-exists-physically-message [[[ @@ -27,7 +27,7 @@ # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - plugin (only when $1 - i.e. user - given) .zi-exists-physically-message() { - builtin emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes if ! .zi-exists-physically "$1" "$2"; then .zi-any-to-user-plugin "$1" "$2" @@ -115,8 +115,8 @@ # Obtains a snippet URL without specification if it is an SVN URL (points to directory) or regular URL (points to file), # returns 2 possible paths for further examination .zi-two-paths() { - emulate -LR zsh - setopt extendedglob typesetsilent warncreateglobal noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob typesetsilent warncreateglobal noshortloops local url=$1 url1 url2 local_dirA dirnameA svn_dirA local_dirB dirnameB local -a fileB_there @@ -155,8 +155,8 @@ # $5 - name of output string parameter, to hold filename ("filename") # $6 - name of output string parameter, to hold is-snippet 0/1-bool ("is_snippet") .zi-compute-ice() { - emulate -LR zsh - setopt extendedglob typesetsilent warncreateglobal noshortloops + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} + builtin setopt extendedglob typesetsilent warncreateglobal noshortloops local ___URL="${1%/}" ___pack="$2" ___is_snippet=0 local ___var_name1="${3:-ZI_ICE}" ___var_name2="${4:-local_dir}" ___var_name3="${5:-filename}" ___var_name4="${6:-is_snippet}" @@ -344,7 +344,7 @@ # sucessfully reaches 0, or 1 if Ctrl-C will be pressed. .zi-countdown() { (( !${+ICE[countdown]} )) && return 0 - emulate -L zsh -o extendedglob + builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} trap "+zi-message \"{ehi}ABORTING, the ice {ice}$ice{ehi} not ran{rst}\"; return 1" INT local count=5 tpe="$1" ice ice="${ICE[$tpe]}" diff --git a/zi.zsh b/zi.zsh index 152e0106..229443bb 100755 --- a/zi.zsh +++ b/zi.zsh @@ -206,8 +206,9 @@ builtin setopt noaliases # The hijacking is not only to gather report data, but also to. # run custom `autoload' function, that doesn't need FPATH. :zi-tmp-subst-autoload () { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob warncreateglobal typesetsilent rcquotes + local -a opts opts2 custom reply local func @@ -288,7 +289,7 @@ builtin setopt noaliases } else { eval "function ${(q)${custom[++count*2]}:-$func} { local body=\"\$(<${(qqq)sel}/${(qqq)func})\" body2 - () { setopt localoptions extendedglob + () { builtin setopt localoptions extendedglob body2=\"\${body##[[:space:]]#${func}[[:blank:]]#\(\)[[:space:]]#\{}\" [[ \$body2 != \$body ]] && body2=\"\${body2%\}[[:space:]]#([$nl]#([[:blank:]]#\#[^$nl]#((#e)|[$nl]))#)#}\" } @@ -326,7 +327,7 @@ builtin setopt noaliases # # The hijacking is to gather report data (which is used in unload). :zi-tmp-subst-bindkey() { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob warncreateglobal typesetsilent noshortloops is-at-least 5.3 && .zi-add-report "${ZI[CUR_USPL2]}" "Bindkey ${(j: :)${(q+)@}}" || .zi-add-report "${ZI[CUR_USPL2]}" "Bindkey ${(j: :)${(q)@}}" @@ -788,7 +789,7 @@ builtin setopt noaliases # Returns user and plugin in $reply. # .zi-any-to-user-plugin() { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob typesetsilent noshortloops rcquotes ${${${+reply}:#0}:+warncreateglobal} # Two components given? # That's a pretty fast track to call this function this way. @@ -822,7 +823,7 @@ builtin setopt noaliases } # ]]] # FUNCTION: .zi-any-to-pid. [[[ .zi-any-to-pid() { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob typesetsilent noshortloops rcquotes ${${${+REPLY}:#0}:+warncreateglobal} 1=${~1} 2=${~2} @@ -851,7 +852,7 @@ builtin setopt noaliases # FUNCTION: .zi-util-shands-path. [[[ # Replaces parts of path with %HOME, etc. .zi-util-shands-path() { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob typesetsilent noshortloops rcquotes ${${${+REPLY}:#0}:+warncreateglobal} local -A map @@ -945,7 +946,7 @@ builtin setopt noaliases } # ]]] # FUNCTION: @zi-substitute. [[[ @zi-substitute() { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob warncreateglobal typesetsilent noshortloops local -A ___subst_map ___subst_map=( @@ -989,7 +990,7 @@ builtin setopt noaliases ZI_EXTS[seqno]=$(( ${ZI_EXTS[seqno]:-0} + 1 )) ZI_EXTS[$key${${(M)type#hook:}:+ ${ZI_EXTS[seqno]}}]="${ZI_EXTS[seqno]} z-annex-data: ${(q)name} ${(q)type} ${(q)handler} ${(q)helphandler} ${(q)icemods}" () { - emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} integer index="${type##[%a-zA-Z:_!-]##}" ZI_EXTS[ice-mods]="${ZI_EXTS[ice-mods]}${icemods:+|}${(j:|:)${(@)${(@s:|:)icemods}/(#b)(#s)(?)/$index-$match[1]}}" } @@ -1089,14 +1090,14 @@ builtin setopt noaliases .zi-set-m-func() { if [[ $1 == set ]]; then ZI[___m_bkp]="${functions[m]}" - setopt noaliases + builtin setopt noaliases functions[m]="${functions[+zi-message]}" - setopt aliases + builtin setopt aliases elif [[ $1 == unset ]]; then if [[ -n ${ZI[___m_bkp]} ]]; then - setopt noaliases + builtin setopt noaliases functions[m]="${ZI[___m_bkp]}" - setopt aliases + builtin setopt aliases else noglob unset functions[m] fi @@ -1122,7 +1123,7 @@ builtin setopt noaliases [[ -n ${ICE[(i)(\!|)(sh|bash|ksh|csh)]}${ICE[opts]} ]] && { local -a precm precm=( - emulate + builtin emulate ${${(M)${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:+-R} ${${${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:-zsh} ${${ICE[(i)(\!|)bash]}:+-${(s: :):-o noshglob -o braceexpand -o kshglob}} @@ -1176,7 +1177,7 @@ builtin setopt noaliases arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" ) "${arr[5]}" snippet "$save_url" "$id_as" "$local_dir/$dirname" \!atinit || return $(( 10 - $? )) done - (( ${+ICE[atinit]} )) && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + (( ${+ICE[atinit]} )) && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } reply=( ${(on)ZI_EXTS[(I)z-annex hook:atinit-<-> <->]} ) for key in "${reply[@]}"; do arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" ) @@ -1222,7 +1223,7 @@ builtin setopt noaliases (( 0 == retval )) && [[ $url = PZT::* || $url = https://github.com/sorin-ionescu/prezto/* ]] && zstyle ":prezto:module:${${id_as%/init.zsh}:t}" loaded 'yes' } else { [[ ${+ICE[silent]} -eq 1 || ${+ICE[pick]} -eq 1 && -z ${ICE[pick]} || ${ICE[pick]} = /dev/null ]] || { +zi-message "Snippet not loaded ({url}${id_as}{rst})"; retval=1; } } [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$local_dir/$dirname/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; } - [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; } + [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; } # Run the atload hooks right before atload ice. reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} ) for key in "${reply[@]}"; do @@ -1234,7 +1235,7 @@ builtin setopt noaliases (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh" .zi-wrap-functions "$save_url" "" "$id_as" } - [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; } elif [[ -n ${opts[(r)--command]} || ${ICE[as]} = command ]]; then [[ ${+ICE[pick]} = 1 && -z ${ICE[pick]} ]] && ICE[pick]="${id_as:t}" @@ -1270,7 +1271,7 @@ builtin setopt noaliases ZERO="${${(M)ICE[src]##/*}:-$local_dir/$dirname/${ICE[src]}}" (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); } fi - [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; } + [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; }; eval "reply=(${ICE[multisrc]})"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local fname; for fname in "${reply[@]}"; do ZERO="${${(M)fname:#/*}:-$local_dir/$dirname/$fname}"; (( ${+ICE[silent]} )) && { { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( retval += $? )); ((1)); } || { ((1)); { [[ -n $precm ]] && { builtin ${precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); builtin source "$ZERO"; }; }; (( retval += $? )); }; done; } # Run the atload hooks right before atload ice. reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} ) for key in "${reply[@]}"; do @@ -1282,14 +1283,14 @@ builtin setopt noaliases (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh" .zi-wrap-functions "$save_url" "" "$id_as" } - [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && { (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; } } elif [[ ${ICE[as]} = completion ]]; then ((1)) fi - (( ${+ICE[atload]} )) && [[ ${ICE[atload][1]} != "!" ]] && { ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + (( ${+ICE[atload]} )) && [[ ${ICE[atload][1]} != "!" ]] && { ZERO="$local_dir/$dirname/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir/$dirname"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } reply=( ${(on)ZI_EXTS[(I)z-annex hook:atload-<-> <->]} ) for key in "${reply[@]}"; do arr=( "${(Q)${(z@)ZI_EXTS[$key]}[@]}" ) @@ -1374,7 +1375,7 @@ builtin setopt noaliases ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" ) "${___arr[5]}" plugin "$___user" "$___plugin" "$___id_as" "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}" \!atinit || return $(( 10 - $? )) done - [[ ${+ICE[atinit]} = 1 && $ICE[atinit] != '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ ${+ICE[atinit]} = 1 && $ICE[atinit] != '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]}"; ((1)); } || eval "${ICE[atinit]}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } reply=( ${(on)ZI_EXTS[(I)z-annex hook:atinit-<-> <->]} ) for ___key in "${reply[@]}"; do ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" ) @@ -1407,7 +1408,7 @@ builtin setopt noaliases [[ -n ${ICE[(i)(\!|)(sh|bash|ksh|csh)]}${ICE[opts]} ]] && { local -a ___precm ___precm=( - emulate + builtin emulate ${${(M)${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:+-R} ${${${ICE[(i)(\!|)(sh|bash|ksh|csh)]}#\!}:-zsh} ${${ICE[(i)(\!|)bash]}:+-${(s: :):-o noshglob -o braceexpand -o kshglob}} @@ -1446,9 +1447,9 @@ builtin setopt noaliases fi } local ZERO - [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit#!]}"; ((1)); } || eval "${ICE[atinit]#!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit#!]}"; ((1)); } || eval "${ICE[atinit]#!}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$___pdir_orig/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; } - [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local ___fname; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; done; } + [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; local ___fname; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; done; } # Run the atload hooks right before atload ice. reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} ) for ___key in "${reply[@]}"; do @@ -1460,7 +1461,7 @@ builtin setopt noaliases (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh" .zi-wrap-functions "$___user" "$___plugin" "$___id_as" } - [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; } || eval "${ICE[atload]#\!}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } [[ -n ${ICE[src]} || -n ${ICE[multisrc]} || ${ICE[atload][1]} = "!" ]] && { (( -- ZI[TMP_SUBST] == 0 )) && { ZI[TMP_SUBST]=inactive; builtin setopt noaliases; (( ${+ZI[bkp-compdef]} )) && functions[compdef]="${ZI[bkp-compdef]}" || unfunction compdef; (( ZI[ALIASES_OPT] )) && builtin setopt aliases; } } @@ -1486,10 +1487,10 @@ builtin setopt noaliases (( ${+ICE[blockf]} )) && { local -a fpath_bkp; fpath_bkp=( "${fpath[@]}" ); } local ZERO="$___pdir_path/$___fname" (( ${+ICE[aliases]} )) || builtin setopt noaliases - [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]#!}"; ((1)); } || eval "${ICE[atinit]#1}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ $ICE[atinit] = '!'* ]] && { local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}}"; } && eval "${ICE[atinit]#!}"; ((1)); } || eval "${ICE[atinit]#1}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); } [[ -n ${ICE[src]} ]] && { ZERO="${${(M)ICE[src]##/*}:-$___pdir_orig/${ICE[src]}}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { ((1)); { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); }; } - [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); } done; } + [[ -n ${ICE[multisrc]} ]] && { local ___oldcd="$PWD"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; }; eval "reply=(${ICE[multisrc]})"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; for ___fname in "${reply[@]}"; do ZERO="${${(M)___fname:#/*}:-$___pdir_orig/$___fname}"; (( ${+ICE[silent]} )) && { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; } 2>/dev/null 1>&2; (( ___retval += $? )); ((1)); } || { { [[ -n $___precm ]] && { builtin ${___precm[@]} 'source "$ZERO"'; ((1)); } || { ((1)); $___builtin source "$ZERO"; }; }; (( ___retval += $? )); } done; } # Run the atload hooks right before atload ice. reply=( ${(on)ZI_EXTS[(I)z-annex hook:\\\!atload-<-> <->]} ) for ___key in "${reply[@]}"; do @@ -1501,13 +1502,13 @@ builtin setopt noaliases (( ${+functions[.zi-service]} )) || builtin source "${ZI[BIN_DIR]}/lib/zsh/additional.zsh" .zi-wrap-functions "$___user" "$___plugin" "$___id_as" } - [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ ${ICE[atload][1]} = "!" ]] && { .zi-add-report "$___id_as" "Note: Starting to track the atload'!…' ice…"; ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]#\!}"; ((1)); } || eval "${ICE[atload]#\!}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } (( ZI[ALIASES_OPT] )) && builtin setopt aliases (( ${+ICE[blockf]} )) && { fpath=( "${fpath_bkp[@]}" ); } .zi-tmp-subst-off "${___mode:-load}" [[ $___mode != light(|-b) ]] && .zi-diff "${ZI[CUR_USPL2]}" end fi - [[ ${+ICE[atload]} = 1 && ${ICE[atload][1]} != "!" ]] && { ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } + [[ ${+ICE[atload]} = 1 && ${ICE[atload][1]} != "!" ]] && { ZERO="$___pdir_orig/-atload-"; local ___oldcd="$PWD"; (( ${+ICE[nocd]} == 0 )) && { () { builtin setopt localoptions noautopushd; builtin cd -q "$___pdir_orig"; } && builtin eval "${ICE[atload]}"; ((1)); } || eval "${ICE[atload]}"; () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; }; } reply=( ${(on)ZI_EXTS[(I)z-annex hook:atload-<-> <->]} ) for ___key in "${reply[@]}"; do ___arr=( "${(Q)${(z@)ZI_EXTS[$___key]}[@]}" ) @@ -1584,7 +1585,7 @@ builtin setopt noaliases .zi-any-to-user-plugin "$1" "" local ___id_as="$1" ___user="${reply[-2]}" ___plugin="${reply[-1]}" ___oldpwd="$PWD" () { - emulate -LR zsh + builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin cd &>/dev/null -q ${${${(M)___user:#%}:+$___plugin}:-${ZI[PLUGINS_DIR]}/${___id_as//\//---}} || { .zi-get-object-path snippet "$___id_as" builtin cd &>/dev/null -q $REPLY @@ -1594,7 +1595,7 @@ builtin setopt noaliases (( ___nolast )) && { builtin print -r "$1" >! ${ZI[BIN_DIR]}/last-run-object.txt; } ZI[last-run-plugin]="$1" eval "${@[2-correct,-1]}" - () { setopt localoptions noautopushd; builtin cd -q "$___oldpwd"; } + () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldpwd"; } else +zi-message "{u-warn}Error{b-warn}:{rst} no such plugin or snippet." fi @@ -1620,7 +1621,7 @@ builtin setopt noaliases } # ]]] # FUNCTION: .zi-formatter-pid. [[[ .zi-formatter-pid() { - builtin emulate -L zsh -o extendedglob + builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} # Save whitespace location local pbz=${(M)1##(#s)[[:space:]]##} local kbz=${(M)1%%[[:space:]]##(#e)} @@ -1656,7 +1657,7 @@ builtin setopt noaliases } # ]]] # FUNCTION: .zi-formatter-url. [[[ .zi-formatter-url() { - builtin emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} # 1:proto 3:domain/5:start 6:end-of-it 7:no-dot-domain 9:file-path if [[ $1 = (#b)([^:]#)(://|::)((([[:alnum:]._+-]##).([[:alnum:]_+-]##))|([[:alnum:].+_-]##))(|/(*)) ]] { # The advanced coloring if recognized the format… @@ -1712,7 +1713,7 @@ builtin setopt noaliases } # ]]] # FUNCTION: +zi-message. [[[ +zi-message() { - builtin emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} local opt msg [[ $1 = -* ]] && { local opt=$1; shift; } @@ -1736,10 +1737,11 @@ ${${functions[.zi-formatter-$match[7]]:+${$(.zi-formatter-$match[7] "$match[8]"; fi } # ]]] # FUNCTION: +zi-prehelp-usage-message. [[[ +# Prints the usage message. +zi-prehelp-usage-message() { - builtin emulate -LR zsh -o extendedglob - local cmd=$1 allowed=$2 sep="$ZI[col-msg2], $ZI[col-ehi]" \ - sep2="$ZI[col-msg2], $ZI[col-opt]" bcol + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} + + 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] )) { @@ -1779,7 +1781,7 @@ ${${functions[.zi-formatter-$match[7]]:+${$(.zi-formatter-$match[7] "$match[8]"; # ]]] # FUNCTION: +zi-parse-opts. [[[ .zi-parse-opts() { - builtin emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} reply=( "${(@)${@[2,-1]//([  $'\t']##|(#s))(#b)(${(~j.|.)${(@s.|.)___opt_map[$1]}})(#B)([  $'\t']##|(#e))/${OPTS[${___opt_map[${match[1]}]%%:*}]::=1}ß←↓→}:#1ß←↓→}" ) } # ]]] @@ -1841,7 +1843,7 @@ return retval } # ]]] # FUNCTION: .zi-setup-params. [[[ .zi-setup-params() { - emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} reply=( ${(@)${(@s.;.)ICE[param]}/(#m)*/${${MATCH%%(-\>|→|=\>)*}//((#s)[[:space:]]##|[[:space:]]##(#e))}${${(M)MATCH#*(-\>|→|=\>)}:+\=${${MATCH#*(-\>|→|=\>)}//((#s)[[:space:]]##|[[:space:]]##(#e))}}} ) (( ${#reply} )) && return 0 || return 1 } # ]]] @@ -1981,8 +1983,7 @@ return retval if [[ -n $1 ]] { if [[ ${#ZI_RUN} -le 1 || $1 = following ]] { () { - builtin emulate -L zsh - builtin setopt extendedglob + builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} # Example entry: # 1531252764+2+1 p 18 light z-shell/zsh-diff-so-fancy # @@ -2023,8 +2024,7 @@ return retval add-zsh-hook -d -- precmd @zi-scheduler add-zsh-hook -- chpwd @zi-scheduler () { - builtin emulate -L zsh - builtin setopt extendedglob + builtin emulate -L zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} # No "+" in this pattern, it will match only "1531252764" in "1531252764+2" and replace it with current time. ZI_TASKS=( ${ZI_TASKS[@]/(#b)([0-9]##)(*)/$(( ${match[1]} <= 1 ? ${match[1]} : ___t ))${match[2]}} ) } @@ -2356,7 +2356,7 @@ zi() { if (( ___error )) { () { - emulate -LR zsh -o extendedglob + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} +zi-message -n "{u-warn}Error{b-warn}:{rst} No plugin or snippet ID given" if [[ -n $___last_ice ]] { +zi-message -n " (the last recognized ice was: {ice}"\ @@ -2617,7 +2617,7 @@ zi() { .zi-ls "$@" ;; (srv) - () { setopt localoptions extendedglob warncreateglobal + () { builtin setopt localoptions extendedglob warncreateglobal [[ ! -e ${ZI[SERVICES_DIR]}/"$2".fifo ]] && { builtin print "No such service: $2"; } || { [[ $3 = (#i)(next|stop|quit|restart) ]] && { builtin print "${(U)3}" >>! ${ZI[SERVICES_DIR]}/"$2".fifo || builtin print "Service $2 inactive"; ___retval=1; } || From 4dac46c86bc06dd144e03b751aa548b1a6fdf804 Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Sat, 4 Jun 2022 02:13:12 +0100 Subject: [PATCH 7/9] Update _zi --- lib/_zi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/_zi b/lib/_zi index 80a55e41..e6839881 100755 --- a/lib/_zi +++ b/lib/_zi @@ -1,4 +1,6 @@ #compdef zi +# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*- +# vim: ft=zsh sw=2 ts=2 et # shellcheck disable=SC2034,SC2039,SC2059,SC2086,SC2129,SC2181,SC2296,SC2170,SC2128,SC2206,SC1036,SC2039,SC2068,SC2076,SC2155,SC2162,SC2181,SC2201,SC2207,SC2208,SC2236,SC2255,SC2270,SC2273,SC2274,SC2275,SC2276,SC2277,SC2278,SC2279,SC2280,SC2281,SC2282,SC2283,SC2284,SC2285,SC2286,SC2287,SC2288,SC2289,SC2290,SC2291,SC2292,SC2293,SC2294,SC2295,SC2296,SC2297,SC2298,SC2299,SC2300,SC2301,SC2302,SC2303,SC2304,SC2305,SC2306,SC2307,SC2308,SC2309,SC2310,SC2311,SC2312,SC2313,SC2314,SC2315,SC2316,SC2317,SC2318,SC2319,SC2320,SC2321,SC2322,SC2323,SC2324,SC2325,SC2326,SC2327,SC2328,SC2329,SC2330,SC2331,SC2332,SC2333,SC2334,SC2335,SC2336,SC2337,SC2338,SC2339,SC2340,SC2341,SC2342,SC2343,SC2344,SC2345,SC2346,SC2347,SC2348,SC2349,SC2350,SC2351,SC2352,SC2353,SC2354,SC2355,SC2356,SC2357,SC2358,SC2359,SC2360,SC2361,SC2362,SC2363,SC2364,SC2365,SC2366,SC2367,SC2368,SC2369,SC2370,SC2371,SC2372,SC2373,SC2374,SC2375,SC2376,SC2377,SC2378,SC2379,SC2380,SC2381,SC2382,SC2383,SC2384,SC2203,SC2168,SC2154 setopt localoptions warncreateglobal typesetsilent From b54fe9e8e67b367ea1452b1382ca66a7b2ac349c Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Sat, 4 Jun 2022 14:04:11 +0100 Subject: [PATCH 8/9] Update message Signed-off-by: Salvydas Lukosius --- lib/zsh/autoload.zsh | 779 +++++++++++++++++++++---------------------- lib/zsh/install.zsh | 16 +- 2 files changed, 396 insertions(+), 399 deletions(-) diff --git a/lib/zsh/autoload.zsh b/lib/zsh/autoload.zsh index 683bc2e2..a07b637f 100755 --- a/lib/zsh/autoload.zsh +++ b/lib/zsh/autoload.zsh @@ -630,7 +630,7 @@ ZI[EXTENDED_GLOB]="" .zi-self-update() { builtin emulate -LR zsh ${=${options[xtrace]:#off}:+-o xtrace} builtin setopt extendedglob typesetsilent warncreateglobal - [[ $1 = -q ]] && +zi-message "{info2}Updating »»» ❮ ZI ❯ {…}{rst}" + [[ $1 = -q ]] && +zi-message "{profile}Updating »»»»{rst} ❮ {happy}ZI{rst} ❯ {…}" local nl=$'\n' escape=$'\x1b[' current_branch=$(command git rev-parse --abbrev-ref HEAD 2>/dev/null) local -a lines ( builtin cd -q "$ZI[BIN_DIR]" && command git checkout $current_branch &>/dev/null && command git fetch --quiet && \ @@ -723,394 +723,394 @@ ZI[EXTENDED_GLOB]="" # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $2 - plugin (only when $1 - i.e. user - given) .zi-unload() { -.zi-any-to-user-plugin "$1" "$2" -local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" user="${reply[-2]}" plugin="${reply[-1]}" quiet="${${3:+1}:-0}" -local k -.zi-any-colorify-as-uspl2 "$uspl2" -(( quiet )) || builtin print -r -- "${ZI[col-bar]}---${ZI[col-rst]} Unloading plugin: $REPLY ${ZI[col-bar]}---${ZI[col-rst]}" -local ___dir -[[ "$user" = "%" ]] && ___dir="$plugin" || ___dir="${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" -# KSH_ARRAYS immunity -integer correct=0 -[[ -o "KSH_ARRAYS" ]] && correct=1 -# Allow unload for debug user -if [[ "$uspl2" != "_dtrace/_dtrace" ]]; then - .zi-exists-message "$1" "$2" || return 1 -fi -.zi-any-colorify-as-uspl2 "$1" "$2" -local uspl2col="$REPLY" -# Store report of the plugin in variable LASTREPORT -typeset -g LASTREPORT -LASTREPORT=`.zi-show-report "$1" "$2"` - -# -# Call the Zsh Plugin's Standard *_plugin_unload function -# - -(( ${+functions[${plugin}_plugin_unload]} )) && ${plugin}_plugin_unload - -# -# Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update -# - -local -a tmp -local -A sice -tmp=( "${(z@)ZI_SICE[$uspl2]}" ) -(( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=() -if [[ -n ${sice[ps-on-unload]} ]]; then - (( quiet )) || builtin print -r "Running plugin's provided unload code: ${ZI[col-info]}${sice[ps-on-unload][1,50]}${sice[ps-on-unload][51]:+…}${ZI[col-rst]}" - local ___oldcd="$PWD" - () { builtin setopt localoptions noautopushd; builtin cd -q "$___dir"; } - eval "${sice[ps-on-unload]}" - () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } -fi - -# -# 1. Delete done bindkeys -# - -typeset -a string_widget -string_widget=( "${(z)ZI[BINDKEYS__$uspl2]}" ) -local sw -for sw in "${(Oa)string_widget[@]}"; do - [[ -z "$sw" ]] && continue - # Remove one level of quoting to split using (z) - sw="${(Q)sw}" - typeset -a sw_arr - sw_arr=( "${(z)sw}" ) - # Remove one level of quoting to pass to bindkey - local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys - local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget - local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional previous-bound widget - local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional -M or -A or -N - local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional map name - local sw_arr6="${(Q)sw_arr[6-correct]}" # Optional -R (not with -A, -N) - if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then - if [[ -n "$sw_arr3" ]]; then - () { - builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} - (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" - } - bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" - bindkey -M "$sw_arr5" -r "$sw_arr1" - fi - elif [[ "$sw_arr4" = "-M" && "$sw_arr6" = "-R" ]]; then - if [[ -n "$sw_arr3" ]]; then - (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" - bindkey -RM "$sw_arr5" "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" - bindkey -M "$sw_arr5" -Rr "$sw_arr1" - fi - elif [[ "$sw_arr4" != "-M" && "$sw_arr6" = "-R" ]]; then - if [[ -n "$sw_arr3" ]]; then - (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3" - bindkey -R "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2" - bindkey -Rr "$sw_arr1" - fi - elif [[ "$sw_arr4" = "-A" ]]; then - (( quiet )) || builtin print -r "Linking backup-\`main' keymap \`$sw_arr5' back to \`main'" - bindkey -A "$sw_arr5" "main" - elif [[ "$sw_arr4" = "-N" ]]; then - (( quiet )) || builtin print -r "Deleting keymap \`$sw_arr5'" - bindkey -D "$sw_arr5" - else - if [[ -n "$sw_arr3" ]]; then - () { - builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} - (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3" - } - bindkey "$sw_arr1" "$sw_arr3" - else - (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2" - bindkey -r "$sw_arr1" - fi + .zi-any-to-user-plugin "$1" "$2" + local uspl2="${reply[-2]}${${reply[-2]:#(%|/)*}:+/}${reply[-1]}" user="${reply[-2]}" plugin="${reply[-1]}" quiet="${${3:+1}:-0}" + local k + .zi-any-colorify-as-uspl2 "$uspl2" + (( quiet )) || builtin print -r -- "${ZI[col-bar]}---${ZI[col-rst]} Unloading plugin: $REPLY ${ZI[col-bar]}---${ZI[col-rst]}" + local ___dir + [[ "$user" = "%" ]] && ___dir="$plugin" || ___dir="${ZI[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" + # KSH_ARRAYS immunity + integer correct=0 + [[ -o "KSH_ARRAYS" ]] && correct=1 + # Allow unload for debug user + if [[ "$uspl2" != "_dtrace/_dtrace" ]]; then + .zi-exists-message "$1" "$2" || return 1 fi -done + .zi-any-colorify-as-uspl2 "$1" "$2" + local uspl2col="$REPLY" + # Store report of the plugin in variable LASTREPORT + typeset -g LASTREPORT + LASTREPORT=`.zi-show-report "$1" "$2"` -# -# 2. Delete created Zstyles -# + # + # Call the Zsh Plugin's Standard *_plugin_unload function + # -typeset -a pattern_style -pattern_style=( "${(z)ZI[ZSTYLES__$uspl2]}" ) -local ps -for ps in "${(Oa)pattern_style[@]}"; do - [[ -z "$ps" ]] && continue - # Remove one level of quoting to split using (z) - ps="${(Q)ps}" - typeset -a ps_arr - ps_arr=( "${(z)ps}" ) - # Remove one level of quoting to pass to zstyle - local ps_arr1="${(Q)ps_arr[1-correct]}" - local ps_arr2="${(Q)ps_arr[2-correct]}" - (( quiet )) || builtin print "Deleting zstyle $ps_arr1 $ps_arr2" - zstyle -d "$ps_arr1" "$ps_arr2" -done + (( ${+functions[${plugin}_plugin_unload]} )) && ${plugin}_plugin_unload -# -# 3. Restore changed options -# + # + # Call the code provided by the Zsh Plugin's Standard @zsh-plugin-run-at-update + # -# Paranoid, don't want bad key/value pair error -.zi-diff-options-compute "$uspl2" -integer empty=0 -.zi-save-set-extendedglob -[[ "${ZI[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1 -.zi-restore-extendedglob -if (( empty != 1 )); then - typeset -A opts - opts=( "${(z)ZI[OPTIONS__$uspl2]}" ) - for k in "${(kon)opts[@]}"; do - # Internal options - [[ "$k" = "physical" ]] && continue - if [[ "${opts[$k]}" = "on" ]]; then - (( quiet )) || +zi-message "[ {p}¤{rst} ] Setting option $k" - builtin setopt "$k" + local -a tmp + local -A sice + tmp=( "${(z@)ZI_SICE[$uspl2]}" ) + (( ${#tmp} > 1 && ${#tmp} % 2 == 0 )) && sice=( "${(Q)tmp[@]}" ) || sice=() + if [[ -n ${sice[ps-on-unload]} ]]; then + (( quiet )) || builtin print -r "Running plugin's provided unload code: ${ZI[col-info]}${sice[ps-on-unload][1,50]}${sice[ps-on-unload][51]:+…}${ZI[col-rst]}" + local ___oldcd="$PWD" + () { builtin setopt localoptions noautopushd; builtin cd -q "$___dir"; } + eval "${sice[ps-on-unload]}" + () { builtin setopt localoptions noautopushd; builtin cd -q "$___oldcd"; } + fi + + # + # 1. Delete done bindkeys + # + + typeset -a string_widget + string_widget=( "${(z)ZI[BINDKEYS__$uspl2]}" ) + local sw + for sw in "${(Oa)string_widget[@]}"; do + [[ -z "$sw" ]] && continue + # Remove one level of quoting to split using (z) + sw="${(Q)sw}" + typeset -a sw_arr + sw_arr=( "${(z)sw}" ) + # Remove one level of quoting to pass to bindkey + local sw_arr1="${(Q)sw_arr[1-correct]}" # Keys + local sw_arr2="${(Q)sw_arr[2-correct]}" # Widget + local sw_arr3="${(Q)sw_arr[3-correct]}" # Optional previous-bound widget + local sw_arr4="${(Q)sw_arr[4-correct]}" # Optional -M or -A or -N + local sw_arr5="${(Q)sw_arr[5-correct]}" # Optional map name + local sw_arr6="${(Q)sw_arr[6-correct]}" # Optional -R (not with -A, -N) + if [[ "$sw_arr4" = "-M" && "$sw_arr6" != "-R" ]]; then + if [[ -n "$sw_arr3" ]]; then + () { + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} + (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" + } + bindkey -M "$sw_arr5" "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" + bindkey -M "$sw_arr5" -r "$sw_arr1" + fi + elif [[ "$sw_arr4" = "-M" && "$sw_arr6" = "-R" ]]; then + if [[ -n "$sw_arr3" ]]; then + (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" + bindkey -RM "$sw_arr5" "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2 ${ZI[col-info]}in map ${ZI[col-rst]}$sw_arr5" + bindkey -M "$sw_arr5" -Rr "$sw_arr1" + fi + elif [[ "$sw_arr4" != "-M" && "$sw_arr6" = "-R" ]]; then + if [[ -n "$sw_arr3" ]]; then + (( quiet )) || builtin print -r "Restoring ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr3" + bindkey -R "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting ${ZI[col-info]}range${ZI[col-rst]} bindkey ${(q)sw_arr1} $sw_arr2" + bindkey -Rr "$sw_arr1" + fi + elif [[ "$sw_arr4" = "-A" ]]; then + (( quiet )) || builtin print -r "Linking backup-\`main' keymap \`$sw_arr5' back to \`main'" + bindkey -A "$sw_arr5" "main" + elif [[ "$sw_arr4" = "-N" ]]; then + (( quiet )) || builtin print -r "Deleting keymap \`$sw_arr5'" + bindkey -D "$sw_arr5" else - (( quiet )) || +zi-message "[ {p}¤{rst} ] Unsetting option $k" - builtin unsetopt "$k" + if [[ -n "$sw_arr3" ]]; then + () { + builtin emulate -LR zsh -o extendedglob ${=${options[xtrace]:#off}:+-o xtrace} + (( quiet )) || builtin print -r "Restoring bindkey ${${(q)sw_arr1}//(#m)\\[\^\?\]\[\)\(\'\"\}\{\`]/${MATCH#\\}} $sw_arr3" + } + bindkey "$sw_arr1" "$sw_arr3" + else + (( quiet )) || builtin print -r "Deleting bindkey ${(q)sw_arr1} $sw_arr2" + bindkey -r "$sw_arr1" + fi fi done -fi - -# -# 4. Delete aliases -# - -typeset -a aname_avalue -aname_avalue=( "${(z)ZI[ALIASES__$uspl2]}" ) -local nv -for nv in "${(Oa)aname_avalue[@]}"; do - [[ -z "$nv" ]] && continue - # Remove one level of quoting to split using (z) - nv="${(Q)nv}" - typeset -a nv_arr - nv_arr=( "${(z)nv}" ) - # Remove one level of quoting to pass to unalias - local nv_arr1="${(Q)nv_arr[1-correct]}" - local nv_arr2="${(Q)nv_arr[2-correct]}" - local nv_arr3="${(Q)nv_arr[3-correct]}" - if [[ "$nv_arr3" = "-s" ]]; then - if [[ -n "$nv_arr2" ]]; then - (( quiet )) || +zi-message "[ {p}¤{rst} ] Restoring {info}suffix{rst} alias ${nv_arr1}=${nv_arr2}" - alias "$nv_arr1" &> /dev/null && unalias -s -- "$nv_arr1" - alias -s -- "${nv_arr1}=${nv_arr2}" - else - (( quiet )) || alias "$nv_arr1" &> /dev/null && { - +zi-message "[ {p}¤{rst} ] Removing {info}suffix{rst} alias ${nv_arr1}" - unalias -s -- "$nv_arr1" - } - fi - elif [[ "$nv_arr3" = "-g" ]]; then - if [[ -n "$nv_arr2" ]]; then - (( quiet )) || +zi-message "[ {p}¤{rst} ] Restoring {info}global{rst} alias ${nv_arr1}=${nv_arr2}" - alias "$nv_arr1" &> /dev/null && unalias -g -- "$nv_arr1" - alias -g -- "${nv_arr1}=${nv_arr2}" - else - (( quiet )) || alias "$nv_arr1" &> /dev/null && { - +zi-message "[ {p}¤{rst} ] Removing {info}global{rst} alias ${nv_arr1}" - unalias -- "${(q)nv_arr1}" - } - fi - else - if [[ -n "$nv_arr2" ]]; then - (( quiet )) || +zi-message "[ {p}¤{rst} ] Restoring alias ${nv_arr1}=${nv_arr2}" - alias "$nv_arr1" &> /dev/null && unalias -- "$nv_arr1" - alias -- "${nv_arr1}=${nv_arr2}" + + # + # 2. Delete created Zstyles + # + + typeset -a pattern_style + pattern_style=( "${(z)ZI[ZSTYLES__$uspl2]}" ) + local ps + for ps in "${(Oa)pattern_style[@]}"; do + [[ -z "$ps" ]] && continue + # Remove one level of quoting to split using (z) + ps="${(Q)ps}" + typeset -a ps_arr + ps_arr=( "${(z)ps}" ) + # Remove one level of quoting to pass to zstyle + local ps_arr1="${(Q)ps_arr[1-correct]}" + local ps_arr2="${(Q)ps_arr[2-correct]}" + (( quiet )) || builtin print "Deleting zstyle $ps_arr1 $ps_arr2" + zstyle -d "$ps_arr1" "$ps_arr2" + done + + # + # 3. Restore changed options + # + + # Paranoid, don't want bad key/value pair error + .zi-diff-options-compute "$uspl2" + integer empty=0 + .zi-save-set-extendedglob + [[ "${ZI[OPTIONS__$uspl2]}" != *[$'! \t']* ]] && empty=1 + .zi-restore-extendedglob + if (( empty != 1 )); then + typeset -A opts + opts=( "${(z)ZI[OPTIONS__$uspl2]}" ) + for k in "${(kon)opts[@]}"; do + # Internal options + [[ "$k" = "physical" ]] && continue + if [[ "${opts[$k]}" = "on" ]]; then + (( quiet )) || +zi-message "Setting option $k" + builtin setopt "$k" + else + (( quiet )) || +zi-message "Unsetting option $k" + builtin unsetopt "$k" + fi + done + fi + + # + # 4. Delete aliases + # + + typeset -a aname_avalue + aname_avalue=( "${(z)ZI[ALIASES__$uspl2]}" ) + local nv + for nv in "${(Oa)aname_avalue[@]}"; do + [[ -z "$nv" ]] && continue + # Remove one level of quoting to split using (z) + nv="${(Q)nv}" + typeset -a nv_arr + nv_arr=( "${(z)nv}" ) + # Remove one level of quoting to pass to unalias + local nv_arr1="${(Q)nv_arr[1-correct]}" + local nv_arr2="${(Q)nv_arr[2-correct]}" + local nv_arr3="${(Q)nv_arr[3-correct]}" + if [[ "$nv_arr3" = "-s" ]]; then + if [[ -n "$nv_arr2" ]]; then + (( quiet )) || +zi-message "Restoring {info}suffix{rst} alias ${nv_arr1}=${nv_arr2}" + alias "$nv_arr1" &> /dev/null && unalias -s -- "$nv_arr1" + alias -s -- "${nv_arr1}=${nv_arr2}" + else + (( quiet )) || alias "$nv_arr1" &> /dev/null && { + +zi-message "Removing {info}suffix{rst} alias ${nv_arr1}" + unalias -s -- "$nv_arr1" + } + fi + elif [[ "$nv_arr3" = "-g" ]]; then + if [[ -n "$nv_arr2" ]]; then + (( quiet )) || +zi-message "Restoring {info}global{rst} alias ${nv_arr1}=${nv_arr2}" + alias "$nv_arr1" &> /dev/null && unalias -g -- "$nv_arr1" + alias -g -- "${nv_arr1}=${nv_arr2}" + else + (( quiet )) || alias "$nv_arr1" &> /dev/null && { + +zi-message "Removing {info}global{rst} alias ${nv_arr1}" + unalias -- "${(q)nv_arr1}" + } + fi else - (( quiet )) || alias "$nv_arr1" &> /dev/null && { - +zi-message "[ {p}¤{rst} ] Removing alias ${nv_arr1}" - unalias -- "$nv_arr1" - } + if [[ -n "$nv_arr2" ]]; then + (( quiet )) || +zi-message "Restoring alias ${nv_arr1}=${nv_arr2}" + alias "$nv_arr1" &> /dev/null && unalias -- "$nv_arr1" + alias -- "${nv_arr1}=${nv_arr2}" + else + (( quiet )) || alias "$nv_arr1" &> /dev/null && { + +zi-message "Removing alias ${nv_arr1}" + unalias -- "$nv_arr1" + } + fi fi - fi -done + done -# -# 5. Restore Zle state -# + # + # 5. Restore Zle state + # -local -a keys -keys=( "${(@on)ZI[(I)TIME_<->_*]}" ) -integer keys_size=${#keys} -() { - builtin setopt localoptions extendedglob noksharrays typesetsilent - typeset -a restore_widgets skip_delete - local wid - restore_widgets=( "${(z)ZI[WIDGETS_SAVED__$uspl2]}" ) - for wid in "${(Oa)restore_widgets[@]}"; do - [[ -z "$wid" ]] && continue - wid="${(Q)wid}" - typeset -a orig_saved - orig_saved=( "${(z)wid}" ) - local tpe="${orig_saved[1]}" - local orig_saved1="${(Q)orig_saved[2]}" # Original widget - local comp_wid="${(Q)orig_saved[3]}" - local orig_saved2="${(Q)orig_saved[4]}" # Saved target function - local orig_saved3="${(Q)orig_saved[5]}" # Saved previous $widget's contents - local found_time_key="${keys[(r)TIME_<->_${uspl2//\//---}]}" to_process_plugin - integer found_time_idx=0 idx=0 - to_process_plugin="" - [[ "$found_time_key" = (#b)TIME_(<->)_* ]] && found_time_idx="${match[1]}" - if (( found_time_idx )); then # Must be true - for (( idx = found_time_idx + 1; idx <= keys_size; ++ idx )); do - found_time_key="${keys[(r)TIME_${idx}_*]}" - local oth_uspl2="" - [[ "$found_time_key" = (#b)TIME_${idx}_(*) ]] && oth_uspl2="${match[1]//---//}" - local -a entry_splitted - entry_splitted=( "${(z@)ZI[WIDGETS_SAVED__$oth_uspl2]}" ) - integer found_idx="${entry_splitted[(I)(-N|-C)\ $orig_saved1\\\ *]}" - local -a entry_splitted2 - entry_splitted2=( "${(z@)ZI[BINDKEYS__$oth_uspl2]}" ) - integer found_idx2="${entry_splitted2[(I)*\ $orig_saved1\ *]}" - if (( found_idx || found_idx2 )) - then - # Skip multiple loads of the same plugin - # TODO: #113 Fully handle multiple plugin loads - if [[ "$oth_uspl2" != "$uspl2" ]]; then - to_process_plugin="$oth_uspl2" - break # Only the first one is needed + local -a keys + keys=( "${(@on)ZI[(I)TIME_<->_*]}" ) + integer keys_size=${#keys} + () { + builtin setopt localoptions extendedglob noksharrays typesetsilent + typeset -a restore_widgets skip_delete + local wid + restore_widgets=( "${(z)ZI[WIDGETS_SAVED__$uspl2]}" ) + for wid in "${(Oa)restore_widgets[@]}"; do + [[ -z "$wid" ]] && continue + wid="${(Q)wid}" + typeset -a orig_saved + orig_saved=( "${(z)wid}" ) + local tpe="${orig_saved[1]}" + local orig_saved1="${(Q)orig_saved[2]}" # Original widget + local comp_wid="${(Q)orig_saved[3]}" + local orig_saved2="${(Q)orig_saved[4]}" # Saved target function + local orig_saved3="${(Q)orig_saved[5]}" # Saved previous $widget's contents + local found_time_key="${keys[(r)TIME_<->_${uspl2//\//---}]}" to_process_plugin + integer found_time_idx=0 idx=0 + to_process_plugin="" + [[ "$found_time_key" = (#b)TIME_(<->)_* ]] && found_time_idx="${match[1]}" + if (( found_time_idx )); then # Must be true + for (( idx = found_time_idx + 1; idx <= keys_size; ++ idx )); do + found_time_key="${keys[(r)TIME_${idx}_*]}" + local oth_uspl2="" + [[ "$found_time_key" = (#b)TIME_${idx}_(*) ]] && oth_uspl2="${match[1]//---//}" + local -a entry_splitted + entry_splitted=( "${(z@)ZI[WIDGETS_SAVED__$oth_uspl2]}" ) + integer found_idx="${entry_splitted[(I)(-N|-C)\ $orig_saved1\\\ *]}" + local -a entry_splitted2 + entry_splitted2=( "${(z@)ZI[BINDKEYS__$oth_uspl2]}" ) + integer found_idx2="${entry_splitted2[(I)*\ $orig_saved1\ *]}" + if (( found_idx || found_idx2 )) + then + # Skip multiple loads of the same plugin + # TODO: #113 Fully handle multiple plugin loads + if [[ "$oth_uspl2" != "$uspl2" ]]; then + to_process_plugin="$oth_uspl2" + break # Only the first one is needed + fi fi - fi - done - if [[ -n "$to_process_plugin" ]]; then - if (( !found_idx && !found_idx2 )); then - (( quiet )) || builtin print "Problem (1) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" - continue - fi - (( quiet )) || builtin print "Chaining widget \`$orig_saved1' to plugin $oth_uspl2" - local -a oth_orig_saved - if (( found_idx )) { - oth_orig_saved=( "${(z)${(Q)entry_splitted[found_idx]}}" ) - local oth_fun="${oth_orig_saved[4]}" - # oth_orig_saved[2]="${(q)orig_saved2}" # not do this, because - # we don't want to call other plugin's function at any moment - oth_orig_saved[5]="${(q)orig_saved3}" # chain up the widget - entry_splitted[found_idx]="${(q)${(j: :)oth_orig_saved}}" - ZI[WIDGETS_SAVED__$oth_uspl2]="${(j: :)entry_splitted}" - } else { - oth_orig_saved=( "${(z)${(Q)entry_splitted2[found_idx2]}}" ) - local oth_fun="${widgets[${oth_orig_saved[3]}]#*:}" - } - integer idx="${functions[$orig_saved2][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" - if (( idx <= ${#functions[$orig_saved2]} )) - then - local prefix_X="${match[1]#\{}" - [[ $prefix_X != \$* ]] && prefix_X="${prefix_X%\}}" - idx="${functions[$oth_fun][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" - if (( idx <= ${#functions[$oth_fun]} )); then - match[1]="${match[1]#\{}" - [[ ${match[1]} != \$* ]] && match[1]="${match[1]%\}}" - eval "local oth_prefix_uspl2_X=\"${match[1]}\"" - if [[ "${widgets[$prefix_X]}" = builtin ]]; then - (( quiet )) || builtin print "Builtin-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" - zle -A ".${prefix_X#.}" "$oth_prefix_uspl2_X" - elif [[ "${widgets[$prefix_X]}" = completion:* ]]; then - (( quiet )) || builtin print "Chain*-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" - zle -C "$oth_prefix_uspl2_X" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" - else - (( quiet )) || builtin print "Chain-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" - zle -N "$oth_prefix_uspl2_X" "${widgets[$prefix_X]#user:}" + done + if [[ -n "$to_process_plugin" ]]; then + if (( !found_idx && !found_idx2 )); then + (( quiet )) || builtin print "Problem (1) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" + continue + fi + (( quiet )) || builtin print "Chaining widget \`$orig_saved1' to plugin $oth_uspl2" + local -a oth_orig_saved + if (( found_idx )) { + oth_orig_saved=( "${(z)${(Q)entry_splitted[found_idx]}}" ) + local oth_fun="${oth_orig_saved[4]}" + # oth_orig_saved[2]="${(q)orig_saved2}" # not do this, because + # we don't want to call other plugin's function at any moment + oth_orig_saved[5]="${(q)orig_saved3}" # chain up the widget + entry_splitted[found_idx]="${(q)${(j: :)oth_orig_saved}}" + ZI[WIDGETS_SAVED__$oth_uspl2]="${(j: :)entry_splitted}" + } else { + oth_orig_saved=( "${(z)${(Q)entry_splitted2[found_idx2]}}" ) + local oth_fun="${widgets[${oth_orig_saved[3]}]#*:}" + } + integer idx="${functions[$orig_saved2][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" + if (( idx <= ${#functions[$orig_saved2]} )) + then + local prefix_X="${match[1]#\{}" + [[ $prefix_X != \$* ]] && prefix_X="${prefix_X%\}}" + idx="${functions[$oth_fun][(i)(#b)([^[:space:]]#${orig_saved1}[^[:space:]]#)]}" + if (( idx <= ${#functions[$oth_fun]} )); then + match[1]="${match[1]#\{}" + [[ ${match[1]} != \$* ]] && match[1]="${match[1]%\}}" + eval "local oth_prefix_uspl2_X=\"${match[1]}\"" + if [[ "${widgets[$prefix_X]}" = builtin ]]; then + (( quiet )) || builtin print "Builtin-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" + zle -A ".${prefix_X#.}" "$oth_prefix_uspl2_X" + elif [[ "${widgets[$prefix_X]}" = completion:* ]]; then + (( quiet )) || builtin print "Chain*-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" + zle -C "$oth_prefix_uspl2_X" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" + else + (( quiet )) || builtin print "Chain-restoring widget \`$oth_prefix_uspl2_X' ($oth_uspl2)" + zle -N "$oth_prefix_uspl2_X" "${widgets[$prefix_X]#user:}" + fi fi + # The alternate method + # skip_delete+=( "${match[1]}" ) + # functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}" fi - # The alternate method - # skip_delete+=( "${match[1]}" ) - # functions[$oth_fun]="${functions[$oth_fun]//[^\{[:space:]]#$orig_saved1/${match[1]}}" - fi - else - (( quiet )) || builtin print "Restoring Zle widget $orig_saved1" - if [[ "$orig_saved3" = builtin ]]; then - zle -A ".$orig_saved1" "$orig_saved1" - elif [[ "$orig_saved3" = completion:* ]]; then - zle -C "$orig_saved1" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" else - zle -N "$orig_saved1" "${orig_saved3#user:}" + (( quiet )) || builtin print "Restoring Zle widget $orig_saved1" + if [[ "$orig_saved3" = builtin ]]; then + zle -A ".$orig_saved1" "$orig_saved1" + elif [[ "$orig_saved3" = completion:* ]]; then + zle -C "$orig_saved1" "${(@)${(@s.:.)${orig_saved3#user:}}[2,3]}" + else + zle -N "$orig_saved1" "${orig_saved3#user:}" + fi fi + else + (( quiet )) || builtin print "Problem (2) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" fi + done + } + typeset -a delete_widgets + delete_widgets=( "${(z)ZI[WIDGETS_DELETE__$uspl2]}" ) + local wid + for wid in "${(Oa)delete_widgets[@]}"; do + [[ -z "$wid" ]] && continue + wid="${(Q)wid}" + if [[ -n "${skip_delete[(r)$wid]}" ]]; then + builtin print "Would delete $wid" + continue + fi + if [[ "${ZI_ZLE_HOOKS_LIST[$wid]}" = "1" ]]; then + (( quiet )) || builtin print "Removing Zle hook \`$wid'" else - (( quiet )) || builtin print "Problem (2) during handling of widget \`$orig_saved1' (contents: $orig_saved2)" + (( quiet )) || builtin print "Removing Zle widget \`$wid'" fi + zle -D "$wid" done -} -typeset -a delete_widgets -delete_widgets=( "${(z)ZI[WIDGETS_DELETE__$uspl2]}" ) -local wid -for wid in "${(Oa)delete_widgets[@]}"; do - [[ -z "$wid" ]] && continue - wid="${(Q)wid}" - if [[ -n "${skip_delete[(r)$wid]}" ]]; then - builtin print "Would delete $wid" - continue - fi - if [[ "${ZI_ZLE_HOOKS_LIST[$wid]}" = "1" ]]; then - (( quiet )) || builtin print "Removing Zle hook \`$wid'" - else - (( quiet )) || builtin print "Removing Zle widget \`$wid'" - fi - zle -D "$wid" -done -# -# 6. Unfunction -# + # + # 6. Unfunction + # -.zi-diff-functions-compute "$uspl2" -typeset -a func -func=( "${(z)ZI[FUNCTIONS__$uspl2]}" ) -local f -for f in "${(on)func[@]}"; do - [[ -z "$f" ]] && continue - f="${(Q)f}" - (( quiet )) || +zi-message "[ {p}¤{rst} ] Deleting function $f" - (( ${+functions[$f]} )) && unfunction -- "$f" - (( ${+precmd_functions} )) && precmd_functions=( ${precmd_functions[@]:#$f} ) - (( ${+preexec_functions} )) && preexec_functions=( ${preexec_functions[@]:#$f} ) - (( ${+chpwd_functions} )) && chpwd_functions=( ${chpwd_functions[@]:#$f} ) - (( ${+periodic_functions} )) && periodic_functions=( ${periodic_functions[@]:#$f} ) - (( ${+zshaddhistory_functions} )) && zshaddhistory_functions=( ${zshaddhistory_functions[@]:#$f} ) - (( ${+zshexit_functions} )) && zshexit_functions=( ${zshexit_functions[@]:#$f} ) -done + .zi-diff-functions-compute "$uspl2" + typeset -a func + func=( "${(z)ZI[FUNCTIONS__$uspl2]}" ) + local f + for f in "${(on)func[@]}"; do + [[ -z "$f" ]] && continue + f="${(Q)f}" + (( quiet )) || +zi-message "Deleting function $f" + (( ${+functions[$f]} )) && unfunction -- "$f" + (( ${+precmd_functions} )) && precmd_functions=( ${precmd_functions[@]:#$f} ) + (( ${+preexec_functions} )) && preexec_functions=( ${preexec_functions[@]:#$f} ) + (( ${+chpwd_functions} )) && chpwd_functions=( ${chpwd_functions[@]:#$f} ) + (( ${+periodic_functions} )) && periodic_functions=( ${periodic_functions[@]:#$f} ) + (( ${+zshaddhistory_functions} )) && zshaddhistory_functions=( ${zshaddhistory_functions[@]:#$f} ) + (( ${+zshexit_functions} )) && zshexit_functions=( ${zshexit_functions[@]:#$f} ) + done -# -# 7. Clean up FPATH and PATH -# + # + # 7. Clean up FPATH and PATH + # -.zi-diff-env-compute "$uspl2" + .zi-diff-env-compute "$uspl2" -# Have to iterate over $path elements and -# skip those that were added by the plugin -typeset -a new elem p -elem=( "${(z)ZI[PATH__$uspl2]}" ) -for p in "${path[@]}"; do - if [[ -z "${elem[(r)${(q)p}]}" ]] { - new+=( "$p" ) - } else { - (( quiet )) || +zi-message "[ {p}¤{rst} ] Removing {pname}PATH{rst} element {info}$p{rst}" - [[ -d "$p" ]] || (( quiet )) || +zi-message "[ {error}✖{rst} ] {error}Warning:{rst} it didn't exist on disk" - } -done -path=( "${new[@]}" ) -# The same for $fpath -elem=( "${(z)ZI[FPATH__$uspl2]}" ) -new=( ) -for p ( "${fpath[@]}" ) { - if [[ -z "${elem[(r)${(q)p}]}" ]] { - new+=( "$p" ) - } else { - (( quiet )) || +zi-message "[ {p}¤{rst} ] Removing {pname}FPATH{rst} element {info}$p{rst}" - [[ -d "$p" ]] || (( quiet )) || +zi-message "[ {error}✖{rst} ] {error}Warning:{rst} it didn't exist on disk" + # Have to iterate over $path elements and + # skip those that were added by the plugin + typeset -a new elem p + elem=( "${(z)ZI[PATH__$uspl2]}" ) + for p in "${path[@]}"; do + if [[ -z "${elem[(r)${(q)p}]}" ]] { + new+=( "$p" ) + } else { + (( quiet )) || +zi-message "Removing {pname}PATH{rst} element {info}$p{rst}" + [[ -d "$p" ]] || (( quiet )) || +zi-message "{error}Warning:{rst} it didn't exist on disk" + } + done + path=( "${new[@]}" ) + # The same for $fpath + elem=( "${(z)ZI[FPATH__$uspl2]}" ) + new=( ) + for p ( "${fpath[@]}" ) { + if [[ -z "${elem[(r)${(q)p}]}" ]] { + new+=( "$p" ) + } else { + (( quiet )) || +zi-message "Removing {pname}FPATH{rst} element {info}$p{rst}" + [[ -d "$p" ]] || (( quiet )) || +zi-message "{error}Warning:{rst} it didn't exist on disk" + } } -} -fpath=( "${new[@]}" ) + fpath=( "${new[@]}" ) -# -# 8. Delete created variables -# + # + # 8. Delete created variables + # .zi-diff-parameter-compute "$uspl2" empty=0 @@ -1143,10 +1143,8 @@ fpath=( "${new[@]}" ) continue; ;; esac - # Don't unset redefined variables, only newly defined - # "" means variable didn't exist before plugin load - # (didn't have a type). - # Do an exception for the prompt variables. + # Don't unset redefined variables, only newly defined "" means variable did not exist before plugin load + # (did not have a type). Do an exception for the prompt variables. if [[ $v1 = '""' || ( $k = (RPROMPT|RPS1|RPS2|PROMPT|PS1|PS2|PS3|PS4) && $v1 != $v2 ) ]]; then found=0 for wl in "${whitelist[@]}"; do @@ -1169,21 +1167,20 @@ fpath=( "${new[@]}" ) done fi -# -# 9. Forget the plugin -# - -if [[ "$uspl2" = "_dtrace/_dtrace" ]]; then - .zi-clear-debug-report - (( quiet )) || +zi-message "[ {info}✔{rst} ] dtrace report saved to \$LASTREPORT" -else - (( quiet )) || +zi-message "[ {info}✔{rst} ] Unregistering plugin $uspl2col" - .zi-unregister-plugin "$user" "$plugin" "${sice[teleid]}" - zsh_loaded_plugins[${zsh_loaded_plugins[(i)$user${${user:#(%|/)*}:+/}$plugin]}]=() # Support Zsh plugin standard - .zi-clear-report-for "$user" "$plugin" - (( quiet )) || +zi-message "[ {info}✔{rst} ] Plugin's report saved to \$LASTREPORT" -fi + # + # 9. Forget the plugin + # + if [[ "$uspl2" = "_dtrace/_dtrace" ]]; then + .zi-clear-debug-report + (( quiet )) || +zi-message "dtrace report saved to \$LASTREPORT" + else + (( quiet )) || +zi-message "Unregistering plugin $uspl2col" + .zi-unregister-plugin "$user" "$plugin" "${sice[teleid]}" + zsh_loaded_plugins[${zsh_loaded_plugins[(i)$user${${user:#(%|/)*}:+/}$plugin]}]=() # Support Zsh plugin standard + .zi-clear-report-for "$user" "$plugin" + (( quiet )) || +zi-message "Plugin's report saved to \$LASTREPORT" + fi } # ]]] # FUNCTION: .zi-show-report [[[ # Displays report of the plugin given. @@ -1222,24 +1219,24 @@ fi REPLY="" .zi-diff-functions-compute "$uspl2" .zi-format-functions "$uspl2" - [[ -n "$REPLY" ]] && +zi-message "[ {info}✔{rst} ] {p}Functions created:{rst}"$'\n'"$REPLY" + [[ -n "$REPLY" ]] && +zi-message "{p}Functions created:{rst}"$'\n'"$REPLY" # Print report gathered via $options-diffing REPLY="" .zi-diff-options-compute "$uspl2" .zi-format-options "$uspl2" - [[ -n "$REPLY" ]] && +zi-message "[ {info}✔{rst} ] {p}Options changed:{rst}"$'\n'"$REPLY" + [[ -n "$REPLY" ]] && +zi-message "{p}Options changed:{rst}"$'\n'"$REPLY" # Print report gathered via environment diffing REPLY="" .zi-diff-env-compute "$uspl2" .zi-format-env "$uspl2" "1" - [[ -n "$REPLY" ]] && +zi-message "[ {info}✔{rst} ] {p}PATH elements added:{rst}"$'\n'"$REPLY" + [[ -n "$REPLY" ]] && +zi-message "{p}PATH elements added:{rst}"$'\n'"$REPLY" REPLY="" .zi-format-env "$uspl2" "2" - [[ -n "$REPLY" ]] && +zi-message "[ {info}✔{rst} ] {p}FPATH elements added:{rst}"$'\n'"$REPLY" + [[ -n "$REPLY" ]] && +zi-message "{p}FPATH elements added:{rst}"$'\n'"$REPLY" # Print report gathered via parameter diffing .zi-diff-parameter-compute "$uspl2" .zi-format-parameter "$uspl2" - [[ -n "$REPLY" ]] && +zi-message "[ {info}✔{rst} ] {p}Variables added or redefined:{rst}"$'\n'"$REPLY" + [[ -n "$REPLY" ]] && +zi-message "{p}Variables added or redefined:{rst}"$'\n'"$REPLY" # Print what completions plugin has .zi-find-completions-of-plugin "$user" "$plugin" typeset -a completions @@ -1318,7 +1315,7 @@ fi if (( was_snippet )) { .zi-exists-physically "$user" "$plugin" || return $retval .zi-any-colorify-as-uspl2 "$2" "$3" - (( !OPTS[opt_-q,--quiet] )) && +zi-message "[ {p}¤{rst} ] {msg2}Updating also \`$REPLY{rst}{msg2}' plugin (already updated a snippet of the same name){…}{rst}" + (( !OPTS[opt_-q,--quiet] )) && +zi-message "{msg2}Updating also \`$REPLY{rst}{msg2}' plugin (already updated a snippet of the same name){…}{rst}" } else { .zi-exists-physically-message "$user" "$plugin" || return 1 } @@ -1355,7 +1352,7 @@ fi if [[ ${#${(M)config[@]:#\[remote[[:blank:]]*\]}} -eq 0 ]]; then (( !OPTS[opt_-q,--quiet] )) && { .zi-any-colorify-as-uspl2 "$id_as" - [[ $id_as = _local/* ]] && +zi-message "[ {p}¤{rst} ] {info2}Skipping local plugin $REPLY{rst}" || +zi-message "[ {p}¤{rst} ] {info2} $REPLY doesn't have a remote set, will not fetch{rst}" + [[ $id_as = _local/* ]] && +zi-message "{info2}Skipping local plugin $REPLY{rst}" || +zi-message "{info2} $REPLY doesn't have a remote set, will not fetch{rst}" } return 1 fi @@ -1395,7 +1392,7 @@ fi } } if (( ZI[annex-multi-flag:pull-active] <= 1 && !OPTS[opt_-q,--quiet] )) { - +zi-message "[ {info}✔{rst} ] Binary{rst}: {obj2}$version{rst} is latest release{rst}" + +zi-message "Binary{ehi}:{rst} {b}{version}${version}{rst} is the latest {info}✔{rst}" } } if (( 1 )) { @@ -1404,7 +1401,7 @@ fi .zi-any-colorify-as-uspl2 "$id_as" (( ZI[first-plugin-mark] )) && { ZI[first-plugin-mark]=0 - } || +zi-message "{nl}[ {p}¤{rst} ] Updating $REPLY{rst}" + } || +zi-message "{nl}Updating $REPLY{rst}" } ICE=( "${(kv)ice[@]}" ) # Run annexes' atpull hooks (the before atpull-ice ones). @@ -1453,7 +1450,7 @@ fi .zi-any-colorify-as-uspl2 "$id_as" (( ZI[first-plugin-mark] )) && { ZI[first-plugin-mark]=0 - } || +zi-message "{nl}[ {p}¤{rst} ] Updating $REPLY{rst}" + } || +zi-message "{nl}Updating $REPLY{rst}" } } +zi-message $line @@ -1475,7 +1472,7 @@ fi .zi-any-colorify-as-uspl2 "$id_as" (( ZI[first-plugin-mark] )) && { ZI[first-plugin-mark]=0 - } || +zi-message "{nl}[ {p}¤{rst} ] Updating $REPLY{rst}" + } || +zi-message "{nl}Updating $REPLY{rst}" } } else { ZI[annex-multi-flag:pull-active]=0 @@ -1680,7 +1677,7 @@ fi .zi-compinit 1 1 &>/dev/null rehash if (( !OPTS[opt_-q,--quiet] )) { - +zi-message "{ok}The update took {num}${SECONDS}{ok} seconds{rst}" + +zi-message "{info}The update took {num}${SECONDS}{info} seconds{rst}" } return $retval } diff --git a/lib/zsh/install.zsh b/lib/zsh/install.zsh index 4971ceda..9757273b 100755 --- a/lib/zsh/install.zsh +++ b/lib/zsh/install.zsh @@ -905,14 +905,14 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col command rm -f ${TMPDIR:-/tmp}/zi-execs.$$.lst ${TMPDIR:-/tmp}/zi.installed_comps.$$.lst ${TMPDIR:-/tmp}/zi.skipped_comps.$$.lst ${TMPDIR:-/tmp}/zi.compiled.$$.lst if [[ ! -d $local_dir/$dirname ]]; then - local id_msg_part="{…} (at label{ehi}:{rst} {id-as}$id_as{rst})" - [[ $update != -u ]] && +zi-message "{nl}{info}Setting up snippet: {url}$sname{rst}${ICE[id-as]:+$id_msg_part}" + local id_msg_part="{…} ({p}at label{ehi}:{rst} {id-as}$id_as{rst})" + [[ $update != -u ]] && +zi-message "{nl}{apo}Snippet{ehi}:{rst} {url}$sname{rst}${ICE[id-as]:+$id_msg_part}" command mkdir -p "$local_dir" fi if [[ $update = -u && ${OPTS[opt_-q,--quiet]} != 1 ]]; then - local id_msg_part="{…} (identified as{ehi}:{rst} {id-as}$id_as{rst})" - +zi-message "{nl}{info2}Updating snippet: {url}$sname{rst}${ICE[id-as]:+$id_msg_part}" + local id_msg_part="{…} ({p}identified as{ehi}: {id-as}$id_as{rst})" + +zi-message "{nl}{apo}Updating snippet{ehi}:{rst} {url}$sname{rst}${ICE[id-as]:+$id_msg_part}" fi # A flag for the annexes. 0 – no new commits, 1 - run-atpull mode, @@ -928,7 +928,7 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col ( () { builtin setopt localoptions noautopushd; builtin cd -q "$local_dir"; } || return 4 (( !OPTS[opt_-q,--quiet] )) && \ - +zi-message "Downloading {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" (with Subversion)"}:-" (with curl, wget, lftp)"}{…}" + +zi-message "Downloading{ehi}:{rst} {apo}\`{url}$sname{apo}\`{rst}${${ICE[svn]+" ({p}with Subversion{rst})"}:-" ({p}with curl, wget, lftp{rst})"}{…}" if (( ${+ICE[svn]} )) { if [[ $update = -u ]] { @@ -962,9 +962,9 @@ builtin source "${ZI[BIN_DIR]}/lib/zsh/side.zsh" || { builtin print -P "${ZI[col # Do the update # The condition is reversed on purpose – to show only the messages on an actual update if (( OPTS[opt_-q,--quiet] )); then - local id_msg_part="{…} (identified as{ehi}: {id-as}$id_as{rst})" - +zi-message "{nl}{info2}Updating snippet {url}${sname}{rst}${ICE[id-as]:+$id_msg_part}" - +zi-message "Downloading {apo}\`{rst}$sname{apo}\`{rst} (with Subversion){…}" + local id_msg_part="{…} ({p}identified as{ehi}: {id-as}$id_as{rst})" + +zi-message "{nl}{apo}Updating snippet{ehi}:{rst} {url}${sname}{rst}${ICE[id-as]:+$id_msg_part}" + +zi-message "Downloading{ehi}:{rst} {apo}\`{rst}$sname{apo}\`{rst} ({p}with Subversion{rst}){…}" fi .zi-mirror-using-svn "$url" "-u" "$dirname" || return 4 } From 332be4cb02fdce8c0fc47db64aca5e6c7a7fb8b7 Mon Sep 17 00:00:00 2001 From: Salvydas Lukosius Date: Sat, 4 Jun 2022 14:26:20 +0100 Subject: [PATCH 9/9] Readme update 05 31 (#168) * Update README.md --- docs/README.md | 390 ++++++++++++++++++++++++++++++------------------- 1 file changed, 237 insertions(+), 153 deletions(-) diff --git a/docs/README.md b/docs/README.md index e71c23c9..87113043 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,158 +1,242 @@ - - - - -
-

- Logo❮ ZI ❯ -

-

- A Swiss Army Knife for Zsh - - Unix Shell -

-

- 《 Report an issue 》 · - 《 Request a Feature 》 · 《 Ask a Question 》 -

-

+
+ + + + + + + + + + + + + + + + +
+

+ ❮ ZI ❯ Logo❮ ZI ❯

A Swiss Army Knife for Zsh - + Unix Shell

+ 《 Report an issue + · + 《 Request a Feature 》 + · + 《 Ask a Question 》

《💡》Search Wiki 《⚡️》 Install - 《💜》Join - 《🌐》Localize - -
- - - - - - - - Version - - - Project License - - - VIM - - - Visual Studio Code - + 《💜》Join + 《🌐》Localize
+

+ Uptime CI + + + Response Time CI + + + Graphs CI + + + Summary CI + +

+ + + + + + + + Version + + + Project License + + + VIM + + + Visual Studio Code + +

+

+ + + +
+ + + +
+ + + + + + + +
+ +
+ + - - - - - - - + + +
+
+

Roadmap

+

See the open issues for a list of proposed features or subjects that needs the support

+

Top feature requests - add your votes using the 👍 reaction)

+

Top issues - add your votes using the 👍 reaction

+

Newest issues +


+

Contributing

+

Work in progress Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you +make will benefit everybody else and are greatly appreciated and our target to support each other. Please read our contribution guidelines" before you start. Thank you for being involved!

+
+

Project assistance

+

If you want to say thank you or/and support the active development.

+

- Add a GitHub Star to the project, and follow Z-Shell organization.

+

- Write interesting articles about the project on:
+ Dev.to, Medium.com, Hacker News, Community.ops.io, Reddit, Twitter or your blog. Let us know so can share your post, especially if it's in other languages or some interesting zshrc configurations

+

Participate in the community by showing the interst to the project, as it may bring us together, then great things may happen. If you would like to participate, but are not sure about what and how - do not hesitate to contact us so we can discuss the situation 👍. We've all been there, we all had to start from something - together is much easier, just need to do the first step 🚀.

+
+

Security

+

- Z-Shell ZI follows good practices of security, but 100% security cannot be assured.

+

- Z-Shell ZI is provided "as is" without any warranty. Use at your own risk.

+

- For more information and to report security issues, please refer to our security documentation.

+
+

Acknowledgements

+

The Z-Shell organization was created to recover the Zdharma organization which was deleted by the owner for an unknown reason. It took a lot of time and offer for all those who liked the project and were depending on it don't want to depend on an unreliable source.

+

ZI, formerly known as zplugin, zinit, is an open-source community project released under the MIT License.

+
+

Authors & contributors

+

Check the list of authors and contributors in this repository and also all other repositories under Z-Shell organization. We will inlclude all showning the interest or dedicated their time to take a part. +

- - - -
- - - -
- - - - - - - - - -
- -
- -## Roadmap - -See the [open issues](https://github.com/z-shell/zi/issues) for a list of proposed features (and known -issues). - -- [Top Feature - Requests](https://github.com/z-shell/zi/issues?q=label%3Aenhancement+is%3Aopen+sort%3Areactions-%2B1-desc) - (Add your votes using the 👍 reaction) -- [Top - issues](https://github.com/z-shell/zi/issues?q=is%3Aissue+is%3Aopen+label%3Abug+sort%3Areactions-%2B1-desc) - (Add your votes using the 👍 reaction) -- [Newest issues](https://github.com/z-shell/zi/issues?q=is%3Aopen+is%3Aissue+label%3Abug) - -## Contributing - -First off, thanks for taking the time to contribute! Contributions are what make the open-source community -such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else -and are **greatly appreciated**. - -Please read [our contribution -guidelines](https://github.com/z-shell/community/blob/main/docs/project/CONTRIBUTING.md), and thank you for -being involved! - -## Project assistance +
+

Credits

+ + Trunk + + + Crowdin | Agile localization for tech companies + + + DigitalOcean Referral Badge + + + Cloudflare + +
-If you want to say **thank you** or/and support the active development of ZI. -- Add a [GitHub Star](https://github.com/z-shell/zi) to the project. -- Write interesting articles about the project on [Dev.to](https://dev.to/), [Medium](https://medium.com/) or - your personal blog. -- **Become a part** - - [join](https://github.com/z-shell/community/issues/new?assignees=&labels=%F0%9F%91%A5+member&template=membership.yml&title=team%3A+) - the project and bring your parts **together!** :) - -## Security - -- Z-Shell ZI follows good practices of security, but 100% security cannot be assured. -- Z-Shell ZI is provided **"as is"** without any **warranty**. Use at your own risk. - -_For more information and to report security issues, please refer to our [security -documentation](https://github.com/z-shell/zi/blob/main/docs/SECURITY.md)._ - -## Acknowledgements - -The [**Z-Shell**](https://github.com/z-shell) was created to recover the `zdharma` organization project which -was deleted by the owner. -We don't want to depend on an unreliable source. -[**ZI**](https://github.com/z-shell/zi), formerly known as zplugin, zinit, is an open-source community project -released under the [MIT License](https://github.com/z-shell/zi/blob/main/LICENSE). - -## Authors & contributors - -The original setup of this repository is by [@ss-o](https://github.com/ss-o). - -For a full list of all authors and contributors, see [the contributors -page](https://github.com/z-shell/zi/contributors). - -

Credits

- - Trunk - - - Crowdin | Agile localization for tech companies - - - DigitalOcean Referral Badge - - - Cloudflare - -