blob: 6de93bb204714eec2fd63dfbf1868df9c259e745 (
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
|
#
# Keyringer bash completion
#
_keyringer() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# Initial options
opts="`ls $HOME/.keyringer | sed -e 's/config//'`"
# Available keyrings
keyrings="`echo $opts | sed -e 's/ /|/'`"
# The current keyring
keyring="${COMP_WORDS[1]}"
# Command completions
if [ "${#COMP_WORDS[@]}" == "3" ] && echo "${prev}" | grep -qe "[$keyrings]"; then
opts="`keyringer $keyring commands`"
else
case "${prev}" in
ls)
opts="`keyringer $keyring ls ${cur}`"
;;
*)
;;
esac
fi
# Return the available options
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
complete -F _keyringer keyringer
|