Open d-e-s-o opened 4 years ago
We are always open to PRs. I am not exactly good at the completion scripts. I couldn't even get zsh running locally 😞
My bash completion days are also behind me (and I happily flushed 90% I knew from memory). That being said, this patch seems to be doing the trick:
--- src/completions/bash.rs
+++ src/completions/bash.rs
@@ -33,8 +33,8 @@ impl<'a, 'b> BashGen<'a, 'b> {
for i in ${{COMP_WORDS[@]}}
do
case "${{i}}" in
- {name})
- cmd="{name}"
+ "${{1}}")
+ cmd="${{1}}"
;;
{subcmds}
*)
@@ -43,7 +43,7 @@ impl<'a, 'b> BashGen<'a, 'b> {
done
case "${{cmd}}" in
- {name})
+ "${{1}}")
opts="{name_opts}"
if [[ ${{cur}} == -* || ${{COMP_CWORD}} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${{opts}}" -- "${{cur}}") )
I'll probably open a PR unless I find an issue...
I believe this is fixed.
I believe this is fixed.
Mind sharing details as to why you believe that to be the case?
@pickfire How is this fixed?
Because there was a pull request for it? Ah, I didn't notice it was closed instead of merged.
And it was closed without merging because it didn't actually fix the issue.
It would be great if the shell completion was more flexible in what commands it applies to. Let's say I have a program
foo
and a completion scriptfoo.bash
as generated byclap
. If I sourcefoo.bash
I now have completion forfoo
's arguments. Fine.However, what if I have aliased
f
tofoo
? Naturally, I'd want to have completion forf
as well. Usually that's not a problem. The completion script just registers the completion functionality for a certain command. E.g.,can be found in
foo.bash
.Unfortunately, though, just changing that to
doesn't work, because, well, the script itself has the command/name coded into its logic.
That doesn't have to be the case, however, as
git
for example shows. Here all I have to do is register my alias as follows:and bam,
g
has completion.Would be great to have such a more flexible completion script.