-
Notifications
You must be signed in to change notification settings - Fork 380
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
adding an alias completion helper #521
Comments
I can have a look if someone submits one, however if it doesn't come with a promise to help maintain it (well to take ownership to be fair), it needs to be one that doesn't make my head hurt (and come with a bunch of test cases). I'm afraid the ones quickly visible from the links all do inflict that ache. Failing that, I could add a FAQ entry for this and point towards https://github.com/cykerway/complete-alias, that one seems a cleanly installable thing that works for all cases if it works as advertised. But I'd need to take a closer look at it before doing so. |
Should I ask the maintainer of complete-alias whether he'd consider to merge it into bash-completion? |
If the test cases and offer for long term maintainership within bash-completion are in order, sure. |
I think a FAQ entry is good for now, and take your time to review |
Ref: PR #104 |
Nice... how does it come that this seems so much smaller in terms of of code than cykerway/complete-alias? |
#104 is the version 7 years before. I just today realized that No one has yet started to work on the migration of the latest version of complete-alias to bash-completion, but if it would finally be merged, it should replace #104 (or we might work on it by adding commits in #104, but I haven't checked in detail how much the latest version has been changed since #104). |
I found that bash has a One workaround I have been using is to simply expand the alias manually before attempting to trigger completion. By default bash binds the key chord Alt-Control-e to the command |
I remember there were similar discussions about |
Is there a proper way to have completions for some command (e.g. I'd basically like to use:
but I can of course add another:
to trigger the loading unconditionally, but then I always have the functions from the dynamic completions for I also tried making Thanks, |
@calestyo Here is the command I use: sed -E 's/^(\s*complete -F _systemctl )systemctl$/\1sc/' /usr/share/bash-completion/completions/systemctl >~/.local/share/bash-completion/completions/sc For other commands, you just need to substitute the command name, the completion function name and the aliases, then execute it. |
@beavailable Thanks, that works :-) but has IMO two downsides:
I played a bit and came up with the following for
That should do the following:
The only thing I don't know right now is whether one should call |
Use if complete -p systemctl 2>/dev/null || _comp_load systemctl; then
complete -F _systemctl sc
fi |
Thanks... :-) And nice that this doesn't even define the completion for |
@calestyo You're right, I haven't thought that much, because it just works. |
Hey there.
A recurring question seems to be how to automatically get completions for aliases. Numerous code snippets and helper functions can be found, e.g. here:
It seems that getting it right and especially covering all cases, like support for git or to get aliases completed that already contained arguments, is trickier than a one liner.
I think it would be nice if bash-completion could provide a proper helper for this, i.e. one that covers all cases and solves it reasonably cleanly.
Shipping this with bash-completion would have the great benefit, that sooner or later most distros would get it out-of-the box, while a separate small project has often only little chances to really find its way into all distros.
Cheers,
Chris.
The text was updated successfully, but these errors were encountered: