diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-08-18 20:21:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2020-08-18 20:21:46 +0000 |
commit | bddee63922e227c73fd1b4e5b50bbef56bb9a61f (patch) | |
tree | ee729b4d2250e2935a4922f120637a68ed91db17 /.gita-completion.bash | |
parent | Initial commit. (diff) | |
download | gita-bddee63922e227c73fd1b4e5b50bbef56bb9a61f.tar.xz gita-bddee63922e227c73fd1b4e5b50bbef56bb9a61f.zip |
Adding upstream version 0.10.9.upstream/0.10.9
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '.gita-completion.bash')
-rw-r--r-- | .gita-completion.bash | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.gita-completion.bash b/.gita-completion.bash new file mode 100644 index 0000000..5090bb7 --- /dev/null +++ b/.gita-completion.bash @@ -0,0 +1,37 @@ + +_gita_completions() +{ + + local cur commands repos cmd + + cur=${COMP_WORDS[COMP_CWORD]} + cmd=${COMP_WORDS[1]} + + # FIXME: this is somewhat slow + commands=`gita -h | sed '2q;d' |sed 's/[{}.,]/ /g'` + + repos=`gita ls` + # 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 + COMPREPLY=($(compgen -W "${commands}" ${cur})) + elif [ $COMP_CWORD -gt 1 ]; then + case $cmd in + add) + COMPREPLY=($(compgen -d ${cur})) + ;; + ll) + return + ;; + *) + COMPREPLY=($(compgen -W "${repos}" ${cur})) + ;; + esac + fi + +} + +complete -F _gita_completions gita + |