/usr/share/zsh-antigen/antigen.zsh is in zsh-antigen 2.2.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | ######################################################################
# This file was autogenerated by `make`. Do not edit it directly!
######################################################################
# Antigen: A simple plugin manager for zsh
# Authors: Shrikant Sharat Kandula
# and Contributors <https://github.com/zsh-users/antigen/contributors>
# Homepage: http://antigen.sharats.me
# License: MIT License <mitl.sharats.me>
zmodload zsh/parameter
autoload -U is-at-least
# While boot.zsh is part of the ext/cache functionallity it may be disabled
# with ANTIGEN_CACHE flag, and it's always compiled with antigen.zsh
if [[ $ANTIGEN_CACHE != false ]]; then
ANTIGEN_CACHE="${ANTIGEN_CACHE:-${ADOTDIR:-$HOME/.antigen}/init.zsh}"
ANTIGEN_RSRC="${ANTIGEN_RSRC:-${ADOTDIR:-$HOME/.antigen}/.resources}"
# It may not be necessary to check ANTIGEN_AUTO_CONFIG.
if [[ $ANTIGEN_AUTO_CONFIG != false && -f $ANTIGEN_RSRC ]]; then
# Check the list of files for configuration changes (uses -nt comp)
ANTIGEN_CHECK_FILES=$(cat $ANTIGEN_RSRC 2> /dev/null)
ANTIGEN_CHECK_FILES=(${(@f)ANTIGEN_CHECK_FILES})
for config in $ANTIGEN_CHECK_FILES; do
if [[ "$config" -nt "$config.zwc" ]]; then
# Flag configuration file as newer
{ zcompile "$config" } &!
# Kill cache file in order to force full loading (see a few lines below)
[[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE"
fi
done
fi
# If there is a cache file do load from it
if [[ -f $ANTIGEN_CACHE && ! $_ANTIGEN_CACHE_LOADED == true ]]; then
# Wrap antigen in order to defer cache source until `antigen-apply`
antigen() {
if [[ $1 == "apply" ]]; then
source "$ANTIGEN_CACHE"
# Handle `antigen-init` command properly
elif [[ $1 == "init" ]]; then
source "$2"
fi
}
# Do not continue loading antigen as cache bundle takes care of it.
return 0
fi
fi
[[ -z "$_ANTIGEN_INSTALL_DIR" ]] && _ANTIGEN_INSTALL_DIR=${0:A:h}
# Each line in this string has the following entries separated by a space
# character.
# <repo-url>, <plugin-location>, <bundle-type>, <has-local-clone>
[[ $_ANTIGEN_CACHE_LOADED != true ]] && typeset -aU _ANTIGEN_BUNDLE_RECORD
# Do not load anything if git is not available.
if (( ! $+commands[git] )); then
echo 'Antigen: Please install git to use Antigen.' >&2
return 1
fi
# Used to defer compinit/compdef
typeset -a __deferred_compdefs
compdef () { __deferred_compdefs=($__deferred_compdefs "$*") }
# A syntax sugar to avoid the `-` when calling antigen commands. With this
# function, you can write `antigen-bundle` as `antigen bundle` and so on.
antigen () {
local cmd="$1"
if [[ -z "$cmd" ]]; then
echo 'Antigen: Please give a command to run.' >&2
return 1
fi
shift
if (( $+functions[antigen-$cmd] )); then
"antigen-$cmd" "$@"
return $?
else
echo "Antigen: Unknown command: $cmd" >&2
return 1
fi
}
typeset -Ag _ANTIGEN_HOOKS; _ANTIGEN_HOOKS=()
typeset -Ag _ANTIGEN_HOOKS_META; _ANTIGEN_HOOKS_META=()
typeset -g _ANTIGEN_HOOK_PREFIX="-antigen-hook-"
typeset -g _ANTIGEN_EXTENSIONS; _ANTIGEN_EXTENSIONS=()
# -antigen-add-hook antigen-apply antigen-apply-hook replace
# - Replaces hooked function with hook, do not call hooked function
# - Return -1 to stop calling further hooks
# -antigen-add-hook antigen-apply antigen-apply-hook pre (pre-call)
# - By default it will call hooked function
# -antigen-add-hook antigen-pply antigen-apply-hook post (post-call)
# - Calls antigen-apply and then calls hook function
# Usage:
# -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
fi
if (( ! $+functions[$hook] )); then
printf "Antigen: Function %s doesn't exist.\n" $hook
return 1
fi
if [[ "${_ANTIGEN_HOOKS[$target]}" == "" ]]; then
_ANTIGEN_HOOKS[$target]="${hook}"
else
_ANTIGEN_HOOKS[$target]="${_ANTIGEN_HOOKS[$target]}:${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
# Preserve hooked function
eval "function ${_ANTIGEN_HOOK_PREFIX}$(functions -- $target)"
# Create hook, call hook-handler to further process hook functions
eval "function $target () {
noglob -antigen-hook-handler $target \$@
return \$?
}"
fi
return 0
}
# Private function to handle multiple hooks in a central point.
-antigen-hook-handler () {
local target="$1" args hook called
local hooks meta
shift
typeset -a args; args=(${@})
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]})
if [[ ${meta[mode]} == "once" && ${meta[called]} == 1 ]]; then
WARN "Ignoring hook due to mode ${meta[mode]}: $hook"
continue
fi
let called=${meta[called]}+1
meta[called]=$called
_ANTIGEN_HOOKS_META[$hook]="${(kv)meta}"
WARN "Updated meta: "${(kv)meta}
case "${meta[type]}" in
"pre")
pre_hooks+=($hook)
;;
"replace")
replace_hooks+=($hook)
;;
"post")
post_hooks+=($hook)
;;
esac
done
WARN "Processing hooks: ${hooks}"
for hook in $pre_hooks; do
WARN "Pre hook:" $hook $args
noglob $hook $args
[[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret
done
# A replace hook will return inmediately
local replace_hook=0 ret=0
for hook in $replace_hooks; do
replace_hook=1
# Should not be needed if `antigen-remove-hook` removed unneeded hooks.
if (( $+functions[$hook] )); then
WARN "Replace hook:" $hook $args
noglob $hook $args
[[ $? == -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
ret=$?
else
WARN "Replaced hooked function."
fi
for hook in $post_hooks; do
WARN "Post hook:" $hook $args
noglob $hook $args
[[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret
done
LOG "Return from hook ${target} with ${ret}"
return $ret
}
# Usage:
# -antigen-remove-hook antigen-apply-hook
antigen-remove-hook () {
local hook="$1"
typeset -A meta; meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]})
local target="${meta[target]}"
local -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]})
# Remove registered hook
if [[ $#hooks > 0 ]]; then
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}//)"
if (( $+functions[${_ANTIGEN_HOOK_PREFIX}$target] )); then
unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target"
fi
fi
unfunction -- $hook 2> /dev/null
}
# Remove all defined hooks.
-antigen-reset-hooks () {
local target
for target in ${(k)_ANTIGEN_HOOKS}; do
# Release all hooked functions
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=()
}
# Initializes an extension
# Usage:
# antigen-ext ext-name
antigen-ext () {
local ext=$1
local func="-antigen-$ext-init"
if (( $+functions[$func] && $_ANTIGEN_EXTENSIONS[(I)$ext] == 0 )); then
eval $func
local ret=$?
WARN "$func return code was $ret"
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
fi
}
# List installed extensions
# Usage:
# antigen ext-list
antigen-ext-list () {
echo $_ANTIGEN_EXTENSIONS
}
# Initializes built-in extensions
# Usage:
# antigen-ext-init
antigen-ext-init () {
# Initialize extensions. unless in interactive mode.
local ext
for ext in ${(s/ /)_ANTIGEN_BUILTIN_EXTENSIONS}; do
# Check if extension is loaded before intializing it
(( $+functions[-antigen-$ext-init] )) && antigen-ext $ext
done
}
# Initialize defer lib
-antigen-defer-init () {
typeset -ga _DEFERRED_BUNDLE; _DEFERRED_BUNDLE=()
if -antigen-interactive-mode; then
return 1
fi
}
-antigen-defer-execute () {
# Hooks antigen-bundle in order to defer its execution.
antigen-bundle-defer () {
_DEFERRED_BUNDLE+=("${(j: :)${@}}")
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
antigen-remove-hook antigen-bundle-defer
# Process all deferred bundles.
local bundle
for bundle in ${_DEFERRED_BUNDLE[@]}; do
LOG "Processing deferred bundle: ${bundle}" DEFER
antigen-bundle $bundle
done
unset _DEFERRED_BUNDLE
}
antigen-add-hook antigen-apply antigen-apply-defer pre once
}
# Initialize lock lib
-antigen-lock-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;
}
-antigen-lock-execute () {
# Hook antigen command in order to check/create a lock file.
# This hook is only run once then releases itself.
antigen-lock () {
LOG "antigen-lock called"
# If there is a lock set up then we won't process anything.
if [[ -f $ANTIGEN_LOCK ]]; then
# Set up flag do the message is not repeated for each antigen-* command
[[ $_ANTIGEN_LOCK_PROCESS == false ]] && printf "Antigen: Another process in running.\n"
_ANTIGEN_LOCK_PROCESS=true
# Do not further process hooks. For this hook to properly work it
# should be registered first.
return -1
fi
WARN "Creating antigen-lock file at $ANTIGEN_LOCK"
touch $ANTIGEN_LOCK
}
antigen-add-hook antigen antigen-lock pre once
# Hook antigen-apply in order to release .lock file.
antigen-apply-lock () {
WARN "Freeing antigen-lock file at $ANTIGEN_LOCK"
unset _ANTIGEN_LOCK_PROCESS
rm -f $ANTIGEN_LOCK &> /dev/null
}
antigen-add-hook antigen-apply antigen-apply-lock post once
}
# Initialize parallel lib
-antigen-parallel-init () {
WARN "Init parallel extension" PARALLEL
typeset -ga _PARALLEL_BUNDLE; _PARALLEL_BUNDLE=()
if -antigen-interactive-mode; then
return 1
fi
}
-antigen-parallel-execute() {
WARN "Exec parallel extension" PARALLEL
# Install bundles in parallel
antigen-bundle-parallel-execute () {
WARN "Parallel antigen-bundle-parallel-execute" PARALLEL
typeset -a pids; pids=()
local args pid
WARN "Gonna install in parallel ${#_PARALLEL_BUNDLE} bundles." PARALLEL
# Do ensure-repo in parallel
WARN "${_PARALLEL_BUNDLE}" PARALLEL
typeset -Ua repositories # Used to keep track of cloned repositories to avoid
# trying to clone it multiple times.
for args in ${_PARALLEL_BUNDLE}; do
typeset -A bundle; -antigen-parse-args 'bundle' ${=args}
if [[ ! -d ${bundle[dir]} && $repositories[(I)${bundle[url]}] == 0 ]]; then
WARN "Install in parallel ${bundle[name]}." PARALLEL
echo "Installing ${bundle[name]}!..."
# $bundle[url]'s format is "url|branch" as to create "$ANTIGEN_BUNDLES/bundle/name-branch",
# this way you may require multiple branches from the same repository.
-antigen-ensure-repo "${bundle[url]}" > /dev/null &!
pids+=($!)
else
WARN "Bundle ${bundle[name]} already cloned locally." PARALLEL
fi
repositories+=(${bundle[url]})
done
# Wait for all background processes to end
while [[ $#pids > 0 ]]; do
for pid in $pids; do
# `ps` may diplay an error message such "Signal 18 (CONT) caught by ps
# (procps-ng version 3.3.9).", see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=732410
if [[ $(ps -o pid= -p $pid 2>/dev/null) == "" ]]; then
pids[$pids[(I)$pid]]=()
fi
done
sleep .5
done
builtin local bundle &> /dev/null
for bundle in ${_PARALLEL_BUNDLE[@]}; do
antigen-bundle $bundle
done
WARN "Parallel install done" PARALLEL
}
# Hooks antigen-apply in order to release hooked functions
antigen-apply-parallel () {
WARN "Parallel pre-apply" PARALLEL PRE-APPLY
#antigen-remove-hook antigen-pre-apply-parallel
# Hooks antigen-bundle in order to parallel its execution.
antigen-bundle-parallel () {
TRACE "antigen-bundle-parallel: $@" PARALLEL
_PARALLEL_BUNDLE+=("${(j: :)${@}}")
}
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
# Process all parallel bundles.
antigen-bundle-parallel-execute
unset _PARALLEL_BUNDLE
antigen-remove-hook antigen-apply-parallel-execute
antigen-apply
}
antigen-add-hook antigen-apply antigen-apply-parallel-execute replace once
}
typeset -ga _ZCACHE_BUNDLE_SOURCE _ZCACHE_CAPTURE_BUNDLE
typeset -g _ZCACHE_CAPTURE_PREFIX
# Generates cache from listed bundles.
#
# Iterates over _ANTIGEN_BUNDLE_RECORD and join all needed sources into one,
# if this is done through -antigen-load-list.
# Result is stored in ANTIGEN_CACHE.
#
# _ANTIGEN_BUNDLE_RECORD and fpath is stored in cache.
#
# Usage
# -zcache-generate-cache
#
# Returns
# Nothing. Generates ANTIGEN_CACHE
-antigen-cache-generate () {
local -aU _fpath _PATH _sources
local record
LOG "Gonna generate cache for $_ZCACHE_BUNDLE_SOURCE"
for record in $_ZCACHE_BUNDLE_SOURCE; do
record=${record:A}
# LOG "Caching $record"
if [[ -f $record ]]; then
# Adding $'\n' as a suffix as j:\n: doesn't work inside a heredoc.
if [[ $_ANTIGEN_THEME_COMPAT == true && "$record" == *.zsh-theme* ]]; then
local compat="${record:A}.antigen-compat"
echo "# Generated by Antigen. Do not edit!" >! "$compat"
cat $record | sed -Ee '/\{$/,/^\}/!{
s/^local //
}' >>! "$compat"
record="$compat"
fi
_sources+=("source '${record}';"$'\n')
elif [[ -d $record ]]; then
_PATH+=("${record}")
_fpath+=("${record}")
fi
done
cat > $ANTIGEN_CACHE <<EOC
#-- START ZCACHE GENERATED FILE
#-- GENERATED: $(date)
#-- ANTIGEN develop
$(functions -- _antigen)
antigen () {
local MATCH MBEGIN MEND
[[ "\$ZSH_EVAL_CONTEXT" =~ "toplevel:*" || "\$ZSH_EVAL_CONTEXT" =~ "cmdarg:*" ]] && source "$_ANTIGEN_INSTALL_DIR/antigen.zsh" && eval antigen \$@;
return 0;
}
typeset -gaU fpath path
fpath+=(${_fpath[@]}) path+=(${_PATH[@]})
_antigen_compinit () {
autoload -Uz compinit; compinit $ANTIGEN_COMPINIT_OPTS -d "$ANTIGEN_COMPDUMP"; compdef _antigen antigen
add-zsh-hook -D precmd _antigen_compinit
}
autoload -Uz add-zsh-hook; add-zsh-hook precmd _antigen_compinit
compdef () {}
if [[ -n "$ZSH" ]]; then
ZSH="$ZSH"; ZSH_CACHE_DIR="$ZSH_CACHE_DIR"
fi
#--- BUNDLES BEGIN
${(j::)_sources}
#--- BUNDLES END
typeset -gaU _ANTIGEN_BUNDLE_RECORD; _ANTIGEN_BUNDLE_RECORD=($(print ${(qq)_ANTIGEN_BUNDLE_RECORD}))
typeset -g _ANTIGEN_CACHE_LOADED; _ANTIGEN_CACHE_LOADED=true
typeset -ga _ZCACHE_BUNDLE_SOURCE; _ZCACHE_BUNDLE_SOURCE=($(print ${(qq)_ZCACHE_BUNDLE_SOURCE}))
typeset -g _ANTIGEN_CACHE_VERSION; _ANTIGEN_CACHE_VERSION='develop'
#-- END ZCACHE GENERATED FILE
EOC
{ zcompile "$ANTIGEN_CACHE" } &!
# Compile config files, if any
LOG "CHECK_FILES $ANTIGEN_CHECK_FILES"
[[ $ANTIGEN_AUTO_CONFIG == true && -n $ANTIGEN_CHECK_FILES ]] && {
echo ${(j:\n:)ANTIGEN_CHECK_FILES} >! "$ANTIGEN_RSRC"
for rsrc in $ANTIGEN_CHECK_FILES; do
zcompile $rsrc
done
} &!
return true
}
# Initializes caching mechanism.
#
# Hooks `antigen-bundle` and `antigen-apply` in order to defer bundle install
# and load. All bundles are loaded from generated cache rather than dynamically
# as these are bundled.
#
# Usage
# -antigen-cache-init
# Returns
# Nothing
-antigen-cache-init () {
if -antigen-interactive-mode; then
return 1
fi
_ZCACHE_CAPTURE_PREFIX=${_ZCACHE_CAPTURE_PREFIX:-"--zcache-"}
_ZCACHE_BUNDLE_SOURCE=(); _ZCACHE_CAPTURE_BUNDLE=()
# 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
}
-antigen-cache-execute () {
# Main function. Deferred antigen-apply.
antigen-apply-cached () {
# TRACE "APPLYING CACHE" EXT
# Auto determine check_files
# There always should be 5 steps from original source as the correct way is to use
# `antigen` wrapper not `antigen-apply` directly and it's called by an extension.
LOG "TRACE: ${funcfiletrace}"
if [[ $ANTIGEN_AUTO_CONFIG == true && $#ANTIGEN_CHECK_FILES -eq 0 ]]; then
# Check common configuration file does exist.
if [[ -f ${ZDOTDIR:-$HOME}/.zshrc ]]; then
ANTIGEN_CHECK_FILES+=(${ZDOTDIR:-$HOME}/.zshrc)
fi
# TODO Fix: Fuzzy match shoud be replaced by a sane way to determine it.
if [[ $#funcfiletrace -ge 6 ]]; then
ANTIGEN_CHECK_FILES+=("${${funcfiletrace[6]%:*}##* }")
fi
fi
# Generate and compile cache
-antigen-cache-generate
[[ -f "$ANTIGEN_CACHE" ]] && source "$ANTIGEN_CACHE";
# Commented out in order to have a working `cache-gen` command
#unset _ZCACHE_BUNDLE_SOURCE
unset _ZCACHE_CAPTURE_BUNDLE _ZCACHE_CAPTURE_FUNCTIONS
# Release all hooked functions
antigen-remove-hook -antigen-load-env-cached
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}")
return
fi
_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
}
# Generate static-cache file at $ANTIGEN_CACHE using currently loaded
# bundles from $_ANTIGEN_BUNDLE_RECORD
#
# Usage
# antigen-cache-gen
#
# Returns
# Nothing
antigen-cache-gen () {
-antigen-cache-generate
}
#compdef _antigen
# Setup antigen's autocompletion
_antigen () {
local -a _1st_arguments
_1st_arguments=(
'apply:Load all bundle completions'
'bundle:Install and load the given plugin'
'bundles:Bulk define bundles'
'cleanup:Clean up the clones of repos which are not used by any bundles currently loaded'
'cache-gen:Generate cache'
'init:Load Antigen configuration from file'
'list:List out the currently loaded bundles'
'purge:Remove a cloned bundle from filesystem'
'reset:Clears cache'
'restore:Restore the bundles state as specified in the snapshot'
'revert:Revert the state of all bundles to how they were before the last antigen update'
'selfupdate:Update antigen itself'
'snapshot:Create a snapshot of all the active clones'
'theme:Switch the prompt theme'
'update:Update all bundles'
'use:Load any (supported) zsh pre-packaged framework'
);
_1st_arguments+=(
'help:Show this message'
'version:Display Antigen version'
)
__bundle() {
_arguments \
'--loc[Path to the location <path-to/location>]' \
'--url[Path to the repository <github-account/repository>]' \
'--branch[Git branch name]' \
'--no-local-clone[Do not create a clone]'
}
__list() {
_arguments \
'--simple[Show only bundle name]' \
'--short[Show only bundle name and branch]' \
'--long[Show bundle records]'
}
__cleanup() {
_arguments \
'--force[Do not ask for confirmation]'
}
_arguments '*:: :->command'
if (( CURRENT == 1 )); then
_describe -t commands "antigen command" _1st_arguments
return
fi
local -a _command_args
case "$words[1]" in
bundle)
__bundle
;;
use)
compadd "$@" "oh-my-zsh" "prezto"
;;
cleanup)
__cleanup
;;
(update|purge)
compadd $(type -f \-antigen-get-bundles &> /dev/null || antigen &> /dev/null; -antigen-get-bundles --simple 2> /dev/null)
;;
theme)
compadd $(type -f \-antigen-get-themes &> /dev/null || antigen &> /dev/null; -antigen-get-themes 2> /dev/null)
;;
list)
__list
;;
esac
}
zmodload zsh/datetime
ANTIGEN_DEBUG_LOG=${ANTIGEN_DEBUG_LOG:-${ADOTDIR:-$HOME/.antigen}/debug.log}
LOG () {
local PREFIX="[LOG][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG
}
ERR () {
local PREFIX="[ERR][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG
}
WARN () {
local PREFIX="[WRN][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@" >> $ANTIGEN_DEBUG_LOG
}
TRACE () {
local PREFIX="[TRA][${EPOCHREALTIME}]"
echo "${PREFIX} ${funcfiletrace[1]}\n${PREFIX} $@\n${PREFIX} ${(j:\n:)funcstack}" >> $ANTIGEN_DEBUG_LOG
}
-antigen-env-setup
|