summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-08-02 18:46:42 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-08-02 18:46:42 -0300
commitcfd43d8dcf3a50ce4855cc0d88dc3244120d3a3e (patch)
tree80550ea36966209f8e8a70f679cb8a9e32129b00
parent5e6cad5498cb03a4844ef4e65fba49f1ce3439e1 (diff)
downloadkeyringer-cfd43d8dcf3a50ce4855cc0d88dc3244120d3a3e.tar.gz
keyringer-cfd43d8dcf3a50ce4855cc0d88dc3244120d3a3e.tar.bz2
Initial git completion code
-rw-r--r--lib/keyringer/completions/bash26
1 files 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