PROJECT RENAME Zplugin → Zinit. Hold your thumbs that everything will

work seamlessly.
This commit is contained in:
Sebastian Gniazdowski 2020-01-18 10:02:05 +01:00
parent a80e2a58d8
commit 1ca8f6856c
9 changed files with 3684 additions and 3619 deletions

View file

@ -1,4 +1,4 @@
#compdef zplugin #compdef zinit
setopt localoptions warncreateglobal typesetsilent setopt localoptions warncreateglobal typesetsilent
@ -7,9 +7,9 @@ local -a expl
typeset -a commands typeset -a commands
commands=( commands=(
zstatus:'overall Zplugin status' zstatus:'overall Zinit status'
times:'statistics on plugin loading times' times:'statistics on plugin loading times'
self-update:'updates Zplugin' self-update:'updates Zinit'
help:'usage information' help:'usage information'
man:'manual' man:'manual'
env-whitelist:'specify names (also patterns) of parameters to be left unchanged during an unload' env-whitelist:'specify names (also patterns) of parameters to be left unchanged during an unload'
@ -52,10 +52,10 @@ commands=(
cdreplay:'replay compdefs (to be done after compinit)' cdreplay:'replay compdefs (to be done after compinit)'
cdclear:'clear compdef replay list' cdclear:'clear compdef replay list'
srv:'control a service, command can be: stop,start,restart,next,quit; `next'' moves the service to another Zshell' 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 `zplugin ice ...'' command' recall:'fetch saved ice modifiers and construct `zinit ice ...'' command'
env-whitelist:'allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose' env-whitelist:'allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose'
bindkeys:'lists bindkeys set up by each plugin' bindkeys:'lists bindkeys set up by each plugin'
module:'manage binary Zsh module shipped with Zplugin, see `zplugin module help''' module:'manage binary Zsh module shipped with Zinit, see `zinit module help'''
run:"execute code inside plugin's folder" run:"execute code inside plugin's folder"
{add-fpath,fpath}:'add plugin folder to $fpath' {add-fpath,fpath}:'add plugin folder to $fpath'
) )
@ -66,7 +66,7 @@ _arguments -C \
case $state in case $state in
command) command)
_describe -t commands "Zplugin command" commands && ret=0 _describe -t commands "Zinit command" commands && ret=0
;; ;;
argument) argument)
@ -89,9 +89,9 @@ case $state in
load|light) load|light)
typeset -a plugins typeset -a plugins
plugins=( "${ZPLGM[PLUGINS_DIR]}"/*(N:t) ) plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) )
plugins=( "${plugins[@]//---//}" ) plugins=( "${plugins[@]//---//}" )
plugins=( "${plugins[@]:#_local/zplugin}" ) plugins=( "${plugins[@]:#_local/zinit}" )
plugins=( "${plugins[@]:#custom}" ) plugins=( "${plugins[@]:#custom}" )
_alternative \ _alternative \
@ -102,9 +102,9 @@ case $state in
run|fpath|add-fpath) run|fpath|add-fpath)
typeset -a plugins typeset -a plugins
plugins=( "${ZPLGM[PLUGINS_DIR]}"/*(N:t) ) plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) )
plugins=( "${plugins[@]//---//}" ) plugins=( "${plugins[@]//---//}" )
plugins=( "${plugins[@]:#_local/zplugin}" ) plugins=( "${plugins[@]:#_local/zinit}" )
plugins=( "${plugins[@]:#custom}" ) plugins=( "${plugins[@]:#custom}" )
local -a opts local -a opts
@ -124,22 +124,22 @@ case $state in
compile|stress|edit|glance|recall|update|status|cd|changes|delete) compile|stress|edit|glance|recall|update|status|cd|changes|delete)
# Plugins # Plugins
typeset -a plugins typeset -a plugins
plugins=( "${ZPLGM[PLUGINS_DIR]}"/*(N:t) ) plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N:t) )
plugins=( "${plugins[@]//---//}" ) plugins=( "${plugins[@]//---//}" )
plugins=( "${plugins[@]:#_local/zplugin}" ) plugins=( "${plugins[@]:#_local/zinit}" )
plugins=( "${plugins[@]:#custom}" ) plugins=( "${plugins[@]:#custom}" )
# Snippets # Snippets
local -a snippets snippets_alreadyld local -a snippets snippets_alreadyld
local sni local sni
snippets=( "${ZPLGM[SNIPPETS_DIR]}"/**/._zplugin(D/:h) ) snippets=( "${ZINIT[SNIPPETS_DIR]}"/**/._zinit(D/:h) )
snippets=( ${snippets[@]#${ZPLGM[SNIPPETS_DIR]}/} ) snippets=( ${snippets[@]#${ZINIT[SNIPPETS_DIR]}/} )
snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} )
snippets=( ${snippets[@]/--//} ) snippets=( ${snippets[@]/--//} )
for sni ( ${snippets[@]} ) { for sni ( ${snippets[@]} ) {
if [[ -n ${ZPLG_SNIPPETS[$sni]} ]]; then if [[ -n ${ZINIT_SNIPPETS[$sni]} ]]; then
snippets_alreadyld+=( $sni ) snippets_alreadyld+=( $sni )
snippets=( ${snippets[@]:#$sni} ) snippets=( ${snippets[@]:#$sni} )
fi fi
@ -153,7 +153,7 @@ case $state in
unload|report) unload|report)
typeset -a plugins absolute normal typeset -a plugins absolute normal
plugins=( "${ZPLG_REGISTERED_PLUGINS[@]:#_local/zplugin}" ) plugins=( "${ZINIT_REGISTERED_PLUGINS[@]:#_local/zinit}" )
normal=( "${plugins[@]:#%*}" ) normal=( "${plugins[@]:#%*}" )
absolute=( "${(M)plugins[@]:#%*}" ) absolute=( "${(M)plugins[@]:#%*}" )
absolute=( "${absolute[@]/\%\/\//%/}" ) absolute=( "${absolute[@]/\%\/\//%/}" )
@ -185,7 +185,7 @@ case $state in
cdisable) cdisable)
# Find enabled completions # Find enabled completions
typeset -a completions typeset -a completions
completions=( "${ZPLGM[COMPLETIONS_DIR]}"/_*(N:t) ) completions=( "${ZINIT[COMPLETIONS_DIR]}"/_*(N:t) )
completions=( "${completions[@]#_}" ) completions=( "${completions[@]#_}" )
_wanted plugins expl "-- Completion --" \ _wanted plugins expl "-- Completion --" \
compadd "$@" -a - completions && \ compadd "$@" -a - completions && \
@ -195,7 +195,7 @@ case $state in
cenable) cenable)
# Find disabled # Find disabled
typeset -a completions typeset -a completions
completions=( "${ZPLGM[COMPLETIONS_DIR]}"/[^_]*(N:t) ) completions=( "${ZINIT[COMPLETIONS_DIR]}"/[^_]*(N:t) )
_wanted plugins expl "-- Completion --" \ _wanted plugins expl "-- Completion --" \
compadd "$@" -a - completions && \ compadd "$@" -a - completions && \
ret=0 ret=0
@ -207,7 +207,7 @@ case $state in
# for completions that can be installed # for completions that can be installed
typeset -a plugins completions typeset -a plugins completions
local p c user plugin local p c user plugin
for p in "${ZPLGM[PLUGINS_DIR]}"/*; do for p in "${ZINIT[PLUGINS_DIR]}"/*; do
completions=( "$p"/**/_[^_.][^.]#(N) ) completions=( "$p"/**/_[^_.][^.]#(N) )
for c in "${completions[@]}"; do for c in "${completions[@]}"; do
p="${p:t}" p="${p:t}"
@ -228,13 +228,13 @@ case $state in
# it has completions that are installed # it has completions that are installed
typeset -a plugins completions typeset -a plugins completions
local p c user plugin local p c user plugin
for p in "${ZPLGM[PLUGINS_DIR]}"/*; do for p in "${ZINIT[PLUGINS_DIR]}"/*; do
completions=( "$p"/**/_[^_.][^.]#(N) ) completions=( "$p"/**/_[^_.][^.]#(N) )
for c in "${completions[@]}"; do for c in "${completions[@]}"; do
cfile="${c:t}" cfile="${c:t}"
bkpfile="${cfile#_}" bkpfile="${cfile#_}"
# Completion installed, either enabled or disabled? # Completion installed, either enabled or disabled?
if [[ -e "${ZPLGM[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZPLGM[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then if [[ -e "${ZINIT[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZINIT[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
p="${p:t}" p="${p:t}"
user="${p%%---*}" user="${p%%---*}"
plugin="${p#*---}" plugin="${p#*---}"
@ -257,13 +257,13 @@ case $state in
local -a snippets snippets_alreadyld local -a snippets snippets_alreadyld
local sni local sni
snippets=( "${ZPLGM[SNIPPETS_DIR]}"/**/._zplugin(D/:h) ) snippets=( "${ZINIT[SNIPPETS_DIR]}"/**/._zinit(D/:h) )
snippets=( ${snippets[@]#${ZPLGM[SNIPPETS_DIR]}/} ) snippets=( ${snippets[@]#${ZINIT[SNIPPETS_DIR]}/} )
snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} ) snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} )
snippets=( ${snippets[@]/--//} ) snippets=( ${snippets[@]/--//} )
for sni ( ${snippets[@]} ) { for sni ( ${snippets[@]} ) {
if [[ -n ${ZPLG_SNIPPETS[$sni]} ]]; then if [[ -n ${ZINIT_SNIPPETS[$sni]} ]]; then
snippets_alreadyld+=( $sni ) snippets_alreadyld+=( $sni )
snippets=( ${snippets[@]:#$sni} ) snippets=( ${snippets[@]:#$sni} )
fi fi
@ -301,14 +301,14 @@ case $state in
uncompile) uncompile)
typeset -a plugins typeset -a plugins
plugins=( "${ZPLGM[PLUGINS_DIR]}"/*(N) ) plugins=( "${ZINIT[PLUGINS_DIR]}"/*(N) )
typeset -a show_plugins p matches typeset -a show_plugins p matches
for p in "${plugins[@]}"; do for p in "${plugins[@]}"; do
matches=( $p/*.zwc(N) ) matches=( $p/*.zwc(N) )
if [ "$#matches" -ne "0" ]; then if [ "$#matches" -ne "0" ]; then
p="${p:t}" p="${p:t}"
[ "$p" = "_local---zplugin" ] && continue [ "$p" = "_local---zinit" ] && continue
[ "$p" = "custom" ] && continue [ "$p" = "custom" ] && continue
p="${p//---//}" p="${p//---//}"
show_plugins+=( "$p" ) show_plugins+=( "$p" )

View file

@ -9,8 +9,8 @@
.zcalc_history .zcalc_history
# A popular plugin manager's files # A popular plugin manager's files
._zplugin ._zinit
.zplugin_lstupd .zinit_lastupd
# zdharma/zshelldoc tool's files # zdharma/zshelldoc tool's files
zsdoc/data zsdoc/data

View file

@ -4,17 +4,19 @@
# Clone or pull # Clone or pull
# #
if [ -z "$ZPLG_HOME" ]; then ZINIT_HOME="${ZINIT_HOME:-$ZPLG_HOME}"
ZPLG_HOME="${ZDOTDIR:-$HOME}/.zplugin" if [ -z "$ZINIT_HOME" ]; then
ZINIT_HOME="${ZDOTDIR:-$HOME}/.zinit"
fi fi
if [ -z "$ZPLG_BIN_DIR_NAME" ]; then ZINIT_BIN_DIR_NAME="${ZINIT_BIN_DIR_NAME:-$ZPLG_BIN_DIR_NAME}"
ZPLG_BIN_DIR_NAME="bin" if [ -z "$ZINIT_BIN_DIR_NAME" ]; then
ZINIT_BIN_DIR_NAME="bin"
fi fi
if ! test -d "$ZPLG_HOME"; then if ! test -d "$ZINIT_HOME"; then
mkdir "$ZPLG_HOME" mkdir "$ZINIT_HOME"
chmod g-rwX "$ZPLG_HOME" chmod g-rwX "$ZINIT_HOME"
fi fi
if ! command -v git >/dev/null 2>&1; then if ! command -v git >/dev/null 2>&1; then
@ -24,34 +26,34 @@ fi
# Get the download-progress bar tool # Get the download-progress bar tool
if command -v curl >/dev/null 2>&1; then if command -v curl >/dev/null 2>&1; then
mkdir -p /tmp/zplugin mkdir -p /tmp/zinit
cd /tmp/zplugin cd /tmp/zinit
curl -fsSLO https://raw.githubusercontent.com/zdharma/zplugin/master/git-process-output.zsh && \ curl -fsSLO https://raw.githubusercontent.com/zdharma/zinit/master/git-process-output.zsh && \
chmod +x /tmp/zplugin/git-process-output.zsh chmod +x /tmp/zinit/git-process-output.zsh
elif command -v wget >/dev/null 2>&1; then elif command -v wget >/dev/null 2>&1; then
mkdir -p /tmp/zplugin mkdir -p /tmp/zinit
cd /tmp/zplugin cd /tmp/zinit
wget -q https://raw.githubusercontent.com/zdharma/zplugin/master/git-process-output.zsh && \ wget -q https://raw.githubusercontent.com/zdharma/zinit/master/git-process-output.zsh && \
chmod +x /tmp/zplugin/git-process-output.zsh chmod +x /tmp/zinit/git-process-output.zsh
fi fi
echo echo
echo "▓▒░ Installing zplugin at $ZPLG_HOME/$ZPLG_BIN_DIR_NAME" echo "▓▒░ Installing DHARMA Initiative Plugin Manager at $ZINIT_HOME/$ZINIT_BIN_DIR_NAME"
if test -d "$ZPLG_HOME/$ZPLG_BIN_DIR_NAME/.git"; then if test -d "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME/.git"; then
cd "$ZPLG_HOME/$ZPLG_BIN_DIR_NAME" cd "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME"
git pull origin master git pull origin master
else else
cd "$ZPLG_HOME" cd "$ZINIT_HOME"
{ git clone --progress https://github.com/zdharma/zplugin.git "$ZPLG_BIN_DIR_NAME" \ { git clone --progress https://github.com/zdharma/zinit.git "$ZINIT_BIN_DIR_NAME" \
2>&1 | { /tmp/zplugin/git-process-output.zsh || cat; } } 2>/dev/null 2>&1 | { /tmp/zinit/git-process-output.zsh || cat; } } 2>/dev/null
if [ -d "$ZPLG_BIN_DIR_NAME" ]; then if [ -d "$ZINIT_BIN_DIR_NAME" ]; then
echo echo
echo "▓▒░ Zplugin succesfully installed at $ZPLG_HOME/$ZPLG_BIN_DIR_NAME" echo "▓▒░ Zinit succesfully installed at $ZINIT_HOME/$ZINIT_BIN_DIR_NAME"
VERSION="$(cat "$ZPLG_HOME/$ZPLG_BIN_DIR_NAME/.git/refs/heads/master" | cut -c1-10)" VERSION="$(cat "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME/.git/refs/heads/master" | cut -c1-10)"
echo "▓▒░ Version: $VERSION" echo "▓▒░ Version: $VERSION"
else else
echo echo
echo "▓▒░ Something went wrong, couldn't install Zplugin at $ZPLG_HOME/$ZPLG_BIN_DIR_NAME" echo "▓▒░ Something went wrong, couldn't install Zinit at $ZINIT_HOME/$ZINIT_BIN_DIR_NAME"
fi fi
fi fi
@ -59,26 +61,26 @@ fi
# Modify .zshrc # Modify .zshrc
# #
THE_ZDOTDIR="${ZDOTDIR:-$HOME}" THE_ZDOTDIR="${ZDOTDIR:-$HOME}"
if grep zplugin "$THE_ZDOTDIR/.zshrc" >/dev/null 2>&1; then if grep zinit\\.zsh "$THE_ZDOTDIR/.zshrc" >/dev/null 2>&1; then
echo "▓▒░ .zshrc already updated, not making changes" echo "▓▒░ .zshrc already updated, not making changes"
exit 0 exit 0
fi fi
echo "▓▒░ Updating $THE_ZDOTDIR/.zshrc (10 lines of code, at the bottom)" echo "▓▒░ Updating $THE_ZDOTDIR/.zshrc (10 lines of code, at the bottom)"
ZPLG_HOME="$(echo $ZPLG_HOME | sed "s|$HOME|\$HOME|")" ZINIT_HOME="$(echo $ZINIT_HOME | sed "s|$HOME|\$HOME|")"
cat <<-EOF >> "$THE_ZDOTDIR/.zshrc" cat <<-EOF >> "$THE_ZDOTDIR/.zshrc"
### Added by Zplugin's installer ### Added by Zinit's installer
if [[ ! -d $ZPLG_HOME/$ZPLG_BIN_DIR_NAME ]]; then if [[ ! -f $ZINIT_HOME/$ZINIT_BIN_DIR_NAME/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing Zplugin…%f" print -P "%F{33}▓▒░ %F{220}Installing DHARMA Initiative Plugin Manager (zdharma/zinit)…%f"
command mkdir -p $ZPLG_HOME command mkdir -p $ZINIT_HOME
command git clone https://github.com/zdharma/zplugin $ZPLG_HOME/$ZPLG_BIN_DIR_NAME && \\ command git clone https://github.com/zdharma/zinit $ZINIT_HOME/$ZINIT_BIN_DIR_NAME && \\
print -P "%F{33}▓▒░ %F{34}Installation successful.%F" || \\ print -P "%F{33}▓▒░ %F{34}Installation successful.%F" || \\
print -P "%F{160}▓▒░ The clone has failed.%F" print -P "%F{160}▓▒░ The clone has failed.%F"
fi fi
source "$ZPLG_HOME/$ZPLG_BIN_DIR_NAME/zplugin.zsh" source "$ZINIT_HOME/$ZINIT_BIN_DIR_NAME/zinit.zsh"
autoload -Uz _zplugin autoload -Uz _zinit
(( \${+_comps} )) && _comps[zplugin]=_zplugin (( \${+_comps} )) && _comps[zinit]=_zinit
### End of Zplugin installer's chunk ### End of Zinit installer's chunk
EOF EOF
echo "▓▒░ Done" echo "▓▒░ Done"

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,12 @@
# -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*- # -*- mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# Copyright (c) 2019 Sebastian Gniazdowski and contributors # Copyright (c) 2019 Sebastian Gniazdowski and contributors
# FUNCTION: -zplg-shands-exp {{{ # FUNCTION: .zinit-shands-exp <<<
# Does expansion of currently little unstandarized # Does expansion of currently little unstandarized
# shorthands like "%SNIPPETS", "%HOME", "OMZ::", "PZT::". # shorthands like "%SNIPPETS", "%HOME", "OMZ::", "PZT::".
-zplg-shands-exp() { .zinit-shands-exp() {
REPLY="$1$2" REPLY="$1$2"
REPLY="${${${REPLY/\%HOME/$HOME}/\%SNIPPETS/${ZPLGM[SNIPPETS_DIR]}}#%}" REPLY="${${${REPLY/\%HOME/$HOME}/\%SNIPPETS/${ZINIT[SNIPPETS_DIR]}}#%}"
#REPLY="${REPLY/OMZ::/https--github.com--robbyrussell--oh-my-zsh--trunk--}" #REPLY="${REPLY/OMZ::/https--github.com--robbyrussell--oh-my-zsh--trunk--}"
#REPLY="${REPLY/\/OMZ//https--github.com--robbyrussell--oh-my-zsh--trunk}" #REPLY="${REPLY/\/OMZ//https--github.com--robbyrussell--oh-my-zsh--trunk}"
#REPLY="${REPLY/PZT::/https--github.com--sorin-ionescu--prezto--trunk--}" #REPLY="${REPLY/PZT::/https--github.com--sorin-ionescu--prezto--trunk--}"
@ -15,28 +15,28 @@
# Testable # Testable
[[ "$REPLY" != "$1$2" ]] [[ "$REPLY" != "$1$2" ]]
} }
# }}} # >>>
# FUNCTION: -zplg-exists-physically {{{ # FUNCTION: .zinit-exists-physically <<<
# Checks if directory of given plugin exists in PLUGIN_DIR. # Checks if directory of given plugin exists in PLUGIN_DIR.
# #
# Testable. # Testable.
# #
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given) # $2 - plugin (only when $1 - i.e. user - given)
-zplg-exists-physically() { .zinit-exists-physically() {
-zplg-any-to-user-plugin "$1" "$2" .zinit-any-to-user-plugin "$1" "$2"
if [[ "${reply[-2]}" = "%" ]]; then if [[ "${reply[-2]}" = "%" ]]; then
# Shorthands, little unstandarized # Shorthands, little unstandarized
-zplg-shands-exp "$1" "$2" && { .zinit-shands-exp "$1" "$2" && {
[[ -d "$REPLY" ]] && return 0 || return 1 [[ -d "$REPLY" ]] && return 0 || return 1
} || { } || {
[[ -d "${reply[-1]}" ]] && return 0 || return 1 [[ -d "${reply[-1]}" ]] && return 0 || return 1
} }
else else
[[ -d "${ZPLGM[PLUGINS_DIR]}/${reply[-2]:+${reply[-2]}---}${reply[-1]//\//---}" ]] && return 0 || return 1 [[ -d "${ZINIT[PLUGINS_DIR]}/${reply[-2]:+${reply[-2]}---}${reply[-1]//\//---}" ]] && return 0 || return 1
fi fi
} # }}} } # >>>
# FUNCTION: -zplg-exists-physically-message {{{ # FUNCTION: .zinit-exists-physically-message <<<
# Checks if directory of given plugin exists in PLUGIN_DIR, # Checks if directory of given plugin exists in PLUGIN_DIR,
# and outputs error message if it doesn't. # and outputs error message if it doesn't.
# #
@ -44,56 +44,56 @@
# #
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given) # $2 - plugin (only when $1 - i.e. user - given)
-zplg-exists-physically-message() { .zinit-exists-physically-message() {
if ! -zplg-exists-physically "$1" "$2"; then if ! .zinit-exists-physically "$1" "$2"; then
-zplg-any-colorify-as-uspl2 "$1" "$2" .zinit-any-colorify-as-uspl2 "$1" "$2"
local spec="$REPLY" local spec="$REPLY"
-zplg-shands-exp "$1" "$2" && REPLY="${REPLY/$HOME/~}" .zinit-shands-exp "$1" "$2" && REPLY="${REPLY/$HOME/~}"
print -r -- "${ZPLGM[col-error]}No such (plugin or snippet) directory${ZPLGM[col-rst]}: $spec" print -r -- "${ZINIT[col-error]}No such (plugin or snippet) directory${ZINIT[col-rst]}: $spec"
[[ "$REPLY" != "$1$2" ]] && print -r -- "(expands to: $REPLY)" [[ "$REPLY" != "$1$2" ]] && print -r -- "(expands to: $REPLY)"
return 1 return 1
fi fi
return 0 return 0
} # }}} } # >>>
# FUNCTION: -zplg-plgdir {{{ # FUNCTION: .zinit-plgdir <<<
-zplg-get-plg-dir() { .zinit-get-plg-dir() {
# There are plugins having ".plugin.zsh" # There are plugins having ".plugin.zsh"
# in ${plugin} directory name, also some # in ${plugin} directory name, also some
# have ".zsh" there # have ".zsh" there
local dname="${ZPLGM[alias-map-${user:+${user}/}$plugin]}" local dname="${ZINIT[alias-map-${user:+${user}/}$plugin]}"
local pdir="${${${${plugin:t}%.plugin.zsh}%.zsh}%.git}" local pdir="${${${${plugin:t}%.plugin.zsh}%.zsh}%.git}"
[[ -z "$dname" ]] && { [[ -z "$dname" ]] && {
[[ "$user" = "%" ]] && dname="$plugin" || \ [[ "$user" = "%" ]] && dname="$plugin" || \
dname="${ZPLGM[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}" dname="${ZINIT[PLUGINS_DIR]}/${user:+${user}---}${plugin//\//---}"
} }
reply=( "$dname" "$pdir" ) reply=( "$dname" "$pdir" )
return 0 return 0
} }
# }}} # >>>
# FUNCTION: -zplg-first {{{ # FUNCTION: .zinit-first <<<
# Finds the main file of plugin. There are multiple file name # Finds the main file of plugin. There are multiple file name
# formats, they are ordered in order starting from more correct # formats, they are ordered in order starting from more correct
# ones, and matched. -zplg-load-plugin() has similar code parts # ones, and matched. .zinit-load-plugin() has similar code parts
# and doesn't call -zplg-first() for performance. Obscure matching # and doesn't call .zinit-first() for performance. Obscure matching
# is done in -zplg-find-other-matches, here and in -zplg-load(). # is done in .zinit-find-other-matches, here and in .zinit-load().
# Obscure = non-standard main-file naming convention. # Obscure = non-standard main-file naming convention.
# #
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given) # $2 - plugin (only when $1 - i.e. user - given)
-zplg-first() { .zinit-first() {
-zplg-any-to-user-plugin "$1" "$2" .zinit-any-to-user-plugin "$1" "$2"
local user="${reply[-2]}" plugin="${reply[-1]}" local user="${reply[-2]}" plugin="${reply[-1]}"
-zplg-get-plg-dir "$user" "$plugin" .zinit-get-plg-dir "$user" "$plugin"
local dname="${reply[-2]}" local dname="${reply[-2]}"
# Look for file to compile. First look for the most common one # Look for file to compile. First look for the most common one
# (optimization) then for other possibilities # (optimization) then for other possibilities
if [[ ! -e "$dname/${reply[-1]}.plugin.zsh" ]]; then if [[ ! -e "$dname/${reply[-1]}.plugin.zsh" ]]; then
-zplg-find-other-matches "$dname" "${reply[-1]}" .zinit-find-other-matches "$dname" "${reply[-1]}"
else else
reply=( "$dname/${reply[-1]}.plugin.zsh" ) reply=( "$dname/${reply[-1]}.plugin.zsh" )
fi fi
@ -106,32 +106,32 @@
# Take first entry (ksharrays resilience) # Take first entry (ksharrays resilience)
reply=( "$dname" "${reply[-${#reply}]}" ) reply=( "$dname" "${reply[-${#reply}]}" )
return 0 return 0
} # }}} } # >>>
# FUNCTION: -zplg-any-colorify-as-uspl2 {{{ # FUNCTION: .zinit-any-colorify-as-uspl2 <<<
# Returns ANSI-colorified "user/plugin" string, from any supported # Returns ANSI-colorified "user/plugin" string, from any supported
# plugin spec (user---plugin, user/plugin, user plugin, plugin). # plugin spec (user---plugin, user/plugin, user plugin, plugin).
# #
# $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin) # $1 - plugin spec (4 formats: user---plugin, user/plugin, user, plugin)
# $2 - plugin (only when $1 - i.e. user - given) # $2 - plugin (only when $1 - i.e. user - given)
# $REPLY = ANSI-colorified "user/plugin" string # $REPLY = ANSI-colorified "user/plugin" string
-zplg-any-colorify-as-uspl2() { .zinit-any-colorify-as-uspl2() {
-zplg-any-to-user-plugin "$1" "$2" .zinit-any-to-user-plugin "$1" "$2"
local user="${reply[-2]}" plugin="${reply[-1]}" local user="${reply[-2]}" plugin="${reply[-1]}"
[[ "$user" = "%" ]] && { [[ "$user" = "%" ]] && {
plugin="${plugin/${ZPLGM[SNIPPETS_DIR]}/SNIPPETS}" plugin="${plugin/${ZINIT[SNIPPETS_DIR]}/SNIPPETS}"
plugin="${plugin/https--github.com--robbyrussell--oh-my-zsh--trunk--/OMZ::}" plugin="${plugin/https--github.com--robbyrussell--oh-my-zsh--trunk--/OMZ::}"
plugin="${plugin/https--github.com--robbyrussell--oh-my-zsh--trunk/OMZ}" plugin="${plugin/https--github.com--robbyrussell--oh-my-zsh--trunk/OMZ}"
plugin="${plugin/https--github.com--sorin-ionescu--prezto--trunk--/PZT::}" plugin="${plugin/https--github.com--sorin-ionescu--prezto--trunk--/PZT::}"
plugin="${plugin/https--github.com--sorin-ionescu--prezto--trunk/PZT}" plugin="${plugin/https--github.com--sorin-ionescu--prezto--trunk/PZT}"
plugin="${plugin/$HOME/HOME}" plugin="${plugin/$HOME/HOME}"
REPLY="${ZPLGM[col-uname]}%${ZPLGM[col-rst]}${ZPLGM[col-pname]}${plugin}${ZPLGM[col-rst]}" REPLY="${ZINIT[col-uname]}%${ZINIT[col-rst]}${ZINIT[col-pname]}${plugin}${ZINIT[col-rst]}"
} || REPLY="${user:+${ZPLGM[col-uname]}${user}${ZPLGM[col-rst]}/}${ZPLGM[col-pname]}${plugin}${ZPLGM[col-rst]}" } || REPLY="${user:+${ZINIT[col-uname]}${user}${ZINIT[col-rst]}/}${ZINIT[col-pname]}${plugin}${ZINIT[col-rst]}"
} # }}} } # >>>
# FUNCTION: -zplg-two-paths {{{ # FUNCTION: .zinit-two-paths <<<
# Obtains a snippet URL without specification if it is an SVN URL (points to # 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 # directory) or regular URL (points to file), returns 2 possible paths for
# further examination # further examination
-zplg-two-paths() { .zinit-two-paths() {
setopt localoptions extendedglob nokshglob noksharrays noshwordsplit setopt localoptions extendedglob nokshglob noksharrays noshwordsplit
local url="$1" url1 url2 local_dirA svn_dirA local_dirB dirnameA dirnameB local url="$1" url1 url2 local_dirA svn_dirA local_dirB dirnameA dirnameB
local -a fileB_there local -a fileB_there
@ -140,48 +140,49 @@
url="${${url#"${url%%[! $'\t']*}"}%/}" url="${${url#"${url%%[! $'\t']*}"}%/}"
url1="$url" url2="$url" url1="$url" url2="$url"
#url1[1,5]="${ZPLG_1MAP[${url[1,5]}]:-${url[1,5]}}" # svn #url1[1,5]="${ZINIT_1MAP[${url[1,5]}]:-${url[1,5]}}" # svn
#url2[1,5]="${ZPLG_2MAP[${url[1,5]}]:-${url[1,5]}}" # normal #url2[1,5]="${ZINIT_2MAP[${url[1,5]}]:-${url[1,5]}}" # normal
dirnameA="${${url1%%\?*}:t}" dirnameA="${${url1%%\?*}:t}"
local_dirA="${${${url1%%\?*}:h}/:\/\//--}" local_dirA="${${${url1%%\?*}:h}/:\/\//--}"
[[ "$local_dirA" = "." ]] && local_dirA="" || local_dirA="${${${${${local_dirA#/}//\//--}//=/--EQ--}//\?/--QM--}//\&/--AMP--}" [[ "$local_dirA" = "." ]] && local_dirA="" || local_dirA="${${${${${local_dirA#/}//\//--}//=/--EQ--}//\?/--QM--}//\&/--AMP--}"
local_dirA="${ZPLGM[SNIPPETS_DIR]}${local_dirA:+/$local_dirA}" local_dirA="${ZINIT[SNIPPETS_DIR]}${local_dirA:+/$local_dirA}"
[[ -d "$local_dirA/$dirnameA/.svn" ]] && svn_dirA=".svn" [[ -d "$local_dirA/$dirnameA/.svn" ]] && svn_dirA=".svn"
dirnameB="${${url2%%\?*}:t}" dirnameB="${${url2%%\?*}:t}"
local_dirB="${${${url2%%\?*}:h}/:\/\//--}" local_dirB="${${${url2%%\?*}:h}/:\/\//--}"
[[ "$local_dirB" = "." ]] && local_dirB="" || local_dirB="${${${${${local_dirB#/}//\//--}//=/--EQ--}//\?/--QM--}//\&/--AMP--}" [[ "$local_dirB" = "." ]] && local_dirB="" || local_dirB="${${${${${local_dirB#/}//\//--}//=/--EQ--}//\?/--QM--}//\&/--AMP--}"
local_dirB="${ZPLGM[SNIPPETS_DIR]}${local_dirB:+/$local_dirB}" local_dirB="${ZINIT[SNIPPETS_DIR]}${local_dirB:+/$local_dirB}"
fileB_there=( "$local_dirB/$dirnameB"/*~*.zwc(.DOnN[1]) ) fileB_there=( "$local_dirB/$dirnameB"/*~*.zwc(.DOnN[1]) )
reply=( "$local_dirA/$dirnameA" "$svn_dirA" "$local_dirB/$dirnameB" "${fileB_there[1]##$local_dirB/$dirnameB/#}" ) reply=( "$local_dirA/$dirnameA" "$svn_dirA" "$local_dirB/$dirnameB" "${fileB_there[1]##$local_dirB/$dirnameB/#}" )
} }
# }}} # >>>
# FUNCTION: -zplg-compute-ice {{{ # FUNCTION: .zinit-compute-ice <<<
# Computes ZPLG_ICE array (default, it can be specified via $3) from a) input # Computes ZINIT_ICE array (default, it can be specified via $3) from a) input
# ZPLG_ICE, b) static ice, c) saved ice, taking priorities into account. Also # ZINIT_ICE, b) static ice, c) saved ice, taking priorities into account. Also
# returns path to snippet directory and optional name of snippet file (only # returns path to snippet directory and optional name of snippet file (only
# valid if ZPLG_ICE[svn] is not set). # valid if ZINIT_ICE[svn] is not set).
# #
# Can also pack resulting ices into ZPLG_SICE (see $2). # Can also pack resulting ices into ZINIT_SICE (see $2).
# #
# $1 - URL (also plugin-spec) # $1 - URL (also plugin-spec)
# $2 - "pack" or "nopack" or "pack-nf" - packing means ZPLG_ICE # $2 - "pack" or "nopack" or "pack-nf" - packing means ZINIT_ICE
# wins with static ice; "pack-nf" means that disk-ices will # wins with static ice; "pack-nf" means that disk-ices will
# be ignored (no-file?) # be ignored (no-file?)
# $3 - name of output associative array, "ZPLG_ICE" is the default # $3 - name of output associative array, "ZINIT_ICE" is the default
# $4 - name of output string parameter, to hold path to directory ("local_dir") # $4 - name of output string parameter, to hold path to directory ("local_dir")
# $5 - name of output string parameter, to hold filename ("filename") # $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") # $6 - name of output string parameter, to hold is-snippet 0/1-bool ("is_snippet")
-zplg-compute-ice() { .zinit-compute-ice() {
setopt localoptions extendedglob nokshglob noksharrays emulate -LR zsh
setopt extendedglob typesetsilent warncreateglobal noshortloops
local __URL="${1%/}" __pack="$2" __is_snippet=0 local __URL="${1%/}" __pack="$2" __is_snippet=0
local __var_name1="${3:-ZPLG_ICE}" __var_name2="${4:-local_dir}" \ local __var_name1="${3:-ZINIT_ICE}" __var_name2="${4:-local_dir}" \
__var_name3="${5:-filename}" __var_name4="${6:-is_snippet}" __var_name3="${5:-filename}" __var_name4="${6:-is_snippet}"
# Copy from -zplg-recall # Copy from .zinit-recall
local -a ice_order nval_ices local -a ice_order nval_ices
ice_order=( ice_order=(
svn proto from teleid bindmap cloneopts id-as depth if wait load svn proto from teleid bindmap cloneopts id-as depth if wait load
@ -194,7 +195,7 @@
subscribe param subscribe param
# Include all additional ices after # Include all additional ices after
# stripping them from the possible: '' # stripping them from the possible: ''
${(@us.|.)${ZPLG_EXTS[ice-mods]//\'\'/}} ${(@us.|.)${ZINIT_EXTS[ice-mods]//\'\'/}}
) )
nval_ices=( nval_ices=(
blockf silent lucid trackbinds cloneonly nocd run-atpull blockf silent lucid trackbinds cloneonly nocd run-atpull
@ -204,7 +205,7 @@
# Include only those additional ices, # Include only those additional ices,
# don't have the '' in their name, i.e. # don't have the '' in their name, i.e.
# aren't designed to hold value # aren't designed to hold value
${(@)${(@s.|.)ZPLG_EXTS[ice-mods]}:#*\'\'*} ${(@)${(@s.|.)ZINIT_EXTS[ice-mods]}:#*\'\'*}
# Must be last # Must be last
svn svn
@ -214,26 +215,26 @@
__URL="${${__URL#"${__URL%%[! $'\t']*}"}%/}" __URL="${${__URL#"${__URL%%[! $'\t']*}"}%/}"
# Snippet? # Snippet?
-zplg-two-paths "$__URL" .zinit-two-paths "$__URL"
local __s_path="${reply[-4]}" __s_svn="${reply[-3]}" ___path="${reply[-2]}" __filename="${reply[-1]}" __local_dir local __s_path="${reply[-4]}" __s_svn="${reply[-3]}" ___path="${reply[-2]}" __filename="${reply[-1]}" __local_dir
if [[ -d "$__s_path" || -d "$___path" ]]; then if [[ -d "$__s_path" || -d "$___path" ]]; then
__is_snippet=1 __is_snippet=1
else else
# Plugin # Plugin
-zplg-shands-exp "$__URL" && __URL="$REPLY" .zinit-shands-exp "$__URL" && __URL="$REPLY"
-zplg-any-to-user-plugin "$__URL" "" .zinit-any-to-user-plugin "$__URL" ""
local __user="${reply[-2]}" __plugin="${reply[-1]}" local __user="${reply[-2]}" __plugin="${reply[-1]}"
__s_path="" __filename="" __s_path="" __filename=""
[[ "$__user" = "%" ]] && ___path="$__plugin" || ___path="${ZPLGM[PLUGINS_DIR]}/${__user:+${__user}---}${__plugin//\//---}" [[ "$__user" = "%" ]] && ___path="$__plugin" || ___path="${ZINIT[PLUGINS_DIR]}/${__user:+${__user}---}${__plugin//\//---}"
-zplg-exists-physically-message "$__user" "$__plugin" || return 1 .zinit-exists-physically-message "$__user" "$__plugin" || return 1
fi fi
[[ $__pack = pack* ]] && (( ${#ZPLG_ICE} > 0 )) && \ [[ $__pack = pack* ]] && (( ${#ZINIT_ICE} > 0 )) && \
-zplg-pack-ice "${__user-$__URL}" "$__plugin" .zinit-pack-ice "${__user-$__URL}" "$__plugin"
local -A __sice local -A __sice
local -a __tmp local -a __tmp
__tmp=( "${(z@)ZPLG_SICE[$__user${${__user:#(%|/)*}:+/}$__plugin]}" ) __tmp=( "${(z@)ZINIT_SICE[$__user${${__user:#(%|/)*}:+/}$__plugin]}" )
(( ${#__tmp[@]} > 1 && ${#__tmp[@]} % 2 == 0 )) && __sice=( "${(Q)__tmp[@]}" ) (( ${#__tmp[@]} > 1 && ${#__tmp[@]} % 2 == 0 )) && __sice=( "${(Q)__tmp[@]}" )
if [[ "${+__sice[svn]}" = "1" || -n "$__s_svn" ]]; then if [[ "${+__sice[svn]}" = "1" || -n "$__s_svn" ]]; then
@ -242,7 +243,7 @@
print -r -- "(\`svn' can be used only with snippets)" print -r -- "(\`svn' can be used only with snippets)"
return 1 return 1
elif (( !__is_snippet )); then elif (( !__is_snippet )); then
print -r -- "Undefined behavior #1 occurred, please report at https://github.com/zdharma/zplugin/issues" print -r -- "Undefined behavior #1 occurred, please report at https://github.com/zdharma/zinit/issues"
return 1 return 1
fi fi
if [[ -e "$__s_path" && -n "$__s_svn" ]]; then if [[ -e "$__s_path" && -n "$__s_svn" ]]; then
@ -263,36 +264,50 @@
fi fi
fi fi
local __zplugin_path="$__local_dir/._zplugin" local __zinit_path="$__local_dir/._zinit"
# Zplugin -> Zinit rename upgrade code
if [[ ! -d $__zinit_path && -d $__local_dir/._zplugin ]]; then
(
print -Pr -- "${ZINIT[col-pre]}UPGRADING THE DIRECTORY STRUCTURE" \
"FOR THE ZPLUGIN -> ZINIT RENAME…%f"
builtin cd -q ${ZINIT[PLUGINS_DIR]} || return 1
autoload -Uz zmv
( zmv -W '**/._zplugin' '**/._zinit' ) &>/dev/null
builtin cd -q ${ZINIT[SNIPPETS_DIR]} || return 1
( zmv -W '**/._zplugin' '**/._zinit' ) &>/dev/null
print -Pr -- "${ZINIT[col-obj]}THE UPGRADE SUCCEDED!%f"
) || print -Pr -- "${ZINIT[col-error]}THE UPGRADE FAILED!%f"
fi
# Read disk-Ice # Read disk-Ice
local -A __mdata local -A __mdata
local __key local __key
{ for __key in mode url is_release ${ice_order[@]}; do { for __key in mode url is_release ${ice_order[@]}; do
[[ -f "$__zplugin_path/$__key" ]] && __mdata[$__key]="$(<$__zplugin_path/$__key)" [[ -f "$__zinit_path/$__key" ]] && __mdata[$__key]="$(<$__zinit_path/$__key)"
done done
[[ "${__mdata[mode]}" = "1" ]] && __mdata[svn]="" [[ "${__mdata[mode]}" = "1" ]] && __mdata[svn]=""
} 2>/dev/null } 2>/dev/null
# Handle flag-Ices; svn must be last # Handle flag-Ices; svn must be last
for __key in ${ice_order[@]}; do for __key in ${ice_order[@]}; do
(( 0 == ${+ZPLG_ICE[no$__key]} && 0 == ${+__sice[no$__key]} )) && continue (( 0 == ${+ZINIT_ICE[no$__key]} && 0 == ${+__sice[no$__key]} )) && continue
# "If there is such ice currently, and there's no no* ice given, # "If there is such ice currently, and there's no no* ice given,
# and there's the no* ice in the static ice" skip, don't unset. # and there's the no* ice in the static ice" skip, don't unset.
# With conjunction with the previous line this has the proper # With conjunction with the previous line this has the proper
# meaning: uset if at least in one  current or static ice # meaning: uset if at least in one  current or static ice
# there's the no* ice, but not if it's only in the static ice # there's the no* ice, but not if it's only in the static ice
# (unless there's on such ice "anyway"). # (unless there's on such ice "anyway").
(( 1 == ${+ZPLG_ICE[$__key]} && 0 == ${+ZPLG_ICE[no$__key]} && \ (( 1 == ${+ZINIT_ICE[$__key]} && 0 == ${+ZINIT_ICE[no$__key]} && \
1 == ${+__sice[no$__key]} )) && continue 1 == ${+__sice[no$__key]} )) && continue
if [[ "$__key" = "svn" ]]; then if [[ "$__key" = "svn" ]]; then
command print -r -- "0" >! "$__zplugin_path/mode" command print -r -- "0" >! "$__zinit_path/mode"
__mdata[mode]=0 __mdata[mode]=0
else else
command rm -f -- "$__zplugin_path/$__key" command rm -f -- "$__zinit_path/$__key"
fi fi
unset "__mdata[$__key]" "__sice[$__key]" "ZPLG_ICE[$__key]" unset "__mdata[$__key]" "__sice[$__key]" "ZINIT_ICE[$__key]"
done done
# Final decision, static ice vs. saved ice # Final decision, static ice vs. saved ice
@ -313,8 +328,8 @@
return 0 return 0
} }
# }}} # >>>
# FUNCTION: -zplg-store-ices {{{ # FUNCTION: .zinit-store-ices <<<
# Saves ice mods in given hash onto disk. # Saves ice mods in given hash onto disk.
# #
# $1 - directory where to create / delete files # $1 - directory where to create / delete files
@ -323,12 +338,12 @@
# $4 - additional keys of hash to store, empty-meaningful ices, space separated # $4 - additional keys of hash to store, empty-meaningful ices, space separated
# $5 the URL, if applicable # $5 the URL, if applicable
# $6 the mode (1 - svn, 0 - single file), if applicable # $6 the mode (1 - svn, 0 - single file), if applicable
-zplg-store-ices() { .zinit-store-ices() {
local __pfx="$1" __ice_var="$2" \ local __pfx="$1" __ice_var="$2" \
__add_ices="$3" __add_ices2="$4" \ __add_ices="$3" __add_ices2="$4" \
url="$5" mode="$6" url="$5" mode="$6"
# Copy from -zplg-recall # Copy from .zinit-recall
local -a ice_order nval_ices local -a ice_order nval_ices
ice_order=( ice_order=(
svn proto from teleid bindmap cloneopts id-as depth if wait load svn proto from teleid bindmap cloneopts id-as depth if wait load
@ -341,7 +356,7 @@
subscribe param subscribe param
# Include all additional ices after # Include all additional ices after
# stripping them from the possible: '' # stripping them from the possible: ''
${(@s.|.)${ZPLG_EXTS[ice-mods]//\'\'/}} ${(@s.|.)${ZINIT_EXTS[ice-mods]//\'\'/}}
) )
nval_ices=( nval_ices=(
blockf silent lucid trackbinds cloneonly nocd run-atpull blockf silent lucid trackbinds cloneonly nocd run-atpull
@ -351,7 +366,7 @@
# Include only those additional ices, # Include only those additional ices,
# don't have the '' in their name, i.e. # don't have the '' in their name, i.e.
# aren't designed to hold value # aren't designed to hold value
${(@)${(@s.|.)ZPLG_EXTS[ice-mods]}:#*\'\'*} ${(@)${(@s.|.)ZINIT_EXTS[ice-mods]}:#*\'\'*}
# Must be last # Must be last
svn svn
@ -381,27 +396,27 @@
[[ -n "${(P)__key}" ]] && print -r -- "${(P)__key}" >! "$__pfx"/"$__key" [[ -n "${(P)__key}" ]] && print -r -- "${(P)__key}" >! "$__pfx"/"$__key"
done done
} }
# }}} # >>>
# FUNCTION: -zplg-countdown {{{ # FUNCTION: .zinit-countdown <<<
# Displays a countdown 5...4... etc. and returns 0 if it # Displays a countdown 5...4... etc. and returns 0 if it
# sucessfully reaches 0, or 1 if Ctrl-C will be pressed. # sucessfully reaches 0, or 1 if Ctrl-C will be pressed.
-zplg-countdown() { .zinit-countdown() {
(( !${+ZPLG_ICE[countdown]} )) && return 0 (( !${+ZINIT_ICE[countdown]} )) && return 0
emulate -L zsh emulate -L zsh
trap "print \"${ZPLGM[col-pname]}ABORTING, the ice not ran${ZPLGM[col-rst]}\"; return 1" INT trap "print \"${ZINIT[col-pname]}ABORTING, the ice not ran${ZINIT[col-rst]}\"; return 1" INT
local count=5 tpe="$1" ice local count=5 tpe="$1" ice
ice="${ZPLG_ICE[$tpe]}" ice="${ZINIT_ICE[$tpe]}"
[[ $tpe = "atpull" && $ice = "%atclone" ]] && ice="${ZPLG_ICE[atclone]}" [[ $tpe = "atpull" && $ice = "%atclone" ]] && ice="${ZINIT_ICE[atclone]}"
ice="$tpe:$ice" ice="$tpe:$ice"
print -nr "${ZPLGM[col-pname]}Running ${ZPLGM[col-bold]}${ZPLGM[col-uname]}$ice${ZPLGM[col-rst]}${ZPLGM[col-pname]} ice in...${ZPLGM[col-rst]} " print -nr "${ZINIT[col-pname]}Running ${ZINIT[col-bold]}${ZINIT[col-uname]}$ice${ZINIT[col-rst]}${ZINIT[col-pname]} ice in...${ZINIT[col-rst]} "
while (( -- count + 1 )) { while (( -- count + 1 )) {
print -nr -- "${ZPLGM[col-bold]}${ZPLGM[col-error]}"$(( count + 1 ))..."${ZPLGM[col-rst]}" print -nr -- "${ZINIT[col-bold]}${ZINIT[col-error]}"$(( count + 1 ))..."${ZINIT[col-rst]}"
sleep 1 sleep 1
} }
print -r -- "${ZPLGM[col-bold]}${ZPLGM[col-error]}0 <running now>...${ZPLGM[col-rst]}" print -r -- "${ZINIT[col-bold]}${ZINIT[col-error]}0 <running now>...${ZINIT[col-rst]}"
return 0 return 0
} }
# }}} # >>>
# vim:ft=zsh:sw=4:sts=4:et # vim:ft=zsh:sw=4:sts=4:et:foldmarker=<<<,>>>

2443
zinit.zsh Normal file

File diff suppressed because it is too large Load diff

View file

@ -847,8 +847,8 @@ custom_try_source_file(char *file)
/* If there is no zwc file, or if it is less recent than script file */ /* If there is no zwc file, or if it is less recent than script file */
if ( ( !rn && ( rc || ( stc.st_mtime < stn.st_mtime ) ) ) && if ( ( !rn && ( rc || ( stc.st_mtime < stn.st_mtime ) ) ) &&
( access( file_dup, W_OK ) == 0 || 0 == strcmp( ( access( file_dup, W_OK ) == 0 || 0 == strcmp(
getsparam( "ZPLG_MOD_DEBUG" ) ? getsparam( "ZINIT_MOD_DEBUG" ) ?
getsparam( "ZPLG_MOD_DEBUG" ) : "0", getsparam( "ZINIT_MOD_DEBUG" ) : "0",
"1" ) ) "1" ) )
) { ) {
char *args[] = { file, NULL }; char *args[] = { file, NULL };
@ -866,8 +866,8 @@ custom_try_source_file(char *file)
bin_zcompile("ZpluginModule_", args, &ops, 0); bin_zcompile("ZpluginModule_", args, &ops, 0);
} else { } else {
if ( 0 == strcmp( if ( 0 == strcmp(
getsparam( "ZPLG_MOD_DEBUG" ) ? getsparam( "ZINIT_MOD_DEBUG" ) ?
getsparam( "ZPLG_MOD_DEBUG" ) : "0", getsparam( "ZINIT_MOD_DEBUG" ) : "0",
"1" ) "1" )
) { ) {
zwarnnam( "ZpluginModule", zwarnnam( "ZpluginModule",
@ -1399,7 +1399,7 @@ void zpmod_usage() {
"Command <report-append>:\n" "Command <report-append>:\n"
"\n" "\n"
"Used by Zplugin internally to speed up loading plugins with tracking (reporting).\n" "Used by Zplugin internally to speed up loading plugins with tracking (reporting).\n"
"It extends the given field {plugin-ID} in $ZPLG_REPORTS hash, with the given string\n" "It extends the given field {plugin-ID} in $ZINIT_REPORTS hash, with the given string\n"
"{new-report-body}.\n" "{new-report-body}.\n"
"\n" "\n"
"Command <source-study>:\n" "Command <source-study>:\n"
@ -1425,14 +1425,14 @@ zp_append_report( const char *nam, const char *target, int target_len, const cha
char *target_string = NULL; char *target_string = NULL;
int target_string_len = 0, new_extended_len = 0; int target_string_len = 0, new_extended_len = 0;
/* Get ZPLG_REPORTS associative array */ /* Get ZINIT_REPORTS associative array */
pm = ( Param ) paramtab->getnode( paramtab, "ZPLG_REPORTS" ); pm = ( Param ) paramtab->getnode( paramtab, "ZINIT_REPORTS" );
if ( !pm ) { if ( !pm ) {
zwarnnam( nam, "%d: Parameter $ZPLG_REPORTS isn't declared. Zplugin is not loaded? I.e. not sourced.", __LINE__ ); zwarnnam( nam, "%d: Parameter $ZINIT_REPORTS isn't declared. Zplugin is not loaded? I.e. not sourced.", __LINE__ );
return 1; return 1;
} }
/* Get ZPLG_REPORTS[{target}] hashed Param */ /* Get ZINIT_REPORTS[{target}] hashed Param */
ht = pm->u.hash; ht = pm->u.hash;
hn = gethashnode2( ht, target ); hn = gethashnode2( ht, target );
val_pm = ( Param ) hn; val_pm = ( Param ) hn;

File diff suppressed because it is too large Load diff