Turbocharged formula name completion
This commit is contained in:
parent
24c825efe2
commit
b04a5ffa0b
@ -38,12 +38,13 @@ HOMEBREW_TEMP="${HOMEBREW_TEMP:-${HOMEBREW_DEFAULT_TEMP}}"
|
||||
# Don't need shellcheck to follow these `source`.
|
||||
# shellcheck disable=SC1090
|
||||
case "$*" in
|
||||
--prefix) echo "$HOMEBREW_PREFIX"; exit 0 ;;
|
||||
--cellar) echo "$HOMEBREW_CELLAR"; exit 0 ;;
|
||||
--repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;;
|
||||
--caskroom) echo "$HOMEBREW_PREFIX/Caskroom"; exit 0 ;;
|
||||
--cache) echo "$HOMEBREW_CACHE"; exit 0 ;;
|
||||
shellenv) source "$HOMEBREW_LIBRARY/Homebrew/cmd/shellenv.sh"; homebrew-shellenv; exit 0 ;;
|
||||
--prefix) echo "$HOMEBREW_PREFIX"; exit 0 ;;
|
||||
--cellar) echo "$HOMEBREW_CELLAR"; exit 0 ;;
|
||||
--repository|--repo) echo "$HOMEBREW_REPOSITORY"; exit 0 ;;
|
||||
--caskroom) echo "$HOMEBREW_PREFIX/Caskroom"; exit 0 ;;
|
||||
--cache) echo "$HOMEBREW_CACHE"; exit 0 ;;
|
||||
shellenv) source "$HOMEBREW_LIBRARY/Homebrew/cmd/shellenv.sh"; homebrew-shellenv; exit 0 ;;
|
||||
formulae|formulas) source "$HOMEBREW_LIBRARY/Homebrew/cmd/formulae.sh"; homebrew-formulae; exit 0 ;;
|
||||
esac
|
||||
|
||||
#####
|
||||
|
||||
11
Library/Homebrew/cmd/formulae.sh
Normal file
11
Library/Homebrew/cmd/formulae.sh
Normal file
@ -0,0 +1,11 @@
|
||||
#: * `formulae`
|
||||
#:
|
||||
#: Prints a sorted list of locally available formulas including shortnames.
|
||||
#:
|
||||
|
||||
# shellcheck disable=SC2155
|
||||
homebrew-formulae() {
|
||||
local formulae="$(find "$HOMEBREW_REPOSITORY"/Library/Taps -type d \( -name Casks -o -name cmd -o -name .github \) -prune -false -o -name '*rb' | sed 's/\.rb//g' | sed -E 's .*/Taps/(.*)/homebrew- \1/ g' | sed 's /Formula/ / g')"
|
||||
local shortnames="$(echo "$formulae" | cut -d / -f 3)"
|
||||
echo -e "$formulae \n $shortnames" | grep -v '^homebrew/' | sort -uf
|
||||
}
|
||||
@ -50,9 +50,8 @@ __brewcomp() {
|
||||
# it is too slow and is not worth it just for duplicate elimination.
|
||||
__brew_complete_formulae() {
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local formulas="$(brew search)"
|
||||
local shortnames="$(echo "$formulas" | \grep / | \cut -d / -f 3)"
|
||||
COMPREPLY=($(compgen -W "$formulas $shortnames" -- "$cur"))
|
||||
local formulae="$(brew formulae)"
|
||||
COMPREPLY=($(compgen -W "$formulae" -- "$cur"))
|
||||
}
|
||||
|
||||
__brew_complete_installed() {
|
||||
|
||||
@ -99,7 +99,7 @@ function __fish_brew_suggest_formulae_all -d 'Lists all available formulae with
|
||||
'.each{ |k, v| puts([k, v].reject(&:nil?).join("\t")) }'
|
||||
# backup: (note that it lists only formulae names without descriptions)
|
||||
else
|
||||
brew search
|
||||
brew formulae
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -37,6 +37,7 @@ environment
|
||||
extract
|
||||
fetch
|
||||
formula
|
||||
formulae
|
||||
gist-logs
|
||||
help
|
||||
home
|
||||
|
||||
@ -54,7 +54,7 @@ __brew_formulae() {
|
||||
local -a list
|
||||
local comp_cachename=brew_formulae
|
||||
if ! _retrieve_cache $comp_cachename; then
|
||||
list=( $(brew search) )
|
||||
list=( $(brew formulae) )
|
||||
_store_cache $comp_cachename list
|
||||
fi
|
||||
_describe -t formulae 'all formulae' list
|
||||
@ -111,6 +111,7 @@ __brew_common_commands() {
|
||||
'edit:edit a formula'
|
||||
'fetch:download formula resources to the cache'
|
||||
'formula:the path for a formula'
|
||||
'formulas:show a sorted list of installable formulas'
|
||||
'gist-logs:generate a gist of the full build logs'
|
||||
'home:visit the homepage of a formula or the brew project'
|
||||
'info:information about a formula'
|
||||
|
||||
@ -240,6 +240,10 @@ For tarballs, also print SHA-256 checksums.
|
||||
* `--force-bottle`:
|
||||
Download a bottle if it exists for the current or newest version of macOS, even if it would not be used during installation.
|
||||
|
||||
### `formulae`
|
||||
|
||||
Prints a sorted list of locally available formulas including shortnames.
|
||||
|
||||
### `gist-logs` [*`options`*] *`formula`*
|
||||
|
||||
Upload logs for a failed build of *`formula`* to a new Gist. Presents an
|
||||
|
||||
@ -336,6 +336,9 @@ Download source packages (for eventual bottling) rather than a bottle\.
|
||||
\fB\-\-force\-bottle\fR
|
||||
Download a bottle if it exists for the current or newest version of macOS, even if it would not be used during installation\.
|
||||
.
|
||||
.SS "\fBformulae\fR"
|
||||
Prints a sorted list of locally available formulas including shortnames\.
|
||||
.
|
||||
.SS "\fBgist\-logs\fR [\fIoptions\fR] \fIformula\fR"
|
||||
Upload logs for a failed build of \fIformula\fR to a new Gist\. Presents an error message if no logs are found\.
|
||||
.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user