2009-07-31 09:45:04 -07:00
|
|
|
# This script contains bash completions for brew.
|
|
|
|
# To use, edit your .bashrc and add the line:
|
2009-07-31 22:10:50 -07:00
|
|
|
# source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
|
2009-07-31 09:45:04 -07:00
|
|
|
#
|
|
|
|
# Assuming you have brew installed in /usr/local, then you'll want:
|
|
|
|
# source /usr/local/Library/Contributions/brew_bash_completion.sh
|
|
|
|
|
2009-07-28 01:45:17 -07:00
|
|
|
_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]}"
|
|
|
|
|
2009-07-31 09:45:04 -07:00
|
|
|
# We only complete unabbreviated commands...
|
2009-08-22 15:54:26 +01:00
|
|
|
actions="edit homepage info install list link make uninstall"
|
2009-07-28 01:45:17 -07:00
|
|
|
|
2009-07-31 09:45:04 -07:00
|
|
|
# Subcommand list
|
2009-07-28 01:45:17 -07:00
|
|
|
if [[ ( ${COMP_CWORD} -eq 1 ) && ( ${COMP_WORDS[0]} == brew ) ]] ; then
|
|
|
|
COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
|
|
|
|
return 0
|
2009-07-31 09:45:04 -07:00
|
|
|
# Subcommands
|
2009-07-28 01:45:17 -07:00
|
|
|
else
|
|
|
|
brew_base=`which brew`
|
|
|
|
brew_base=`dirname ${brew_base}`/..
|
|
|
|
|
2009-07-31 09:45:04 -07:00
|
|
|
case ${prev} in
|
|
|
|
# Commands that take a formula...
|
2009-08-03 11:13:08 +08:00
|
|
|
edit|install|home|homepage)
|
2009-07-31 09:45:04 -07:00
|
|
|
formulae=`ls ${brew_base}/Library/Formula/ | sed "s/\.rb//g"`
|
|
|
|
COMPREPLY=( $(compgen -W "${formulae}" -- ${cur}) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
# Commands that take an existing brew...
|
2009-08-10 16:48:30 +01:00
|
|
|
abv|info|list|link|ls|ln|rm|remove|uninstall)
|
2009-07-31 09:45:04 -07:00
|
|
|
cellar_contents=`ls ${brew_base}/Cellar/`
|
|
|
|
COMPREPLY=( $(compgen -W "${cellar_contents}" -- ${cur}) )
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
2009-07-28 01:45:17 -07:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
complete -F _brew_to_completion brew
|