Fix brew completion for brew install (#3309)

* Fix brew completion for `brew install`
* Using `brew search` rather than `brew --repository`
- Homebrew migrated the directory holding their Formulas into Taps, breaking fish's completions.
- New method to find all Homebrew-core Formulas
- Compatible with old versions of Homebrew and more future proof
* Replace fixed path to search formula with `brew --repository`
* Replace `sed` with builtin `string replace`
This commit is contained in:
Date Huang 2016-08-19 18:58:37 +08:00 committed by Aaron Gyes
parent df10ffab9c
commit 5dd959070c

View file

@ -17,9 +17,16 @@ function __fish_brew_using_command
end
function __fish_brew_formulae
set -l formuladir (brew --repository)/Library/Formula/
# __fish_complete_suffix .rb
ls $formuladir/*.rb | sed 's/.rb$//' | sed "s|^$formuladir||"
# list all local formula, do not use `brew search some_text` against searching online
# TODO fix the problem with `tap-pin`, tap-pin will modify the priority
# If you pin your custom tap for VIM, you should
# `brew install homebrew/core/vim` to install VIM from `core` repo
# `brew install vim` to install VIM from more prior repo
# but `brew search` won't change display for custom VIM and core VIM
# 'vim' for core VIM
# 'custUser/custRepo/vim' for more prior VIM
# more info: https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/brew-tap.md#formula-duplicate-names
brew search
end
function __fish_brew_installed_formulas