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

Suppress "completion installed" text in Caveats #16897

Open
1 task done
jubr opened this issue Mar 15, 2024 · 5 comments
Open
1 task done

Suppress "completion installed" text in Caveats #16897

jubr opened this issue Mar 15, 2024 · 5 comments
Labels
features New features help wanted We want help addressing this

Comments

@jubr
Copy link

jubr commented Mar 15, 2024

Provide a detailed description of the proposed feature

In followup of #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 like suppress, 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 for suppress-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:

==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completion has been installed to:
  /usr/local/share/zsh/site-functions
==> Summary

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 of HOMEBREW_CAVEAT_COMPLETIONS=show.

What alternatives to the feature have been considered?

I've though about running brews output through grep with HOMEBREW_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

@jubr jubr added the features New features label Mar 15, 2024
@jubr
Copy link
Author

jubr commented Mar 15, 2024

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.

@MikeMcQuaid
Copy link
Member

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.

@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 like suppress, 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.

@cho-m
Copy link
Member

cho-m commented Mar 15, 2024

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:

  1. 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.
  2. 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.

@MikeMcQuaid
Copy link
Member

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?

@bartekpacia
Copy link
Contributor

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.

@MikeMcQuaid MikeMcQuaid added the help wanted We want help addressing this label Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
features New features help wanted We want help addressing this
Projects
None yet
Development

No branches or pull requests

4 participants