-
Notifications
You must be signed in to change notification settings - Fork 136
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
feat(completions): add completion for fish #344
Conversation
fish's builtin git completion automatically registers git-forgit completions as completions for forgit subcommand of git.
Hi @folliehiyuki! Thanks so much for the contribution(s) 🎉 Could you please:
I'm the main fish maintainer, so I want to be sure I understand the feature fully and do some QA before merging! |
I ran into the same issue with the CI previously, but the issue went away by itself before I could do anything to fix it. For some reason the fish PPA fails to install
I'm suspecting an issue with the fish PPA. This is not caused by the code changes, the CI fails before the actual checks. Just ran the test locally on my machine and they appear to be fine again. Could not test macos though, because act does not support this. |
Just use mkdir test-repo && cd test-repo
git init
touch file{1,2,3}
# See that the completion list includes all subcommands
git forgit <Tab>
git-forgit <Tab>
# Completion for `add`
git-forgit add <Tab><Tab>
git forgit add <Tab><Tab>
... All the |
@folliehiyuki this is great! Working as you intended. A couple questions:
Let me know what you think on point 1. Depending on that we can submit. |
On point 1, see https://fishshell.com/docs/current/completions.html#where-to-put-completions.
So, it's better to put the fish completion in a separated file. It works with just the On point 2, as said above, I don't use the fish plugin personally, so it's hard to judge. My recommendation would be to use abbr instead of aliases, so, on the command line, pressing |
Awesome. Makes sense to me. Thanks again for the contribution @folliehiyuki ! merging it now. If you feel you have energy to tune up the completions in the non-git-plugin version, another contribution would be greatly appreciated, otherwise I'll check it out when I have time. Cheers! |
Switch from aliases to abbreviations, as I suggested in feat(completions): add completion for fish #344 (comment) string collect returns 1 on empty argument, so it's used here to avoid repeating if else end blocks. Another benefit is that the output of string collect is ensured to be a single string. From string --help: string collect collects its input into a single output argument, without splitting the output when used in a command substitution. This is useful when trying to collect multiline output from another command into a variable. Exit status: 0 if any output argument is non-empty, or 1 otherwise. This PR is marked as breaking change, since abbr behaves differently from alias. It can only be used in the interactive command line (so putting exec glo into your scripts won't work).
fish's builtin git completion automatically registers
git-forgit
completions as completions forforgit
subcommand of git. Therefore this PR provides completions for both formatsgit-forgit
andgit forgit
.Simple subcommands get the completion list from
__fish_git_*
functions, while others requiring more than 1__fish_git_*
completion sources reuse the completion items from the corresponding git commands.Check list
Description
Type of change
Test environment