1 # brew-completion: bash completion function for Homebrew (brew command)
2 # Copyright (c)1020 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 pushd "$prefix"/Library/Formula >/dev/null
12 formulae=`echo * | sed 's/\.rb//g'`
14 COMPREPLY=( $(compgen -W '$formulae' -- "$1") )
17 _brew_formula_installed()
21 prefix=`brew --prefix`
22 pushd "$prefix"/Cellar >/dev/null
25 COMPREPLY=( $(compgen -W '$formulae' -- "$1") )
34 prev=${COMP_WORDS[COMP_CWORD-1]}
37 declare -i i=$COMP_CWORD-1
38 while [ $i -gt 0 ]; do
39 if [[ ${COMP_WORDS[i]} != -* ]]; then
47 "edit"|"home"|"log"|"prune")
51 "link"|"remove"|"uninstall"|"unlink")
52 _brew_formula_installed "$cur"
56 if [[ "$cur" == -* ]]; then
57 COMPREPLY=( $(compgen -W '--macports' \
63 if [[ "$cur" == -* ]]; then
64 COMPREPLY=( $(compgen -W '--github' \
72 if [[ "$cur" == -* ]]; then
73 COMPREPLY=( $(compgen -W '--HEAD -H \
74 --debug -d --interactive -i
75 --verbose -v --ignore-dependencies' \
83 if [[ "$cur" == -* ]]; then
84 COMPREPLY=( $(compgen -W '--brewed \
85 --unbrewed' -- "$cur") )
96 if [[ "$cur" == -* ]]; then
97 COMPREPLY=( $(compgen -W '--cache --help --prefix --version \
99 elif [ "$cmd" = "" ]; then
100 COMPREPLY=( $(compgen -W 'create edit home info install \
101 link list log prune remove search uninstall unlink \
105 complete -F _brew brew