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]} == "--config" \
43 || ${COMP_WORDS[i]} == "--prefix" ]]; then
51 "cat"|"cleanup"|"deps"|"edit"|"home"|"log"|"prune"|"uses" \
52 |"--cache"|"--cellar"|"--prefix")
56 "link"|"remove"|"rm"|"uninstall"|"unlink")
57 _brew_formula_installed "$cur"
61 if [[ "$cur" == -* ]]; then
62 COMPREPLY=( $(compgen -W '--macports --fink \
68 if [[ "$cur" == -* ]]; then
69 COMPREPLY=( $(compgen -W '--all --github' \
77 if [[ "$cur" == -* ]]; then
78 COMPREPLY=( $(compgen -W '--git --HEAD -H \
79 --debug -d --force -f \
80 --interactive -i --verbose -v \
81 --ignore-dependencies --use-llvm' \
89 if [[ "$cur" == -* ]]; then
90 COMPREPLY=( $(compgen -W '
91 --unbrewed' -- "$cur") )
99 if [ "$cmd" = "$c" ]; then
106 if [[ "$cur" == -* ]]; then
107 COMPREPLY=( $(compgen -W '--cache --cellar --config \
108 --env --help --prefix --version -v -H' \
110 elif [ "$cmd" = "" ]; then
111 COMPREPLY=( $(compgen -W 'cat cleanup create deps doctor \
112 edit home info install link list log outdated prune \
113 remove rm search uninstall unlink up update uses \
118 complete -F _brew brew