diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-07-12 23:56:40 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-07-12 23:56:40 -0300 |
commit | 1046b1ebcb3bf0841636d2215faf95ddf1895b47 (patch) | |
tree | 188427e65edf9a5ea96740a4ef9564974f61ec78 | |
parent | e6e48ab8138d8d91943fda4485203a0ebaf25eef (diff) | |
download | keyringer-1046b1ebcb3bf0841636d2215faf95ddf1895b47.tar.gz keyringer-1046b1ebcb3bf0841636d2215faf95ddf1895b47.tar.bz2 |
More on completion
-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}`" ;; *) ;; |