diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/keyringer/completions/bash | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/lib/keyringer/completions/bash b/lib/keyringer/completions/bash index 6de93bb..2d6fd29 100644 --- a/lib/keyringer/completions/bash +++ b/lib/keyringer/completions/bash @@ -3,27 +3,39 @@ # _keyringer() { - local cur prev opts + # Standard stuff + local cur prev opts config COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" # Initial options - opts="`ls $HOME/.keyringer | sed -e 's/config//'`" + config="$HOME/.keyringer" + opts="`ls $config | sed -e 's/config//'`" - # Available keyrings - keyrings="`echo $opts | sed -e 's/ /|/'`" + # Available instances + instances="`echo $opts | sed -e 's/ /|/'`" - # The current keyring - keyring="${COMP_WORDS[1]}" + # The current instance + instance="${COMP_WORDS[1]}" # Command completions - if [ "${#COMP_WORDS[@]}" == "3" ] && echo "${prev}" | grep -qe "[$keyrings]"; then - opts="`keyringer $keyring commands`" - else + if [ "${#COMP_WORDS[@]}" == "3" ] && echo "${prev}" | grep -qe "[$instances]"; then + opts="`keyringer $instance commands`" + elif [ "${#COMP_WORDS[@]}" == "4" ]; then + # Process config + source $config/config + case "${prev}" in + options|preferences) + opts="ls edit add" + ;; + recipients) + opts="ls edit" + ;; ls) - opts="`keyringer $keyring ls ${cur}`" + # TODO + opts="`keyringer $instance ls ${cur}`" ;; *) ;; |