blob: 1b8a862ec36814c4a0ff24fd1ef60bec7f8efd99 (
plain)
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
|
#compdef envstore
## vim:ft=zsh
## completion for envstore release-3
## Daniel Friesel <derf@derf.homelinux.org>
## https://derf.homelinux.org/~derf/dotfiles/completion/_envstore
## see also: http://git.cloudconnected.org/?p=envstore.git;a=summary
local -a arguments_action arguments_action_nofile
local -a arguments_save arguments_rm arguments_eval
local lstate
arguments_action=(
'1:action:(clear eval rm save show)'
)
arguments_action_nofile=(
'1:action:(save)'
)
# envstore can't handle arrays, so only complete scalars and integers.
# Also, don't complete parameters marked 'special', since they're usually
# specific to the current shell
arguments_save=(
'2:parameter:->param'
)
arguments_rm=(
'2:saved parameter:->saved_param'
)
arguments_eval=(
'2::option:(-e)'
)
if (( CURRENT >= 3 )) {
case ${words[2]} in
eval) _arguments -s $arguments_eval ;;
rm) _arguments -s $arguments_rm ;;
save) _arguments -s $arguments_save ;;
esac
} elif [[ -r /tmp/envstore-$UID ]] {
_arguments -s $arguments_action
} else {
_arguments -s $arguments_action_nofile
}
while [[ -n $state ]]; do
lstate=$state
state=''
case $lstate in
param)
_parameters -g '(scalar|integer)*export'
;;
saved_param)
_wanted parameter expl 'saved parameter' \
compadd $(envstore eval -e | cut -d ' ' -f 2 | cut -d '=' -f 1)
;;
esac
done
|