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

Remove "*instal" aliases from bash completion #3052

Merged
merged 2 commits into from
Aug 14, 2017
Merged

Remove "*instal" aliases from bash completion #3052

merged 2 commits into from
Aug 14, 2017

Conversation

rhwood
Copy link
Contributor

@rhwood rhwood commented Aug 13, 2017

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew tests with your changes locally?

Remove all command aliases ending in "instal" (single letter L) from the bash completion. This has the practical effect of removing the aliases "instal" and "uninstal" from bash completion, allowing "install" and "uninstall" to be auto completed once the first three characters of each "ins" or "uni" are typed in.

This makes bash completion for "uninstall" complete with a following space on the first tab instead of offering two different versions of the same command.

Addresses #3051

Remove all command aliases ending in "instal" (single letter L) from the bash completion. This has the practical effect of removing the aliases "instal" and "uninstal" from bash completion, allowing "install" and "uninstall" to be auto completed once the first three characters of each "ins" or "uni" are typed in.
@@ -563,10 +563,10 @@ _brew() {

if [[ "$i" -eq "$COMP_CWORD" ]]
then
# Do not auto-complete "instal" abbreviation for "install" command.
# Do not auto-complete "*instal" abbreviations for "*install" commands.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Do not auto-complete "instal" or "uninstal" abbreviations for "*install" commands. I think is a little easier to parse.

# Prefix newline to prevent not checking the first command.
local cmds=$'\n'"$(brew commands --quiet --include-aliases)"
__brewcomp "${cmds/$'\n'instal$'\n'/$'\n'}"
local cmds=$'\n'"$(brew commands --quiet --include-aliases | grep -v instal$)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way we can do this without spawning a new grep process? No worries if not, just wanted to check.

Copy link
Contributor Author

@rhwood rhwood Aug 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only way I could get it to work without calling grep was:

local cmds=$'\n'"$(brew commands --quiet --include-aliases)"
cmds="${cmds/$'\n'uninstal$'\n'/$'\n'}"
__brewcomp "${cmds/$'\n'instal$'\n'/$'\n'}"

I could not figure out a regex pattern that would work to capture both instal and uninstal in a single line, and went for the one liner (which I also find more readable).

@MikeMcQuaid
Copy link
Member

@rhwood Thanks for the PR! FYI for future if you're happy to open a PR for an issue you don't need to create an issue first.

@MikeMcQuaid MikeMcQuaid merged commit 9e8da17 into Homebrew:master Aug 14, 2017
@MikeMcQuaid
Copy link
Member

Thanks for your contribution to Homebrew, @rhwood! Without people like you submitting PRs we couldn't run this project. You rock!

@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants