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
Update fish completions #15174
Update fish completions #15174
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,28 +98,15 @@ end | |
###################### | ||
# These functions return lists of suggestions for arguments completion | ||
|
||
function __fish_brew_ruby_parse_json -a file parser -d 'Parses given JSON file with Ruby' | ||
# parser is any chain of methods to call on the parsed JSON | ||
ruby -e "require('json'); JSON.parse(File.read('$file'))$parser" | ||
end | ||
|
||
function __fish_brew_suggest_formulae_all -d 'Lists all available formulae with their descriptions' | ||
# store the brew cache path in a var (because calling (brew --cache) is slow) | ||
set -q __brew_cache_path | ||
or set -gx __brew_cache_path (brew --cache) | ||
|
||
if test -f "$__brew_cache_path/descriptions.json" | ||
__fish_brew_ruby_parse_json "$__brew_cache_path/descriptions.json" \ | ||
'.each{ |k, v| puts([k, v].reject(&:nil?).join("\t")) }' | ||
else | ||
brew formulae | ||
end | ||
brew formulae | ||
end | ||
|
||
function __fish_brew_suggest_formulae_installed | ||
brew list --formula | ||
command ls -1 (brew --cellar) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❯ hyperfine 'brew list --formula' 'command ls -1 (brew --cellar)' --shell fish
Benchmark 1: brew list --formula
Time (mean ± σ): 473.1 ms ± 26.9 ms [User: 248.4 ms, System: 107.8 ms]
Range (min … max): 443.6 ms … 542.5 ms 10 runs
Benchmark 2: command ls -1 (brew --cellar)
Time (mean ± σ): 10.0 ms ± 0.9 ms [User: 3.4 ms, System: 4.3 ms]
Range (min … max): 8.7 ms … 14.2 ms 112 runs
Summary
'command ls -1 (brew --cellar)' ran
47.16 ± 5.01 times faster than 'brew list --formula' There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @razvanazamfirei Is this a strategy that could be used in bash/zsh completions too? May want to split it out into a command like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll have to check if it leads to any performance improvements since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @razvanazamfirei Thanks! That could be a follow-up PR, doesn't need to block this one. |
||
end | ||
|
||
|
||
function __fish_brew_suggest_formulae_outdated -d "List of outdated formulae with the information about potential upgrade" | ||
brew outdated --formula --verbose \ | ||
razvanazamfirei marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# replace first space with tab to make the following a description in the completions list: | ||
|
@@ -143,7 +130,7 @@ function __fish_brew_suggest_casks_all -d "Lists locally available casks" | |
end | ||
|
||
function __fish_brew_suggest_casks_installed -d "Lists installed casks" | ||
brew list --cask -1 | ||
command ls -1 (brew --caskroom) | ||
razvanazamfirei marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal here: in a future PR this would be nice to make a command implemented in Bash I think if it provides speedups to either Bash and/or ZSH. |
||
end | ||
|
||
function __fish_brew_suggest_casks_outdated -d "Lists outdated casks with the information about potential upgrade" | ||
|
@@ -153,7 +140,9 @@ function __fish_brew_suggest_casks_outdated -d "Lists outdated casks with the in | |
end | ||
|
||
function __fish_brew_suggest_taps_installed -d "List all available taps" | ||
brew tap | ||
command find (brew --repo)/Library/Taps -mindepth 2 -maxdepth 2 -type d \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal here: in a future PR this would be nice to make a command implemented in Bash I think if it provides speedups to either Bash and/or ZSH. |
||
| string replace homebrew- "" \ | ||
| string replace (brew --repo)/Library/Taps/ "" | ||
end | ||
|
||
function __fish_brew_suggest_commands -d "Lists all commands names, including aliases" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The results are different after this change because we no longer get any description related info.
Before
After
Not sure how important the descriptions are for most people though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the descriptions came from
$__brew_cache_path/descriptions.json
. I don't have that file locally and haven't been able to figure out where it gets generated from.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh, that file isn't generated by default. IMO the new behaviour makes more sense and the performance benefits are worth it.