Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

completions: improve list of available services and outdated checks #16651

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Library/Homebrew/completions/bash.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}

Expand Down
13 changes: 5 additions & 8 deletions Library/Homebrew/completions/fish.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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


Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/completions/zsh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions completions/bash/brew
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}

Expand Down
13 changes: 5 additions & 8 deletions completions/fish/brew.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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


Expand Down
4 changes: 2 additions & 2 deletions completions/zsh/_brew
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

Expand Down
Loading