aboutsummaryrefslogtreecommitdiffstats
path: root/completion
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2008-11-27 09:26:52 -0500
committerW. Trevor King <wking@drexel.edu>2008-11-27 09:26:52 -0500
commitadb7e854b56aa7c3df6fae677fe383f417e364c4 (patch)
treea396ad3ba0d175f8a157c2e8ec6a19240b56510e /completion
parent998525bf43305b1d53927975621ab9f211d0ed95 (diff)
downloadbugseverywhere-adb7e854b56aa7c3df6fae677fe383f417e364c4.tar.gz
Basic bash completion is now supported.
I'm still working on a clean implementation though...
Diffstat (limited to 'completion')
-rw-r--r--completion/be.bash43
1 files changed, 43 insertions, 0 deletions
diff --git a/completion/be.bash b/completion/be.bash
new file mode 100644
index 0000000..8789352
--- /dev/null
+++ b/completion/be.bash
@@ -0,0 +1,43 @@
+#!/bin/bash
+# Bash completion script for be (Bugs Everywhere)
+#
+# System wide installation:
+# Copy this file to /etc/bash_completion/be
+# Per-user installation:
+# Copy this file to ~/.be-completion.sh and source it in your .bashrc:
+# source ~/.be-completion.sh
+#
+# For a good intro to Bash completion, see Steve Kemp's article
+# "An introduction to bash completion: part 2"
+# http://www.debian-administration.org/articles/317
+
+# Support commands of the form:
+# be <command> [<long option>] [<long option>] ...
+# Requires:
+# be --commands
+# to print a list of available commands
+# be command [<option> ...] --options
+# to print a list of available long options
+_be()
+{
+ local cur prev opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ if [ $COMP_CWORD -eq 1 ]; then
+ # no command yet, show all commands
+ COMPREPLY=( $( compgen -W "$(be --commands)" -- $cur ) )
+ else
+ # remove the first word (should be "be") for security reasons
+ unset COMP_WORDS[0]
+ # remove the current word and all later words, because they
+ # are not needed for completion.
+ for i in `seq $COMP_CWORD ${#COMP_WORDS[@]}`; do
+ unset COMP_WORDS[$i];
+ done
+ COMPREPLY=( $( compgen -W "$(be "${COMP_WORDS[@]}" --options)" -- $cur ) )
+ fi
+}
+
+complete -F _be be