]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Enhancing shell completion for 'encrypt' action
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 14 Nov 2013 12:41:59 +0000 (10:41 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 14 Nov 2013 12:41:59 +0000 (10:41 -0200)
lib/keyringer/completions/bash/keyringer
lib/keyringer/completions/zsh/_keyringer

index 875e6ab36227fa900ead0a74ae0dbf855c464d01..7bfa62f56f71773e40adb393dff4fcfda9530fdd 100644 (file)
@@ -42,6 +42,15 @@ _keyringer_git_complete() {
   fi
 }
 
+# Path completion
+function _keyringer_path_complete() {
+  # Thanks http://unix.stackexchange.com/questions/55520/create-bash-completion-script-to-autocomplete-paths-after-is-equal-sign
+  cur=${1//\\ / }
+  [[ ${cur} == "~/"* ]] && cur=${cur/\~/$HOME}
+
+  echo ${cur}
+}
+
 _keyringer() {
   # Standard stuff
   local cur prev command config path keyrings instances instance opts
@@ -94,10 +103,7 @@ _keyringer() {
         opts="$(_keyringer_git_complete ${cur})"
         ;;
       init)
-        # Thanks http://unix.stackexchange.com/questions/55520/create-bash-completion-script-to-autocomplete-paths-after-is-equal-sign
-        cur=${cur//\\ / }
-        [[ ${cur} == "~/"* ]] && cur=${cur/\~/$HOME}
-
+        cur="$(_keyringer_path_complete ${cur})"
         opts="$(compgen -o dirnames ${cur})"
         ;;
       *)
@@ -115,6 +121,10 @@ _keyringer() {
         # TODO
         opts="$(_keyringer_git_complete ${prev} ${cur})"
         ;;
+      encrypt|encrypt-batch)
+        cur="$(_keyringer_path_complete ${cur})"
+        opts="$(compgen -o dirnames ${cur})"
+        ;;
       *)
         ;;
     esac
index 119d26db39636490291d652f6fc5d2323538f0e6..50ff4331ae2858dac74ce422e4a7bfa39cd1f1a7 100644 (file)
@@ -77,6 +77,9 @@ _keyringer() {
           git)
             compadd "$@" $(_keyringer_git_complete $words[4] $words[5])
             ;;
+          encrypt|encrypt-batch)
+            _files
+            ;;
           *)
             ;;
         esac