tweaks, antigen.zsh server version

This commit is contained in:
2023-03-19 02:59:04 +02:00
parent 761671e7f7
commit dbe5ea3ce0
2 changed files with 40 additions and 39 deletions

View File

@@ -41,6 +41,7 @@ export NVM_COMPLETION=true
export NVM_AUTO_USE=true
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# If we have go packages, include them to the PATH
if command -v go &> /dev/null; then

View File

@@ -24,7 +24,7 @@ if [[ $ANTIGEN_CACHE != false ]]; then
for config in $ANTIGEN_CHECK_FILES; do
if [[ "$config" -nt "$config.zwc" ]]; then
# Flag configuration file as newer
{ zcompile "$config"; } &!
{ zcompile "$config" } &!
# Kill cache file in order to force full loading (see a few lines below)
[[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE"
fi
@@ -151,7 +151,7 @@ antigen () {
# String if record is found
-antigen-find-record () {
local bundle=$1
if [[ $# -eq 0 ]]; then
return 1
fi
@@ -255,7 +255,7 @@ antigen () {
return 0
}
# This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell.
# This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell.
#
# Usage
# -antigen-interactive-mode
@@ -283,7 +283,7 @@ antigen () {
# Branch name
-antigen-parse-branch () {
local url="$1" branch="$2" branches
local match mbegin mend MATCH MBEGIN MEND
if [[ "$branch" =~ '\*' ]]; then
@@ -466,7 +466,7 @@ antigen () {
# Compatibility with oh-my-zsh themes.
-antigen-set-default _ANTIGEN_THEME_COMPAT true
# Add default built-in extensions to load at start up
-antigen-set-default _ANTIGEN_BUILTIN_EXTENSIONS 'lock parallel defer cache'
@@ -555,7 +555,7 @@ antigen () {
if [[ $#list == 0 ]]; then
return 1
fi
# Using a for rather than `source $list` as we need to check for zsh-themes
# In order to create antigen-compat file. This is only needed for interactive-mode
# theme switching, for static loading (cache) there is no need.
@@ -643,7 +643,7 @@ antigen () {
shift
done
# Check if url is just the plugin name. Super short syntax.
if [[ "${args[url]}" != */* ]]; then
case "$ANTIGEN_DEFAULT_REPO_URL" in
@@ -728,13 +728,13 @@ antigen () {
# if it's local then path is just the "url" argument, loc remains the same
args[dir]=${args[url]}
fi
# Escape url and branch (may contain semver-like and pipe characters)
args[url]="${(qq)args[url]}"
if [[ -n "${args[branch]}" ]]; then
args[branch]="${(qq)args[branch]}"
fi
# Escape bundle name (may contain semver-like characters)
args[name]="${(qq)args[name]}"
@@ -821,7 +821,7 @@ antigen-bundle () {
printf "Seems %s is already installed!\n" ${bundle[name]}
return 1
fi
# Clone bundle if we haven't done do already.
if [[ ! -d "${bundle[dir]}" ]]; then
if ! -antigen-bundle-install ${(kv)bundle}; then
@@ -835,7 +835,7 @@ antigen-bundle () {
printf "Antigen: Failed to load %s.\n" ${bundle[btype]} >&2
return 1
fi
# Only add it to the record if it could be installed and loaded.
_ANTIGEN_BUNDLE_RECORD+=("$record")
}
@@ -1326,7 +1326,7 @@ antigen-update () {
local url=""
local make_local_clone=""
local start=$(date +'%s')
if [[ $# -eq 0 ]]; then
printf "Antigen: Missing argument.\n" >&2
return 1
@@ -1340,14 +1340,14 @@ antigen-update () {
url="$(echo "$record" | cut -d' ' -f1)"
make_local_clone=$(echo "$record" | cut -d' ' -f4)
local branch="master"
if [[ $url == *\|* ]]; then
branch="$(-antigen-parse-branch ${url%|*} ${url#*|})"
fi
printf "Updating %s... " $(-antigen-bundle-short-name "$url" "$branch")
if [[ $make_local_clone == "false" ]]; then
printf "Bundle has no local clone. Will not be updated.\n" >&2
return 1
@@ -1358,7 +1358,7 @@ antigen-update () {
printf "Error! Activate logging and try again.\n" >&2
return 1
fi
local took=$(( $(date +'%s') - $start ))
printf "Done. Took %ds.\n" $took
}
@@ -1410,7 +1410,7 @@ typeset -g _ANTIGEN_EXTENSIONS; _ANTIGEN_EXTENSIONS=()
# -antigen-add-hook antigen-apply antigen-apply-hook ["replace"|"pre"|"post"] ["once"|"repeat"]
antigen-add-hook () {
local target="$1" hook="$2" type="$3" mode="${4:-repeat}"
if (( ! $+functions[$target] )); then
printf "Antigen: Function %s doesn't exist.\n" $target
return 1
@@ -1428,7 +1428,7 @@ antigen-add-hook () {
fi
_ANTIGEN_HOOKS_META[$hook]="target $target type $type mode $mode called 0"
# Do shadow for this function if there is none already
local hook_function="${_ANTIGEN_HOOK_PREFIX}$target"
if (( ! $+functions[$hook_function] )); then
@@ -1441,7 +1441,7 @@ antigen-add-hook () {
return \$?
}"
fi
return 0
}
@@ -1454,7 +1454,7 @@ antigen-add-hook () {
typeset -a pre_hooks replace_hooks post_hooks;
typeset -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]})
typeset -A meta;
for hook in $hooks; do
meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]})
@@ -1500,7 +1500,7 @@ antigen-add-hook () {
[[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret
fi
done
if [[ $replace_hook == 0 ]]; then
WARN "${_ANTIGEN_HOOK_PREFIX}$target $args"
noglob ${_ANTIGEN_HOOK_PREFIX}$target $args
@@ -1514,7 +1514,7 @@ antigen-add-hook () {
noglob $hook $args
[[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret
done
LOG "Return from hook ${target} with ${ret}"
return $ret
@@ -1533,7 +1533,7 @@ antigen-remove-hook () {
hooks[$hooks[(I)$hook]]=()
fi
_ANTIGEN_HOOKS[${target}]="${(j|:|)hooks}"
if [[ $#hooks == 0 ]]; then
# Destroy base hook
eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)"
@@ -1554,7 +1554,7 @@ antigen-remove-hook () {
eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)"
unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" 2> /dev/null
done
_ANTIGEN_HOOKS=()
_ANTIGEN_HOOKS_META=()
_ANTIGEN_EXTENSIONS=()
@@ -1570,14 +1570,14 @@ antigen-ext () {
eval $func
local ret=$?
WARN "$func return code was $ret"
if (( $ret == 0 )); then
if (( $ret == 0 )); then
LOG "LOADED EXTENSION $ext" EXT
-antigen-$ext-execute && _ANTIGEN_EXTENSIONS+=($ext)
else
WARN "IGNORING EXTENSION $func" EXT
return 1
fi
else
printf "Antigen: No extension defined or already loaded: %s\n" $func >&2
return 1
@@ -1617,7 +1617,7 @@ antigen-ext-init () {
return -1 # Stop right there
}
antigen-add-hook antigen-bundle antigen-bundle-defer replace
# Hooks antigen-apply in order to release hooked functions
antigen-apply-defer () {
WARN "Defer pre-apply" DEFER PRE-APPLY
@@ -1639,14 +1639,14 @@ antigen-ext-init () {
# Default lock path.
-antigen-set-default ANTIGEN_LOCK $ADOTDIR/.lock
typeset -g _ANTIGEN_LOCK_PROCESS=false
# Use env variable to determine if we should load this extension
-antigen-set-default ANTIGEN_MUTEX true
# Set ANTIGEN_MUTEX to false to avoid loading this extension
if [[ $ANTIGEN_MUTEX == true ]]; then
return 0;
fi
# Do not use mutex
return 1;
}
@@ -1714,7 +1714,7 @@ antigen-ext-init () {
else
WARN "Bundle ${bundle[name]} already cloned locally." PARALLEL
fi
repositories+=(${bundle[url]})
done
@@ -1734,7 +1734,7 @@ antigen-ext-init () {
for bundle in ${_PARALLEL_BUNDLE[@]}; do
antigen-bundle $bundle
done
WARN "Parallel install done" PARALLEL
}
@@ -1751,7 +1751,7 @@ antigen-ext-init () {
antigen-add-hook antigen-bundle antigen-bundle-parallel replace
}
antigen-add-hook antigen-apply antigen-apply-parallel pre once
antigen-apply-parallel-execute () {
WARN "Parallel replace-apply" PARALLEL REPLACE-APPLY
antigen-remove-hook antigen-bundle-parallel
@@ -1872,14 +1872,14 @@ EOC
# Cache auto config files to check for changes (.zshrc, .antigenrc etc)
-antigen-set-default ANTIGEN_AUTO_CONFIG true
# Default cache path.
-antigen-set-default ANTIGEN_CACHE $ADOTDIR/init.zsh
-antigen-set-default ANTIGEN_RSRC $ADOTDIR/.resources
if [[ $ANTIGEN_CACHE == false ]]; then
return 1
fi
return 0
}
@@ -1911,21 +1911,21 @@ EOC
antigen-remove-hook -antigen-load-source-cached
antigen-remove-hook antigen-bundle-cached
}
antigen-add-hook antigen-apply antigen-apply-cached post once
# Defer antigen-bundle.
antigen-bundle-cached () {
_ZCACHE_CAPTURE_BUNDLE+=("${(j: :)${@}}")
}
antigen-add-hook antigen-bundle antigen-bundle-cached pre
# Defer loading.
-antigen-load-env-cached () {
local bundle
typeset -A bundle; bundle=($@)
local location=${bundle[dir]}/${bundle[loc]}
# Load to path if there is no sourceable
if [[ ${bundle[loc]} == "/" ]]; then
_ZCACHE_BUNDLE_SOURCE+=("${location}")
@@ -1935,13 +1935,13 @@ EOC
_ZCACHE_BUNDLE_SOURCE+=("${location}")
}
antigen-add-hook -antigen-load-env -antigen-load-env-cached replace
# Defer sourcing.
-antigen-load-source-cached () {
_ZCACHE_BUNDLE_SOURCE+=($@)
}
antigen-add-hook -antigen-load-source -antigen-load-source-cached replace
return 0
}