From cfd43d8dcf3a50ce4855cc0d88dc3244120d3a3e Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 2 Aug 2013 18:46:42 -0300 Subject: Initial git completion code --- lib/keyringer/completions/bash | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) 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 -- cgit v1.2.3