From: Silvio Rhatto Date: Fri, 2 Aug 2013 21:46:42 +0000 (-0300) Subject: Initial git completion code X-Git-Tag: 0.2.1~3 X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=cfd43d8dcf3a50ce4855cc0d88dc3244120d3a3e;p=keyringer.git Initial git completion code --- diff --git a/lib/keyringer/completions/bash b/lib/keyringer/completions/bash index b255312..0edfb1b 100644 --- a/lib/keyringer/completions/bash +++ b/lib/keyringer/completions/bash @@ -2,6 +2,25 @@ # Keyringer bash completion # +# Completion for git subcommand +_keyringer_git_complete() { + if [ -e "/etc/bash_completion.d/git" ]; then + ( + source /etc/bash_completion.d/git + cd $path + COMP_WORDS=(git $*) + COMP_CWORD=$((${#COMP_WORDS[*]} - 1)) + + if [ "$COMP_CWORD" == "0" ]; then + COMP_CWORD=1 + fi + + _git + echo ${COMPREPLY[@]} + ) + fi +} + _keyringer() { # Standard stuff local cur prev opts config @@ -42,7 +61,7 @@ _keyringer() { opts="gpg ssh ssl ssl-self" ;; git) - # TODO: This depends on git's bash completion + opts="$(_keyringer_git_complete ${cur})" ;; *) ;; @@ -56,13 +75,14 @@ _keyringer() { opts="$(bash -c "set -f && keyringer $instance ls -p -d ${cur}*" 2> /dev/null)" ;; git) - # TODO: This depends on git's bash completion + # TODO + opts="$(_keyringer_git_complete ${prev} ${cur})" ;; *) ;; esac elif [ "${command}" == "git" ]; then - # TODO: This depends on git's bash completion + # TODO true fi