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 extpath="`brew --prefix`/Library/Contributions/examples"
35 if [ -d "$extpath" ]; then
36 EXTCMD=`cd "$extpath"; ls -1 brew-* 2>/dev/null \
37 | cut -d'.' -f1 | cut -d'-' -f2- | sed -e 's/\*//g'`
40 declare -i i=$COMP_CWORD-1
41 while [ $i -gt 0 ]; do
42 if [[ ${COMP_WORDS[i]} != -* \
43 || ${COMP_WORDS[i]} == "--cache" \
44 || ${COMP_WORDS[i]} == "--cellar" \
45 || ${COMP_WORDS[i]} == "--config" \
46 || ${COMP_WORDS[i]} == "--prefix" ]]; then
54 "cat"|"cleanup"|"deps"|"edit"|"home"|"log"|"prune"|"uses" \
55 |"--cache"|"--cellar"|"--prefix")
59 "link"|"remove"|"rm"|"uninstall"|"unlink")
60 _brew_formula_installed "$cur"
64 if [[ "$cur" == -* ]]; then
65 COMPREPLY=( $(compgen -W '--macports --fink \
71 if [[ "$cur" == -* ]]; then
72 COMPREPLY=( $(compgen -W '--all --github' \
80 if [[ "$cur" == -* ]]; then
81 COMPREPLY=( $(compgen -W '--git --HEAD -H \
82 --debug -d --force -f \
83 --interactive -i --verbose -v \
84 --ignore-dependencies --use-llvm' \
92 if [[ "$cur" == -* ]]; then
93 COMPREPLY=( $(compgen -W '
94 --unbrewed' -- "$cur") )
102 if [ "$cmd" = "$c" ]; then
109 if [[ "$cur" == -* ]]; then
110 COMPREPLY=( $(compgen -W '--cache --cellar --config \
111 --env --help --prefix --version -v -H' \
113 elif [ "$cmd" = "" ]; then
114 COMPREPLY=( $(compgen -W 'cat cleanup create deps doctor \
115 edit home info install link list log outdated prune \
116 remove rm search uninstall unlink up update uses \
121 complete -F _brew brew