Add bash completion support for "brew switch"
First autocompletes on the names of installed packages and then autocompletes on available versions for that specific package Closes Homebrew/homebrew#25051. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
parent
bc3ebd8343
commit
b6f8649496
@ -88,6 +88,23 @@ __brew_complete_outdated ()
|
|||||||
COMPREPLY=($(compgen -W "$od" -- "$cur"))
|
COMPREPLY=($(compgen -W "$od" -- "$cur"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__brew_complete_versions ()
|
||||||
|
{
|
||||||
|
local formula="$1"
|
||||||
|
local versions=$(brew list --versions "$formula")
|
||||||
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
COMPREPLY=($(compgen -W "$versions" -X "$formula" -- "$cur"))
|
||||||
|
}
|
||||||
|
|
||||||
|
_brew_switch ()
|
||||||
|
{
|
||||||
|
case "$COMP_CWORD" in
|
||||||
|
2) __brew_complete_installed ;;
|
||||||
|
3) __brew_complete_versions "${COMP_WORDS[COMP_CWORD-1]}" ;;
|
||||||
|
*) ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
__brew_complete_tapped ()
|
__brew_complete_tapped ()
|
||||||
{
|
{
|
||||||
__brewcomp "$(\ls $(brew --repository)/Library/Taps 2>/dev/null | sed 's/-/\//g')"
|
__brewcomp "$(\ls $(brew --repository)/Library/Taps 2>/dev/null | sed 's/-/\//g')"
|
||||||
@ -458,6 +475,7 @@ _brew ()
|
|||||||
outdated) _brew_outdated ;;
|
outdated) _brew_outdated ;;
|
||||||
pin) __brew_complete_formulae ;;
|
pin) __brew_complete_formulae ;;
|
||||||
search|-S) _brew_search ;;
|
search|-S) _brew_search ;;
|
||||||
|
switch) _brew_switch ;;
|
||||||
tap) _brew_complete_tap ;;
|
tap) _brew_complete_tap ;;
|
||||||
uninstall|remove|rm) _brew_uninstall ;;
|
uninstall|remove|rm) _brew_uninstall ;;
|
||||||
unpin) __brew_complete_formulae ;;
|
unpin) __brew_complete_formulae ;;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user