forked from NICHOLAS85/z-a-eval
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathz-a-eval.plugin.zsh
executable file
·59 lines (47 loc) · 1.67 KB
/
z-a-eval.plugin.zsh
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
# -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
# vim: ft=zsh sw=2 ts=2 et
#
# Copyright (c) 2021 Nicholas Serrano
# License MIT
# Standardized $0 Handling
# https://wiki.zshell.dev/community/zsh_plugin_standard#zero-handling
0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
0="${${(M)0:#/*}:-$PWD/$0}"
# Functions Directory
# https://wiki.zshell.dev/community/zsh_plugin_standard#funtions-directory
if [[ $PMSPEC != *f* ]] {
fpath+=( "${0:h}/functions" )
}
autoload -Uz .za-ev-{recache,{atclone,atinit,help}-handler}
# An empty stub to fill the help handler fields
.za-ev-null-handler() { :; }
# Remove temporary variable
.za-ev-atload-handler() { [[ -n ${ICE[eval]} ]] && unset ZI_Z_A_EVAL_SOURCED; }
@zi-register-annex "z-a-eval" hook:atclone-50 \
.za-ev-atclone-handler \
.za-ev-null-handler "eval''" # also register new ices
@zi-register-annex "z-a-eval" hook:atpull-50 \
.za-ev-atclone-handler \
.za-ev-null-handler
@zi-register-annex "z-a-eval" hook:atload-50 \
.za-ev-atload-handler \
.za-ev-null-handler
@zi-register-annex "z-a-eval" hook:atinit-50 \
.za-ev-atinit-handler \
.za-ev-null-handler
@zi-register-annex "z-a-eval" subcommand:recache \
.za-ev-recache \
.za-ev-help-handler
(( Z_A_USECOMP )) || return;
# Annex provides a completion file with the prefix _zi
# Annex provies the 'shim' below which will run all available zi completions
# Lastly the shim is assigned as ZIs completion with a compdef call
autoload -Uz _zi_recache
_zi_shim(){
unset -f $funcstack[1]
eval "
$funcstack[1](){ ${(F)${(@ok)functions[(I)_zi*]/%/ \"\$@\"}//$funcstack[1] \"\$@\"}; }
eval $funcstack[1] \$@
"
}
compdef _zi_shim zi