diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index d0b15e080f..096e74b13c 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -44,6 +44,7 @@ case "$*" in --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) source "$HOMEBREW_LIBRARY/Homebrew/cmd/formulae.sh"; homebrew-formulae; exit 0 ;; esac ##### diff --git a/Library/Homebrew/cmd/formulae.sh b/Library/Homebrew/cmd/formulae.sh new file mode 100644 index 0000000000..e4eab99abd --- /dev/null +++ b/Library/Homebrew/cmd/formulae.sh @@ -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 +} diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 4dca6423bb..480023574c 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -78,6 +78,7 @@ module Homebrew puts Formatter.columns(Cask::Cask.to_a.map(&:full_name).sort) else + # odeprecated "'brew search' with no arguments to output formulae", "'brew formulae'" puts Formatter.columns(Formula.full_names.sort) end diff --git a/completions/bash/brew b/completions/bash/brew index f20533bbf4..49eed71526 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -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() { diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index 2e862fb533..c5894b5cb6 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -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 diff --git a/completions/internal_commands_list.txt b/completions/internal_commands_list.txt index 0d277a1200..9c91e9f1f3 100644 --- a/completions/internal_commands_list.txt +++ b/completions/internal_commands_list.txt @@ -37,6 +37,7 @@ environment extract fetch formula +formulae gist-logs help home diff --git a/completions/zsh/_brew b/completions/zsh/_brew index 1ff67fac63..3e81da5624 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -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' + 'formulae:show a sorted list of installable formulae' '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' diff --git a/docs/Manpage.md b/docs/Manpage.md index 5f883288c1..af61cac3c3 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -227,6 +227,10 @@ and binaries for *`cask`*s. For files, also print SHA-256 checksums. * `--cask`: Treat all named arguments as casks. +### `formulae` + +List all locally installable formulae including short names. + ### `gist-logs` [*`options`*] *`formula`* Upload logs for a failed build of *`formula`* to a new Gist. Presents an diff --git a/manpages/brew.1 b/manpages/brew.1 index f5985d49c8..777ab1cd2f 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -304,6 +304,9 @@ Treat all named arguments as formulae\. \fB\-\-cask\fR 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" Upload logs for a failed build of \fIformula\fR to a new Gist\. Presents an error message if no logs are found\. .