]> gitweb.fluxo.info Git - keyringer.git/commitdiff
More on bash completion
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 18 Jul 2013 21:11:23 +0000 (18:11 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 18 Jul 2013 21:11:23 +0000 (18:11 -0300)
lib/keyringer/completions/bash

index 5c56d4774204fb373166070abee1231a5fead3d8..b25531248d70b519dda5ba488f40cf81525aa51e 100644 (file)
@@ -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