aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2009-09-08 23:44:00 -0400
committerAvatar Mike Kelly <pioto@pioto.org> 2009-09-08 23:44:00 -0400
commit8c20a6552fa820021d9952835a5f9724e5870263 (patch)
treef59e70246ebfac65dd49d8592e597d053f868daf
parent3a26e729b21cfc1191fcb9aebded849ee995f7cd (diff)
downloadpaludis-8c20a6552fa820021d9952835a5f9724e5870263.tar.gz
paludis-8c20a6552fa820021d9952835a5f9724e5870263.tar.xz
initial stab at cave bash completion
-rw-r--r--bash-completion/cave40
1 files changed, 40 insertions, 0 deletions
diff --git a/bash-completion/cave b/bash-completion/cave
new file mode 100644
index 0000000..305a7a5
--- /dev/null
+++ b/bash-completion/cave
@@ -0,0 +1,40 @@
+# Bash completion function for cave
+# Written by Mike Kelly
+# vim: set et sw=4 sts=4 ts=4 ft=sh :
+
+# Based in part upon 'git' bash completion from git-1.6.4.2
+
+_cave_find_cmd() {
+ local w c=1 cmd
+
+ while [[ $c -lt $COMP_CWORD ]] ; do
+ w="${COMP_WORDS[c]}"
+ case "${w}" in
+ --*) ;;
+ --help) cmd="help"; break ;;
+ *) cmd="${w}"; break ;;
+ esac
+ done
+
+ echo "${cmd}"
+}
+
+_cave() {
+ local cmd="$(_cave_find_cmd)" cur="${COMP_WORDS[COMP_CWORD]}"
+
+ if [[ -z "${cmd}" ]] ; then
+ case "${cur}" in
+ --*)
+ COMPREPLY=( $(compgen -W "--environment --log-level" -- "${cur}") )
+ ;;
+ *)
+ COMPREPLY=( $(compgen -W "$(cave print-commands)" -- "${cur}") )
+ ;;
+ esac
+ return
+ fi
+
+ COMPREPLY=()
+}
+complete -o bashdefault -o default -F _cave cave
+