From 5e6cad5498cb03a4844ef4e65fba49f1ce3439e1 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 18 Jul 2013 18:11:23 -0300 Subject: More on bash completion --- lib/keyringer/completions/bash | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/keyringer/completions/bash b/lib/keyringer/completions/bash index 5c56d47..b255312 100644 --- a/lib/keyringer/completions/bash +++ b/lib/keyringer/completions/bash @@ -8,11 +8,16 @@ _keyringer() { COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" + command="${COMP_WORDS[2]}" # Initial options config="$HOME/.keyringer" opts="`ls $config | sed -e 's/config//'`" + # Process config + source $config/config + path="`eval echo '$'$instance`" + # Available instances instances="`echo $opts | sed -e 's/ /|/'`" @@ -36,9 +41,29 @@ _keyringer() { genpair) opts="gpg ssh ssl ssl-self" ;; + git) + # TODO: This depends on git's bash completion + ;; + *) + ;; + esac + elif [ "${#COMP_WORDS[@]}" == "5" ]; then + case "${command}" in + recipients) + opts="$(cd $path/config/recipients && ls -p ${cur}* 2> /dev/null)" + ;; + genpair) + opts="$(bash -c "set -f && keyringer $instance ls -p -d ${cur}*" 2> /dev/null)" + ;; + git) + # TODO: This depends on git's bash completion + ;; *) ;; esac + elif [ "${command}" == "git" ]; then + # TODO: This depends on git's bash completion + true fi # Avoid annoying bell and extra tab -- cgit v1.2.3