Merge pull request #8846 from metacollin/master
Turbocharged formula name completion
This commit is contained in:
commit
d3ae236954
@ -44,6 +44,7 @@ case "$*" in
|
|||||||
--caskroom) echo "$HOMEBREW_PREFIX/Caskroom"; exit 0 ;;
|
--caskroom) echo "$HOMEBREW_PREFIX/Caskroom"; exit 0 ;;
|
||||||
--cache) echo "$HOMEBREW_CACHE"; exit 0 ;;
|
--cache) echo "$HOMEBREW_CACHE"; exit 0 ;;
|
||||||
shellenv) source "$HOMEBREW_LIBRARY/Homebrew/cmd/shellenv.sh"; homebrew-shellenv; exit 0 ;;
|
shellenv) source "$HOMEBREW_LIBRARY/Homebrew/cmd/shellenv.sh"; homebrew-shellenv; exit 0 ;;
|
||||||
|
formulae) source "$HOMEBREW_LIBRARY/Homebrew/cmd/formulae.sh"; homebrew-formulae; exit 0 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
#####
|
#####
|
||||||
|
28
Library/Homebrew/cmd/formulae.sh
Normal file
28
Library/Homebrew/cmd/formulae.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#: * `formulae`
|
||||||
|
#:
|
||||||
|
#: List all locally installable formulae including short names.
|
||||||
|
#:
|
||||||
|
|
||||||
|
homebrew-formulae() {
|
||||||
|
local formulae
|
||||||
|
formulae="$( \
|
||||||
|
find "$HOMEBREW_REPOSITORY/Library/Taps" \
|
||||||
|
-type d \( \
|
||||||
|
-name Casks -o \
|
||||||
|
-name cmd -o \
|
||||||
|
-name .github -o \
|
||||||
|
-name lib -o \
|
||||||
|
-name spec -o \
|
||||||
|
-name vendor \
|
||||||
|
\) \
|
||||||
|
-prune -false -o -name '*\.rb' | \
|
||||||
|
sed -E -e 's/\.rb//g' \
|
||||||
|
-e 's_.*/Taps/(.*)/(home|linux)brew-_\1/_' \
|
||||||
|
-e 's|/Formula/|/|' \
|
||||||
|
)"
|
||||||
|
local shortnames
|
||||||
|
shortnames="$(echo "$formulae" | cut -d "/" -f 3)"
|
||||||
|
echo -e "$formulae \n $shortnames" | \
|
||||||
|
grep -v '^homebrew/core' | \
|
||||||
|
sort -uf
|
||||||
|
}
|
@ -78,6 +78,7 @@ module Homebrew
|
|||||||
|
|
||||||
puts Formatter.columns(Cask::Cask.to_a.map(&:full_name).sort)
|
puts Formatter.columns(Cask::Cask.to_a.map(&:full_name).sort)
|
||||||
else
|
else
|
||||||
|
# odeprecated "'brew search' with no arguments to output formulae", "'brew formulae'"
|
||||||
puts Formatter.columns(Formula.full_names.sort)
|
puts Formatter.columns(Formula.full_names.sort)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,9 +50,8 @@ __brewcomp() {
|
|||||||
# it is too slow and is not worth it just for duplicate elimination.
|
# it is too slow and is not worth it just for duplicate elimination.
|
||||||
__brew_complete_formulae() {
|
__brew_complete_formulae() {
|
||||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
local formulas="$(brew search)"
|
local formulae="$(brew formulae)"
|
||||||
local shortnames="$(echo "$formulas" | \grep / | \cut -d / -f 3)"
|
COMPREPLY=($(compgen -W "$formulae" -- "$cur"))
|
||||||
COMPREPLY=($(compgen -W "$formulas $shortnames" -- "$cur"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__brew_complete_installed() {
|
__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")) }'
|
'.each{ |k, v| puts([k, v].reject(&:nil?).join("\t")) }'
|
||||||
# backup: (note that it lists only formulae names without descriptions)
|
# backup: (note that it lists only formulae names without descriptions)
|
||||||
else
|
else
|
||||||
brew search
|
brew formulae
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ environment
|
|||||||
extract
|
extract
|
||||||
fetch
|
fetch
|
||||||
formula
|
formula
|
||||||
|
formulae
|
||||||
gist-logs
|
gist-logs
|
||||||
help
|
help
|
||||||
home
|
home
|
||||||
|
@ -54,7 +54,7 @@ __brew_formulae() {
|
|||||||
local -a list
|
local -a list
|
||||||
local comp_cachename=brew_formulae
|
local comp_cachename=brew_formulae
|
||||||
if ! _retrieve_cache $comp_cachename; then
|
if ! _retrieve_cache $comp_cachename; then
|
||||||
list=( $(brew search) )
|
list=( $(brew formulae) )
|
||||||
_store_cache $comp_cachename list
|
_store_cache $comp_cachename list
|
||||||
fi
|
fi
|
||||||
_describe -t formulae 'all formulae' list
|
_describe -t formulae 'all formulae' list
|
||||||
@ -111,6 +111,7 @@ __brew_common_commands() {
|
|||||||
'edit:edit a formula'
|
'edit:edit a formula'
|
||||||
'fetch:download formula resources to the cache'
|
'fetch:download formula resources to the cache'
|
||||||
'formula:the path for a formula'
|
'formula:the path for a formula'
|
||||||
|
'formulae:show a sorted list of installable formulae'
|
||||||
'gist-logs:generate a gist of the full build logs'
|
'gist-logs:generate a gist of the full build logs'
|
||||||
'home:visit the homepage of a formula or the brew project'
|
'home:visit the homepage of a formula or the brew project'
|
||||||
'info:information about a formula'
|
'info:information about a formula'
|
||||||
|
@ -227,6 +227,10 @@ and binaries for *`cask`*s. For files, also print SHA-256 checksums.
|
|||||||
* `--cask`:
|
* `--cask`:
|
||||||
Treat all named arguments as casks.
|
Treat all named arguments as casks.
|
||||||
|
|
||||||
|
### `formulae`
|
||||||
|
|
||||||
|
List all locally installable formulae including short names.
|
||||||
|
|
||||||
### `gist-logs` [*`options`*] *`formula`*
|
### `gist-logs` [*`options`*] *`formula`*
|
||||||
|
|
||||||
Upload logs for a failed build of *`formula`* to a new Gist. Presents an
|
Upload logs for a failed build of *`formula`* to a new Gist. Presents an
|
||||||
|
@ -304,6 +304,9 @@ Treat all named arguments as formulae\.
|
|||||||
\fB\-\-cask\fR
|
\fB\-\-cask\fR
|
||||||
Treat all named arguments as casks\.
|
Treat all named arguments as casks\.
|
||||||
.
|
.
|
||||||
|
.SS "\fBformulae\fR"
|
||||||
|
List all locally installable formulae including short names\.
|
||||||
|
.
|
||||||
.SS "\fBgist\-logs\fR [\fIoptions\fR] \fIformula\fR"
|
.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\.
|
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