mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

- Allow subdirectories inside `Casks`/`Formula` directories. - DRY up repeated code with some variables.
29 lines
804 B
Bash
29 lines
804 B
Bash
#: * `casks`
|
|
#:
|
|
#: List all locally installable casks including short names.
|
|
#:
|
|
|
|
# HOMEBREW_LIBRARY is set in bin/brew
|
|
# shellcheck disable=SC2154
|
|
source "${HOMEBREW_LIBRARY}/Homebrew/items.sh"
|
|
|
|
homebrew-casks() {
|
|
local find_include_filter='*/Casks/*\.rb'
|
|
local sed_filter='s|/Casks/(.+/)?|/|'
|
|
local grep_filter='^homebrew/cask'
|
|
|
|
# HOMEBREW_CACHE is set by brew.sh
|
|
# shellcheck disable=SC2154
|
|
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" &&
|
|
-f "${HOMEBREW_CACHE}/api/cask_names.txt" ]]
|
|
then
|
|
{
|
|
cat "${HOMEBREW_CACHE}/api/cask_names.txt"
|
|
echo
|
|
homebrew-items "${find_include_filter}" '.*/homebrew/homebrew-cask/.*' "${sed_filter}" "${grep_filter}"
|
|
} | sort -uf
|
|
else
|
|
homebrew-items "${find_include_filter}" '^\b$' "${sed_filter}" "${grep_filter}"
|
|
fi
|
|
}
|