
Large refactor to Formula, mostly improving reliability and error handling but also layout and readability. General improvements so testing can be more complete. Patches are automatically downloaded and applied for Formula that return a list of urls from Formula::patches. Split out the brew command logic to facilitate testing. Facility from Adam Vandenberg to allow selective cleaning of files, added because Python doesn't work when stripped.
49 lines
1.5 KiB
Bash
49 lines
1.5 KiB
Bash
# This script contains bash completions for brew.
|
|
# To use, edit your .bashrc and add the line:
|
|
# source `brew --prefix`/Library/Contributions/brew_bash_completion.sh
|
|
#
|
|
# Assuming you have brew installed in /usr/local, then you'll want:
|
|
# source /usr/local/Library/Contributions/brew_bash_completion.sh
|
|
|
|
_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]}"
|
|
|
|
# We only complete unabbreviated commands...
|
|
actions="edit homepage info install list link make uninstall"
|
|
|
|
# Subcommand list
|
|
if [[ ( ${COMP_CWORD} -eq 1 ) && ( ${COMP_WORDS[0]} == brew ) ]] ; then
|
|
COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
|
|
return 0
|
|
# Subcommands
|
|
else
|
|
brew_base=`which brew`
|
|
brew_base=`dirname ${brew_base}`/..
|
|
|
|
case ${prev} in
|
|
# Commands that take a formula...
|
|
edit|install|home|homepage)
|
|
formulae=`ls ${brew_base}/Library/Formula/ | sed "s/\.rb//g"`
|
|
COMPREPLY=( $(compgen -W "${formulae}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
|
|
# Commands that take an existing brew...
|
|
abv|info|list|link|ls|ln|rm|remove|uninstall)
|
|
cellar_contents=`ls ${brew_base}/Cellar/`
|
|
COMPREPLY=( $(compgen -W "${cellar_contents}" -- ${cur}) )
|
|
return 0
|
|
;;
|
|
|
|
esac
|
|
fi
|
|
}
|
|
|
|
complete -F _brew_to_completion brew
|