aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAdam Vandenberg2009-07-28 01:45:17 -0700
committerMax Howell2009-08-02 01:25:01 +0100
commit58ba5f9df62f615a301ce80d593b4bb523bee74f (patch)
tree42ea5cbcd64de76e7e85c107c91916e23e04666d /Library
parent1333e910cf80c4b25262b76b08f9a43e083394e7 (diff)
downloadbrew-58ba5f9df62f615a301ce80d593b4bb523bee74f.tar.bz2
Bash completion script for the brew command
Diffstat (limited to 'Library')
-rw-r--r--Library/Contributions/brew_bash_completion.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh
new file mode 100644
index 000000000..18a2e8431
--- /dev/null
+++ b/Library/Contributions/brew_bash_completion.sh
@@ -0,0 +1,35 @@
+_brew_to_completion()
+{
+ local actions cur prev
+ local cellar_contents formulae which_cellar brew_base
+
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ actions="install rm list info ln edit"
+
+ # Command list
+ if [[ ( ${COMP_CWORD} -eq 1 ) && ( ${COMP_WORDS[0]} == brew ) ]] ; then
+ COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
+ return 0
+ # Handle subcommands
+ else
+ brew_base=`which brew`
+ brew_base=`dirname ${brew_base}`/..
+
+ # Commands that take an existing brew...
+ if [[ ($prev == "list") || ($prev == "ln") || ($prev == "rm") ]] ; then
+ cellar_contents=`ls ${brew_base}/Cellar/`
+ COMPREPLY=( $(compgen -W "${cellar_contents}" -- ${cur}) )
+ return 0
+ # Commands that take a formula...
+ elif [[ ($prev == "install") ]] ; then
+ formulae=`ls ${brew_base}/Library/Formula/ | sed "s/\.rb//g"`
+ COMPREPLY=( $(compgen -W "${formulae}" -- ${cur}) )
+ return 0
+ fi
+ fi
+}
+
+complete -F _brew_to_completion brew