diff options
| author | Osman Currim | 2013-12-08 02:40:09 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-12-12 19:08:23 -0600 |
| commit | b6f8649496b435a1675754ec052ffd72e27cb1d1 (patch) | |
| tree | 5ace7babda000f039046f213e56f6d4245be4e81 /Library/Contributions | |
| parent | bc3ebd8343b938e6fb424857cf275e69803769a7 (diff) | |
| download | brew-b6f8649496b435a1675754ec052ffd72e27cb1d1.tar.bz2 | |
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>
Diffstat (limited to 'Library/Contributions')
| -rw-r--r-- | Library/Contributions/brew_bash_completion.sh | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Library/Contributions/brew_bash_completion.sh b/Library/Contributions/brew_bash_completion.sh index b6dfe18a5..886c52ce3 100644 --- a/Library/Contributions/brew_bash_completion.sh +++ b/Library/Contributions/brew_bash_completion.sh @@ -88,6 +88,23 @@ __brew_complete_outdated () 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 () { __brewcomp "$(\ls $(brew --repository)/Library/Taps 2>/dev/null | sed 's/-/\//g')" @@ -458,6 +475,7 @@ _brew () outdated) _brew_outdated ;; pin) __brew_complete_formulae ;; search|-S) _brew_search ;; + switch) _brew_switch ;; tap) _brew_complete_tap ;; uninstall|remove|rm) _brew_uninstall ;; unpin) __brew_complete_formulae ;; |
