completions: improve list of available services and outdated checks

This commit is contained in:
Razvan Azamfirei 2024-01-27 18:42:22 -05:00
parent eb9ac8d3e5
commit 493028f667
No known key found for this signature in database
6 changed files with 18 additions and 24 deletions

View File

@ -81,14 +81,14 @@ __brew_complete_installed_casks() {
__brew_complete_outdated_formulae() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local outdated_formulae
outdated_formulae="$(brew outdated --formula --quiet)"
outdated_formulae="$(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --quiet)"
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_formulae}" -- "${cur}")
}
__brew_complete_outdated_casks() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local outdated_casks
outdated_casks="$(brew outdated --cask --quiet 2>/dev/null)"
outdated_casks="$(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --quiet 2>/dev/null)"
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_casks}" -- "${cur}")
}

View File

@ -108,7 +108,7 @@ end
function __fish_brew_suggest_formulae_outdated -d "List of outdated formulae with the information about potential upgrade"
brew outdated --formula --verbose \
HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --verbose 2>/dev/null \
# replace first space with tab to make the following a description in the completions list:
| string replace -r '\s' '\t'
end
@ -134,7 +134,7 @@ function __fish_brew_suggest_casks_installed -d "Lists installed casks"
end
function __fish_brew_suggest_casks_outdated -d "Lists outdated casks with the information about potential upgrade"
brew outdated --cask --verbose 2>/dev/null \
HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --verbose 2>/dev/null \
# replace first space with tab to make the following a description in the completions list:
| string replace -r '\s' '\t'
end
@ -157,13 +157,10 @@ function __fish_brew_suggest_diagnostic_checks -d "List available diagnostic che
brew doctor --list-checks
end
# TODO: any better way to list available services?
function __fish_brew_suggest_services -d "Lists available services"
set -l list (brew services list)
set -e list[1] # Header
for line in $list
echo (string split ' ' $line)[1]
end
command find (brew --cellar) -mindepth 3 -maxdepth 3 -name '*.service' \
| awk -F'homebrew.|.service' '{print $3}' \
| sort -d
end

View File

@ -74,7 +74,7 @@ __brew_outdated_formulae() {
[[ -prefix '-' ]] && return 0
local -a formulae
formulae=($(brew outdated --formula))
formulae=($(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula))
_describe -t formulae 'outdated formulae' formulae
}
@ -106,7 +106,7 @@ __brew_outdated_casks() {
[[ -prefix '-' ]] && return 0
local -a casks
casks=($(brew outdated --cask 2>/dev/null))
casks=($(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask 2>/dev/null))
_describe -t casks 'outdated casks' casks
}

View File

@ -68,14 +68,14 @@ __brew_complete_installed_casks() {
__brew_complete_outdated_formulae() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local outdated_formulae
outdated_formulae="$(brew outdated --formula --quiet)"
outdated_formulae="$(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --quiet)"
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_formulae}" -- "${cur}")
}
__brew_complete_outdated_casks() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local outdated_casks
outdated_casks="$(brew outdated --cask --quiet 2>/dev/null)"
outdated_casks="$(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --quiet 2>/dev/null)"
while read -r line; do COMPREPLY+=("${line}"); done < <(compgen -W "${outdated_casks}" -- "${cur}")
}

View File

@ -95,7 +95,7 @@ end
function __fish_brew_suggest_formulae_outdated -d "List of outdated formulae with the information about potential upgrade"
brew outdated --formula --verbose \
HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --verbose 2>/dev/null \
# replace first space with tab to make the following a description in the completions list:
| string replace -r '\s' '\t'
end
@ -121,7 +121,7 @@ function __fish_brew_suggest_casks_installed -d "Lists installed casks"
end
function __fish_brew_suggest_casks_outdated -d "Lists outdated casks with the information about potential upgrade"
brew outdated --cask --verbose 2>/dev/null \
HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --verbose 2>/dev/null \
# replace first space with tab to make the following a description in the completions list:
| string replace -r '\s' '\t'
end
@ -144,13 +144,10 @@ function __fish_brew_suggest_diagnostic_checks -d "List available diagnostic che
brew doctor --list-checks
end
# TODO: any better way to list available services?
function __fish_brew_suggest_services -d "Lists available services"
set -l list (brew services list)
set -e list[1] # Header
for line in $list
echo (string split ' ' $line)[1]
end
command find (brew --cellar) -mindepth 3 -maxdepth 3 -name '*.service' \
| awk -F'homebrew.|.service' '{print $3}' \
| sort -d
end

View File

@ -78,7 +78,7 @@ __brew_outdated_formulae() {
[[ -prefix '-' ]] && return 0
local -a formulae
formulae=($(brew outdated --formula))
formulae=($(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula))
_describe -t formulae 'outdated formulae' formulae
}
@ -110,7 +110,7 @@ __brew_outdated_casks() {
[[ -prefix '-' ]] && return 0
local -a casks
casks=($(brew outdated --cask 2>/dev/null))
casks=($(HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask 2>/dev/null))
_describe -t casks 'outdated casks' casks
}