Merge pull request #10259 from kidonng/cask-completion
Add brew casks command
This commit is contained in:
commit
30d5fc6285
@ -55,6 +55,7 @@ case "$*" in
|
||||
--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 ;;
|
||||
casks) source "$HOMEBREW_LIBRARY/Homebrew/cmd/casks.sh"; homebrew-casks; exit 0 ;;
|
||||
esac
|
||||
|
||||
#####
|
||||
|
12
Library/Homebrew/cmd/casks.sh
Normal file
12
Library/Homebrew/cmd/casks.sh
Normal file
@ -0,0 +1,12 @@
|
||||
#: * `casks`
|
||||
#:
|
||||
#: List all locally installable casks including short names.
|
||||
#:
|
||||
|
||||
# Don't need shellcheck to follow the `source`.
|
||||
# shellcheck disable=SC1090
|
||||
source "$HOMEBREW_LIBRARY/Homebrew/items.sh"
|
||||
|
||||
homebrew-casks() {
|
||||
homebrew-items 'Formula' 's|/Casks/|/|' '^homebrew/cask'
|
||||
}
|
@ -3,35 +3,10 @@
|
||||
#: List all locally installable formulae including short names.
|
||||
#:
|
||||
|
||||
# Don't need shellcheck to follow the `source`.
|
||||
# shellcheck disable=SC1090
|
||||
source "$HOMEBREW_LIBRARY/Homebrew/items.sh"
|
||||
|
||||
homebrew-formulae() {
|
||||
local formulae
|
||||
local sed_extended_regex_flag
|
||||
|
||||
if [[ -n "$HOMEBREW_MACOS" ]]; then
|
||||
sed_extended_regex_flag="-E"
|
||||
else
|
||||
sed_extended_regex_flag="-r"
|
||||
fi
|
||||
|
||||
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 "$sed_extended_regex_flag" \
|
||||
-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
|
||||
homebrew-items 'Casks' 's|/Formula/|/|' '^homebrew/core'
|
||||
}
|
||||
|
35
Library/Homebrew/items.sh
Normal file
35
Library/Homebrew/items.sh
Normal file
@ -0,0 +1,35 @@
|
||||
homebrew-items() {
|
||||
local items
|
||||
local sed_extended_regex_flag
|
||||
local find_filter=$1
|
||||
local sed_filter=$2
|
||||
local grep_filter=$3
|
||||
|
||||
if [[ -n "$HOMEBREW_MACOS" ]]; then
|
||||
sed_extended_regex_flag="-E"
|
||||
else
|
||||
sed_extended_regex_flag="-r"
|
||||
fi
|
||||
|
||||
items="$( \
|
||||
find "$HOMEBREW_REPOSITORY/Library/Taps" \
|
||||
-type d \( \
|
||||
-name "$find_filter" -o \
|
||||
-name cmd -o \
|
||||
-name .github -o \
|
||||
-name lib -o \
|
||||
-name spec -o \
|
||||
-name vendor \
|
||||
\) \
|
||||
-prune -false -o -name '*\.rb' | \
|
||||
sed "$sed_extended_regex_flag" \
|
||||
-e 's/\.rb//g' \
|
||||
-e 's_.*/Taps/(.*)/(home|linux)brew-_\1/_' \
|
||||
-e "$sed_filter" \
|
||||
)"
|
||||
local shortnames
|
||||
shortnames="$(echo "$items" | cut -d "/" -f 3)"
|
||||
echo -e "$items\n$shortnames" | \
|
||||
grep -v "$grep_filter" | \
|
||||
sort -uf
|
||||
}
|
@ -655,12 +655,9 @@ __brew_caskcomp ()
|
||||
__brew_cask_complete_formulae ()
|
||||
{
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
local lib=$(brew --repository)/Library
|
||||
local taps=${lib}/Taps
|
||||
local casks=${lib}/Taps/homebrew/homebrew-cask/Casks
|
||||
local ff=$(\ls ${casks} 2>/dev/null | \sed 's/\.rb//g')
|
||||
local casks=$(brew casks)
|
||||
|
||||
COMPREPLY=($(compgen -W "$ff" -- "$cur"))
|
||||
COMPREPLY=($(compgen -W "$casks" -- "$cur"))
|
||||
}
|
||||
|
||||
__brew_cask_complete_installed ()
|
||||
|
@ -206,7 +206,7 @@ function __fish_brew_suggest_casks_outdated -d "Lists outdated casks with the in
|
||||
end
|
||||
|
||||
function __fish_brew_suggest_casks_all -d "Lists locally available casks"
|
||||
brew search --cask
|
||||
brew casks
|
||||
end
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ bump-formula-pr
|
||||
bump-revision
|
||||
bump-unversioned-casks
|
||||
cask
|
||||
casks
|
||||
cat
|
||||
cleanup
|
||||
command
|
||||
|
@ -18,7 +18,7 @@ __brew_all_casks() {
|
||||
local comp_cachename=brew_casks
|
||||
|
||||
if ! _retrieve_cache $comp_cachename; then
|
||||
list=( $(brew search --cask) )
|
||||
list=( $(brew casks) )
|
||||
_store_cache $comp_cachename list
|
||||
fi
|
||||
|
||||
|
@ -65,6 +65,10 @@ Uninstall formulae that were only installed as a dependency of another formula a
|
||||
* `-n`, `--dry-run`:
|
||||
List what would be uninstalled, but do not actually uninstall anything.
|
||||
|
||||
### `casks`
|
||||
|
||||
List all locally installable casks including short names.
|
||||
|
||||
### `cleanup` [*`options`*] [*`formula`*|*`cask`*]
|
||||
|
||||
Remove stale lock files and outdated downloads for all formulae and casks,
|
||||
|
@ -60,6 +60,9 @@ Uninstall formulae that were only installed as a dependency of another formula a
|
||||
\fB\-n\fR, \fB\-\-dry\-run\fR
|
||||
List what would be uninstalled, but do not actually uninstall anything\.
|
||||
.
|
||||
.SS "\fBcasks\fR"
|
||||
List all locally installable casks including short names\.
|
||||
.
|
||||
.SS "\fBcleanup\fR [\fIoptions\fR] [\fIformula\fR|\fIcask\fR]"
|
||||
Remove stale lock files and outdated downloads for all formulae and casks, and remove old versions of installed formulae\. If arguments are specified, only do this for the given formulae and casks\. Removes all downloads more than 120 days old\. This can be adjusted with \fBHOMEBREW_CLEANUP_MAX_AGE_DAYS\fR\.
|
||||
.
|
||||
|
Loading…
x
Reference in New Issue
Block a user