aboutsummaryrefslogtreecommitdiff
path: root/lib/keyringer/completions/bash/keyringer
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-09-29 18:43:10 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-09-29 18:43:10 -0300
commitd9d0c1fdec1a1beebba75e00af7af6f9adc94535 (patch)
tree91f5a2b2cd2a2a3d804b1ef702b70be6cccb058d /lib/keyringer/completions/bash/keyringer
parentbdbf214658446e0821e67a5e58695df0881247b6 (diff)
downloadkeyringer-d9d0c1fdec1a1beebba75e00af7af6f9adc94535.tar.gz
keyringer-d9d0c1fdec1a1beebba75e00af7af6f9adc94535.tar.bz2
Shell completion: adding 'init' subcommand
Diffstat (limited to 'lib/keyringer/completions/bash/keyringer')
-rw-r--r--lib/keyringer/completions/bash/keyringer17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/keyringer/completions/bash/keyringer b/lib/keyringer/completions/bash/keyringer
index ccc1851..875e6ab 100644
--- a/lib/keyringer/completions/bash/keyringer
+++ b/lib/keyringer/completions/bash/keyringer
@@ -60,20 +60,22 @@ _keyringer() {
# Process config
source $config/config
- path="`eval echo '$'$instance`"
- keyrings="`ls --color=never $config | sed -e 's/config//'`"
+ keyrings="`ls --color=never $config | sed -e 's/config//' | xargs`"
# Available instances
- instances="`echo $keyrings | sed -e 's/ /|/'`"
+ instances="`echo $keyrings | sed -e 's/ /\\\|/g'`"
# The current instance
instance="${COMP_WORDS[1]}"
+ path="`eval echo '$'$instance`"
# Command completions
if [ "${#COMP_WORDS[@]}" == "2" ]; then
opts="$keyrings"
- elif [ "${#COMP_WORDS[@]}" == "3" ] && echo "${prev}" | grep -qe "[$instances]"; then
+ elif [ "${#COMP_WORDS[@]}" == "3" ] && echo "${prev}" | grep -qe "$instances"; then
opts="`export KEYRINGER_CHECK_VERSION=false && keyringer $instance commands`"
+ elif [ "${#COMP_WORDS[@]}" == "3" ]; then
+ opts="init"
elif [ "${#COMP_WORDS[@]}" == "4" ]; then
case "${prev}" in
options|preferences)
@@ -91,6 +93,13 @@ _keyringer() {
git)
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}
+
+ opts="$(compgen -o dirnames ${cur})"
+ ;;
*)
;;
esac