blob: 0a158eb11e0a2838619d3d428eab5d55cbb96a04 (
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
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
|
#compdef keyringer
# Completion for git subcommand
_keyringer_git_complete() {
# TODO: how to call _git() properly?
return
}
_keyringer() {
local curcontext="$curcontext" state line
typeset -A opt_args
# Initial options
local config="$HOME/.keyringer"
# Check if we have initial configuration
if [ ! -d "$config" ]; then
return
fi
# Process config
local keyrings="`ls --color=never $config | sed -e 's/config//'`"
source $config/config
local keyring_path="`eval echo '$'$words[2]`"
_arguments \
'1: :->keyring' \
'2: :->action' \
'3: :->options' \
'4: :->misc' \
'*: :->final'
case $state in
keyring)
_arguments "1:Keyrings:($keyrings)"
;;
action)
compadd "$@" `KEYRINGER_CHECK_VERSION=false keyringer $words[2] commands`
;;
options)
case $words[3] in
options|preferences)
compadd "$@" ls edit add
;;
recipients)
compadd "$@" ls edit
;;
ls|encrypt|encrypt-batch|decrypt|edit|append|append-batch|del|recrypt|open)
# TODO: do not rely on bash
compadd "$@" $(bash -c "set -f && KEYRINGER_CHECK_VERSION=false keyringer $words[2] ls -p -d $words[4]*" 2> /dev/null)
;;
genpair)
compadd "$@" gpg ssh ssl ssl-self
;;
git)
compadd "$@" $(_keyringer_git_complete $words[4])
;;
*)
;;
esac
;;
misc)
case "$words[3]" in
recipients)
compadd "$@" $(cd $keyring_path/config/recipients && ls --color=never -p $words[5]* 2> /dev/null)
;;
genpair)
# TODO: do not rely on bash
compadd "$@" $(bash -c "set -f && KEYRINGER_CHECK_VERSION=false keyringer $words[2] ls -p -d $words[5]*" 2> /dev/null)
;;
git)
# TODO
compadd "$@" $(_keyringer_git_complete $words[4] $words[5])
;;
*)
;;
esac
;;
*)
if [ $words[3] == "git" ]; then
# TODO
true
fi
;;
esac
}
_keyringer "$@"
|