Open jubr opened 7 months ago
Looks like for detection if it has been run in the current shell could be by inspecting BASH_COMPLETION_VERSINFO
. Assuming there's similar vars for zsh
, fish
, etc.
Looks like for detection if it has been run in the current shell could be by inspecting
BASH_COMPLETION_VERSINFO
. Assuming there's similar vars forzsh
,fish
, etc.
@jubr Can you investigate this more? If we can automatically detect if this message is redundant I agree it may make sense to remove these messages.
HOMEBREW_CAVEAT_COMPLETIONS
with future values likesuppress
,show
,suppress-when-detected-in-shell
.
Going from "no configuration" to "four different settings" feels excessive. Let's focus on the problem to be solved for now and we can figure out what's best based on what's e.g. possible from the shell.
Looks like for detection if it has been run in the current shell could be by inspecting
BASH_COMPLETION_VERSINFO
I don't think that is available in bash-completion
(v1) for system bash
users. This has more installs than bash-completion@2
in last 90 days and last 365 days.
Some tricky parts for shell detection:
brew
is a bash script. Not sure if possible to see corresponding zsh
(e.g. fpath
/FPATH
/_comps
) and fish
(e.g. fish_complete_path
) variables.brew
sanitizes the environment. By the time caveats are printed, the BASH_*
variables have been removed from environment.From quick glance, a suppress-when-detected-in-shell
feature wouldn't be possible other than maybe brew fish
(since we don't need variables there other than particular shell).
If so, the options would then be a full opt out flag or maybe some sort of show-once-per-formula if we could store info in tab.
Another potential option here: given it looks like detection is not really possible maybe these could just be output a single time regardless of how many formulae are installed/upgraded at the end of all installations?
I just stumbled upon this issue and would like to express my opinion: as a Homebrew user, I really like when I brew install something
and see "zsh completion has been installed". I just really like shell completions. I think it's a good default to print information about installing completion files.
I agree with #2110 that "Caveats" is not maybe the best place for it, though.
Provide a detailed description of the proposed feature
In followup of https://github.com/Homebrew/brew/issues/2110, I'd like to suggest to make the Caveat output less chatty in regard to the shell completions output. Initially this could be opt-in behind an env var in the direction of
HOMEBREW_CAVEAT_COMPLETIONS
with future values likesuppress
,show
,suppress-when-detected-in-shell
.These could be implemented incrementally, with immediate value for advanced users aware of this env var in
suppress
.The next iteration could then add a heuristic to detect if
/opt/homebrew/etc/profile.d/*_completion.sh
has been run, which would provide the needed input forsuppress-when-detected-in-shell
. Checking it has been run would be a better heuristic than looking in~/.*rc
or~/.*profile
, since you never know how people might source their shell configs.What is the motivation for the feature?
I'm noticing that during a large
brew upgrade
that all the potentially important Caveats are being drowned out by these:And since I already have the completions enabled for my shell via Shell-Completion I'd like to have an option to suppress them. Or perhaps even have them suppressed automatically, based on detection.
How will the feature be relevant to at least 90% of Homebrew users?
People have a smaller wall of text to parse after a
brew upgrade
, so basically make our lives a litte more efficient.Reaching ~90% would only be possible if
HOMEBREW_CAVEAT_COMPLETIONS=suppress-when-detected-in-shell
would be out-of-the-box, with opt-out available for distro's and people in the form ofHOMEBREW_CAVEAT_COMPLETIONS=show
.What alternatives to the feature have been considered?
I've though about running
brew
s output throughgrep
withHOMEBREW_COLOR=true
, which I might invest time into if this request is shot down hard 😛.C'mon fellow stumblers, go for 👍 on my request if you think it makes sense. Jurgen out.
Yes, yes, yes
### Verification - [X] This issue's title and/or description do not reference a single formula e.g. `brew install wget`. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.