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

index 6de93bb204714eec2fd63dfbf1868df9c259e745..2d6fd29312827c80aa9adc3be3909a873f8e3945 100644 (file)
@@ -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}`"
         ;;
       *)
         ;;