1 # brew-completion: bash completion function for Homebrew (brew command)
2 # Copyright (c)2010 Alexander Barton <alex@barton.de>
3 # This is free software and published under the terms of the GNU
4 # General Public License, see the file COPYING for details.
10 prefix=`brew --prefix`
11 formulae=`brew search`
12 COMPREPLY=( $(compgen -W '$formulae' -- "$1") )
15 _brew_formula_installed()
19 prefix=`brew --prefix`
21 COMPREPLY=( $(compgen -W '$formulae' -- "$1") )
30 prev=${COMP_WORDS[COMP_CWORD-1]}
33 # Get list of all available external commands
34 EXTCMD=`cd /usr/local/bin; ls -1 brew-* | cut -d'.' -f1 \
35 | cut -d'-' -f2- | sed -e 's/\*//g'`
37 declare -i i=$COMP_CWORD-1
38 while [ $i -gt 0 ]; do
39 if [[ ${COMP_WORDS[i]} != -* \
40 || ${COMP_WORDS[i]} == "--cache" \
41 || ${COMP_WORDS[i]} == "--cellar" \
42 || ${COMP_WORDS[i]} == "--prefix" ]]; then
50 "cleanup"|"edit"|"home"|"log"|"prune" \
51 |"--cache"|"--cellar"|"--prefix")
55 "link"|"remove"|"uninstall"|"unlink")
56 _brew_formula_installed "$cur"
60 if [[ "$cur" == -* ]]; then
61 COMPREPLY=( $(compgen -W '--macports' \
67 if [[ "$cur" == -* ]]; then
68 COMPREPLY=( $(compgen -W '--github' \
76 if [[ "$cur" == -* ]]; then
77 COMPREPLY=( $(compgen -W '--HEAD -H \
78 --debug -d --interactive -i
79 --verbose -v --ignore-dependencies' \
87 if [[ "$cur" == -* ]]; then
88 COMPREPLY=( $(compgen -W '
89 --unbrewed' -- "$cur") )
100 if [ "$cmd" = "$c" ]; then
107 if [[ "$cur" == -* ]]; then
108 COMPREPLY=( $(compgen -W '--cache --cellar --help --prefix \
109 --version -v -H' -- "$cur") )
110 elif [ "$cmd" = "" ]; then
111 COMPREPLY=( $(compgen -W 'cleanup create edit home info \
112 install link list log outdated prune remove search \
113 uninstall unlink update $EXTCMD' -- "$cur") )
116 complete -F _brew brew