Add all commands to the bash completion script.
This commit is contained in:
parent
fdc091ed42
commit
fe71812af6
@ -1,3 +1,10 @@
|
|||||||
|
# This script contains bash completions for brew.
|
||||||
|
# To use, edit your .bashrc and add the line:
|
||||||
|
# source <path-to-homebrew>/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()
|
_brew_to_completion()
|
||||||
{
|
{
|
||||||
local actions cur prev
|
local actions cur prev
|
||||||
@ -7,28 +14,34 @@ _brew_to_completion()
|
|||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
actions="install rm list info ln edit"
|
# We only complete unabbreviated commands...
|
||||||
|
actions="edit info install list link make uninstall"
|
||||||
|
|
||||||
# Command list
|
# Subcommand list
|
||||||
if [[ ( ${COMP_CWORD} -eq 1 ) && ( ${COMP_WORDS[0]} == brew ) ]] ; then
|
if [[ ( ${COMP_CWORD} -eq 1 ) && ( ${COMP_WORDS[0]} == brew ) ]] ; then
|
||||||
COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${actions}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
# Handle subcommands
|
# Subcommands
|
||||||
else
|
else
|
||||||
brew_base=`which brew`
|
brew_base=`which brew`
|
||||||
brew_base=`dirname ${brew_base}`/..
|
brew_base=`dirname ${brew_base}`/..
|
||||||
|
|
||||||
# Commands that take an existing brew...
|
case ${prev} in
|
||||||
if [[ ($prev == "list") || ($prev == "ln") || ($prev == "rm") || ($prev == "info") ]] ; then
|
|
||||||
cellar_contents=`ls ${brew_base}/Cellar/`
|
|
||||||
COMPREPLY=( $(compgen -W "${cellar_contents}" -- ${cur}) )
|
|
||||||
return 0
|
|
||||||
# Commands that take a formula...
|
# Commands that take a formula...
|
||||||
elif [[ ($prev == "install") ]] ; then
|
edit|install)
|
||||||
formulae=`ls ${brew_base}/Library/Formula/ | sed "s/\.rb//g"`
|
formulae=`ls ${brew_base}/Library/Formula/ | sed "s/\.rb//g"`
|
||||||
COMPREPLY=( $(compgen -W "${formulae}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${formulae}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
fi
|
;;
|
||||||
|
|
||||||
|
# Commands that take an existing brew...
|
||||||
|
abv|info|list|link|ls|ln|rm|uninstall)
|
||||||
|
cellar_contents=`ls ${brew_base}/Cellar/`
|
||||||
|
COMPREPLY=( $(compgen -W "${cellar_contents}" -- ${cur}) )
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user