11# compdef zi
2+ # -*- mode: zsh; sh-indentation: 2; indent-tabs-mode: nil; sh-basic-offset: 2; -*-
3+ # vim: ft=zsh sw=2 ts=2 et
4+ # 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
25
36setopt localoptions warncreateglobal typesetsilent
47
@@ -7,74 +10,77 @@ local -a expl
710
811typeset -a commands
912commands=(
10- analytics:'Show ❮ ZI ❯ Analytics'
11- control:'❮ ZI ❯ Control commands'
12- zstatus:'Checks ❮ ZI ❯ Status'
13- times:'Statistics on plugin loading times'
14- self-update:'Updates and Compile ❮ ZI ❯'
15- help:'Usage Information'
16- man:'Manpage'
17- load:'Load plugin'
18- delete:'Delete plugin'
19- unload:'Unload plugin'
20- snippet:"Source (or add to PATH with --command) local or remote file (-f: force - don't use cache)"
21- update:'Git update plugin (or all plugins and snippets if --all passed)'
22- status:'Git status for plugin (or all plugins if --all passed)'
23- report:'Show plugin'"'"'s report (or all plugins'"'"' if --all passed)'
24- loaded:'Show what plugins are loaded'
25- list:'Show what plugins are loaded'
26- ls:'List snippets in formatted and colorized manner'
27- cd:"Go into plugin's directory"
28- create:'Create plugin (also together with Github repository)'
13+ analytics:" Statistics, benchmarks and information"
14+ subcmds:" Shows subcommands registered by annex"
15+ icemods:" Shows ice-modifiers registered by annex"
16+ zstatus:" Check and provide status information"
17+ times:" Statistics on plugin loading times"
18+ self-update:" Updates and compiles ❮ ZI ❯"
19+ help:" Usage information"
20+ man:" Manpage"
21+ load:" Load plugin"
22+ light:" Light load plugin"
23+ delete:" Delete plugin"
24+ unload:" Unload plugin"
25+ snippet:" Source (or add to PATH with --command) local or remote file (-f: force - do not use cache)"
26+ update:" Git update plugin (or all plugins and snippets if --all passed)"
27+ status:" Git status for plugin (or all plugins if --all passed)"
28+ report:" Show plugins report (or all plugins if --all passed)"
29+ loaded:" Show loaded plugins"
30+ list:" List loaded plugins"
31+ ls:" List snippets in formatted and colorized manner"
32+ cd:" Go into plugin directory"
33+ create:" Create plugin (also together with Github repository)"
2934 edit:" Edit plugin's file with \$ EDITOR"
30- glance:"Look at plugin's source (pygmentize, {,source-}highlight) "
31- stress:' Test plugin for compatibility with set of options'
32- changes:"View plugin's git log"
35+ glance:" View the plugin source"
36+ stress:" Test the plugin for compatibility with set of options"
37+ changes:" View the plugin git log"
3338 recently:" Show plugins that changed recently, argument is e.g. 1 month 2 days"
34- clist:' List completions in use'
35- cclear:' Clear stray and improper completions'
36- completions:' List completions in use'
37- cdisable:' Disable completion'
38- cenable:' Enable completion'
39- creinstall:' Install completions for plugin'
40- cuninstall:' Uninstall completions for plugin'
41- csearch:' Search for available completions from any plugin'
42- compinit:' Refresh installed completions'
39+ clist:" List completions in use"
40+ cclear:" Clear stray and improper completions"
41+ completions:" List completions in use"
42+ cdisable:" Disable completion"
43+ cenable:" Enable completion"
44+ creinstall:" Install completions for plugin"
45+ cuninstall:" Uninstall completions for plugin"
46+ csearch:" Search for available completions from any plugin"
47+ compinit:" Refresh installed completions"
4348 dtrace:" Start tracking what's going on in session"
4449 dstart:" Start tracking what's going on in session"
4550 dstop:" Stop tracking what's going on in session"
46- dunload:' Revert changes recorded between dstart and dstop'
51+ dunload:" Revert changes recorded between dstart and dstop"
4752 dreport:" Report what was going on in session"
48- dclear:' Clear report of what was going on in session'
49- compile:' Compile plugin (or all plugins if --all passed)'
50- uncompile:' Remove compiled version of plugin (or of all plugins if --all passed)'
51- compiled:' Show which plugins are compiled'
52- cdlist:' Show compdef replay list'
53- cdreplay:' Replay compdefs (to be done after compinit)'
54- cdclear:' Clear compdef replay list'
55- srv:' Control a service, command can be: stop,start,restart,next,quit; ` next'' moves the service to another Zshell'
56- recall:' Fetch saved ice modifiers and construct ` zi ice ...'' command'
57- bindkeys:' Lists bindkeys set up by each plugin'
58- module:' Manage binary Zsh module shipped with ❮ ZI ❯ , see ` zi module help'''
53+ dclear:" Clear report of what was going on in session"
54+ compile:" Compile plugin (or all plugins if --all passed)"
55+ uncompile:" Remove compiled version of plugin (or of all plugins if --all passed)"
56+ compiled:" Show which plugins are compiled"
57+ cdlist:" Show compdef replay list"
58+ cdreplay:" Replay compdefs (to be done after compinit)"
59+ cdclear:" Clear compdef replay list"
60+ srv:" Control a service, command can be: stop,start,restart,next,quit; next'' moves the service to another Zshell"
61+ recall:" Fetch saved ice modifiers and construct ' zi ice ...' command"
62+ bindkeys:" Lists bindkeys set up by each plugin"
63+ module:" Manage binary Zsh module, see ' zi module help' for more info "
5964 run:" Execute code inside plugin's folder"
60- env-whitelist:' Allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose'
61- add-fpath:' Add plugin folder to $fpath'
65+ env-whitelist:" Allows to specify names (also patterns) of variables left unchanged during an unload. -v - verbose"
66+ add-fpath:" Add plugin folder to \ $ fpath"
6267)
6368
64- _arguments -C \
65- '1: :->command'\
66- '*: :->argument' && ret=0
69+ _arguments -C ' 1: :->command' ' *: :->argument' && ret=0
6770
6871case $state in
6972 command)
70- _describe -t commands "❮ ZI ❯ commands" commands && ret=0
73+ _describe -t commands " ❮ ZI ❯ commands: " commands && ret=0
7174 ;;
7275 argument)
73- case $words[2] in
76+ case ${ words[2]} in
7477 help)
7578 _message " Hit enter to get usage information" && ret=0
7679 ;;
77- control)
80+ subcmds)
81+ _message " Hit enter to get commands list" && ret=0
82+ ;;
83+ icemods)
7884 _message " Hit enter to get commands list" && ret=0
7985 ;;
8086 analytics)
@@ -104,7 +110,7 @@ case $state in
104110 plugins=( " ${plugins[@]:# _local/ zi} " )
105111 plugins=( " ${plugins[@]:# custom} " )
106112 local -a opts
107- if [[ $words[2] = run ]]; then
113+ if [[ ${ words[2]} = run ]]; then
108114 opts=( -l )
109115 else
110116 opts=( -f --front )
@@ -122,17 +128,16 @@ case $state in
122128 local -a snippets snippets_alreadyld
123129 local sni
124130 snippets=( " ${ZI[SNIPPETS_DIR]} " /* /._zi(D/:h) )
125- snippets=( ${snippets[@]#${ZI[SNIPPETS_DIR]}/} )
126- snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} )
127- snippets=( ${snippets[@]/--//} )
128- for sni ( ${snippets[@]} ) {
129- if [[ -n ${ZI_SNIPPETS[$sni]} ]]; then
130- snippets_alreadyld+=( $ sni )
131- snippets=( ${snippets[@]:#$sni} )
131+ snippets=( " ${snippets[@]# ${ZI[SNIPPETS_DIR]} / } " )
132+ snippets=( " ${snippets[@]/ (# b)(http|https|ftp|ftps|scp)--/ ${match[1]} :// } " )
133+ snippets=( " ${snippets[@]/ --// } " )
134+ for sni in " ${snippets[@]} " ; do
135+ if [[ -n " ${ZI_SNIPPETS[$sni]} " ]]; then
136+ snippets_alreadyld+=( " ${ sni} " )
137+ snippets=( " ${snippets[@]:# $sni } " )
132138 fi
133- }
134- _alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \
135- 'plugins:-- Plugin --:compadd -a - plugins' && ret=0
139+ done
140+ _alternative ' dsnippets:-- Downloaded Snippet --:compadd -a - snippets' ' lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' ' plugins:-- Plugin --:compadd -a - plugins' && ret=0
136141 ;;
137142 unload|report)
138143 typeset -a plugins absolute normal
@@ -142,7 +147,7 @@ case $state in
142147 absolute=( " ${absolute[@]/ \%\/\/ /%/ } " )
143148 local hm=" ${HOME%/ } "
144149 absolute=( " ${absolute[@]/ $hm / HOME} " )
145- plugins=( $ normal $ absolute )
150+ plugins=( " ${ normal} " " ${ absolute} " )
146151 _wanted plugins expl " -- Plugin --" compadd " $@ " -a - plugins && ret=0
147152 ;;
148153 all-reports)
@@ -177,35 +182,34 @@ case $state in
177182 typeset -a plugins completions
178183 local p c user plugin
179184 for p in " ${ZI[PLUGINS_DIR]} " /* ; do
180- completions=( "$p "/**/_[^_.]*~*(*.zwc|*.html|*.txt|*.png|*.jpg|*.jpeg|*.js|*.md|_zsh_highlight*|/zsdoc/*)(DN) )
185+ completions=( " ${p} " /** /_[^_.]* ~* (* .zwc| * .html| * .txt| * .png| * .jpg| * .jpeg| * .js| * .md| _zsh_highlight* | /zsdoc/* )(DN) )
181186 for c in " ${completions[@]} " ; do
182187 p=" ${p: t} "
183188 user=" ${p%% ---* } "
184189 plugin=" ${p#* ---} "
185- [[ "$user" = "$plugin" && "${user}---${plugin}" != "$p " ]] && user=""
186- plugins+=( "${user:+$user/}$plugin" )
190+ [[ " ${ user} " = " ${ plugin} " && " ${user} ---${plugin} " != " ${p} " ]] && user=" "
191+ plugins+=( " ${user: +${ user} / }${ plugin} " )
187192 break
188193 done
189194 done
190195 _wanted plugins expl " -- Plugin --" compadd " $@ " -a - plugins && ret=0
191196 ;;
192197 cuninstall)
193- # We must iterate each plugin and check if
194- # it has completions that are installed
198+ # We must iterate each plugin and check if it has completions that are installed
195199 typeset -a plugins completions
196200 local p c user plugin cfile bkpfile
197201 for p in " ${ZI[PLUGINS_DIR]} " /* ; do
198- completions=( "$p "/**/_[^_.][^.]#(N) )
202+ completions=( " ${p} " /** /_[^_.][^.]# (N) )
199203 for c in " ${completions[@]} " ; do
200204 cfile=" ${c: t} "
201205 bkpfile=" ${cfile# _} "
202206 # Completion installed, either enabled or disabled?
203- if [[ -e "${ZI[COMPLETIONS_DIR]}"/"$cfile" || -e "${ZI[COMPLETIONS_DIR]}"/"$bkpfile" ]]; then
207+ if [[ -e " ${ZI[COMPLETIONS_DIR]} " /" ${ cfile} " || -e " ${ZI[COMPLETIONS_DIR]} " /" ${ bkpfile} " ]]; then
204208 p=" ${p: t} "
205209 user=" ${p%% ---* } "
206210 plugin=" ${p#* ---} "
207- [[ "$user" = "$plugin" && "${user}---${plugin}" != "$p " ]] && user=""
208- plugins+=( "${user:+$user/}$plugin" )
211+ [[ " ${ user} " = " ${ plugin} " && " ${user} ---${plugin} " != " ${p} " ]] && user=" "
212+ plugins+=( " ${user: +${ user} / }${ plugin} " )
209213 break
210214 fi
211215 done
@@ -219,17 +223,16 @@ case $state in
219223 local -a snippets snippets_alreadyld
220224 local sni
221225 snippets=( " ${ZI[SNIPPETS_DIR]} " /** /._zi(D/:h) )
222- snippets=( ${snippets[@]#${ZI[SNIPPETS_DIR]}/} )
223- snippets=( ${snippets[@]/(#b)(http|https|ftp|ftps|scp)--/${match[1]}://} )
224- snippets=( ${snippets[@]/--//} )
225- for sni ( ${snippets[@]} ) {
226+ snippets=( " ${snippets[@]# ${ZI[SNIPPETS_DIR]} / } " )
227+ snippets=( " ${snippets[@]/ (# b)(http|https|ftp|ftps|scp)--/ ${match[1]} :// } " )
228+ snippets=( " ${snippets[@]/ --// } " )
229+ for sni in " ${snippets[@]} " ; do
226230 if [[ -n ${ZI_SNIPPETS[$sni]} ]]; then
227- snippets_alreadyld+=( $ sni )
228- snippets=( ${snippets[@]:#$sni} )
231+ snippets_alreadyld+=( " ${ sni} " )
232+ snippets=( " ${snippets[@]:# $sni } " )
229233 fi
230- }
231- _alternative 'dsnippets:-- Downloaded Snippet --:compadd -a - snippets' 'lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' \
232- 'files:-- File --:_files' && ret=0
234+ done
235+ _alternative ' dsnippets:-- Downloaded Snippet --:compadd -a - snippets' ' lsnippets:-- Already Loaded Snippet --:compadd -a - snippets_alreadyld' ' files:-- File --:_files' && ret=0
233236 ;;
234237 dstart| dtrace)
235238 _message " Hit enter to start tracking this session" && ret=0
@@ -254,13 +257,13 @@ case $state in
254257 plugins=( " ${ZI[PLUGINS_DIR]} " /* (N) )
255258 typeset -a show_plugins p matches
256259 for p in " ${plugins[@]} " ; do
257- matches=( $p /*.zwc(N) )
260+ matches=( " ${p} " /* .zwc(N) )
258261 if [ " $# matches" -ne " 0" ]; then
259262 p=" ${p: t} "
260- [ "$p " = "_local---zi" ] && continue
261- [ "$p " = "custom" ] && continue
263+ [ " ${p} " = " _local---zi" ] && continue
264+ [ " ${p} " = " custom" ] && continue
262265 p=" ${p// ---// } "
263- show_plugins+=( "$p " )
266+ show_plugins+=( " ${p} " )
264267 fi
265268 done
266269 _wanted show_plugins expl " -- Plugin --" compadd " $@ " -a - show_plugins && ret=0
0 commit comments