summaryrefslogtreecommitdiffstats
path: root/auto-completion/bash
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-17 09:07:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-17 09:07:45 +0000
commit6364ea0daac38f21228a9f88e1da4c98181a28d2 (patch)
treec29909d1b64d704c339ec0b0bf8533051b92b182 /auto-completion/bash
parentReleasing debian version 0.16.6.1-2. (diff)
downloadgita-6364ea0daac38f21228a9f88e1da4c98181a28d2.tar.xz
gita-6364ea0daac38f21228a9f88e1da4c98181a28d2.zip
Merging upstream version 0.16.7.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'auto-completion/bash')
-rw-r--r--auto-completion/bash/.gita-completion.bash45
1 files changed, 45 insertions, 0 deletions
diff --git a/auto-completion/bash/.gita-completion.bash b/auto-completion/bash/.gita-completion.bash
new file mode 100644
index 0000000..cad120c
--- /dev/null
+++ b/auto-completion/bash/.gita-completion.bash
@@ -0,0 +1,45 @@
+
+_gita_completions()
+{
+
+ local cur commands repos cmd
+ local IFS=$'\n\t '
+
+ cur=${COMP_WORDS[COMP_CWORD]}
+ cmd=${COMP_WORDS[1]}
+
+
+ # this doesn't work for two repos with the same basename
+ #gita_path=${XDG_CONFIG_HOME:-$HOME/.config}/gita/repo_path
+ #repos=`awk '{split($0, paths, ":")} END {for (i in paths) {n=split(paths[i],b, /\//); print b[n]}}' ${gita_path}`
+
+ if [ $COMP_CWORD -eq 1 ]; then
+ # FIXME: this is somewhat slow
+ commands=`gita -h | sed '2q;d' |sed 's/[{}.,]/ /g'`
+ COMPREPLY=($(compgen -W "${commands}" ${cur}))
+ elif [ $COMP_CWORD -gt 1 ]; then
+ case $cmd in
+ add)
+ COMPREPLY=($(compgen -d ${cur}))
+ ;;
+ clone)
+ COMPREPLY=($(compgen -f ${cur}))
+ ;;
+ color | flags)
+ COMPREPLY=($(compgen -W "ll set" ${cur}))
+ ;;
+ ll | context)
+ groups=`gita group ls`
+ COMPREPLY=($(compgen -W "${groups}" ${cur}))
+ return
+ ;;
+ *)
+ repos=`gita ls`
+ COMPREPLY=($(compgen -W "${repos}" ${cur}))
+ ;;
+ esac
+ fi
+}
+
+complete -F _gita_completions gita
+