stecman / symfony-console-completion

Automatic tab-key completion for Symfony console application options, arguments and parameters
MIT License
420 stars 26 forks source link

Completion is not triggered by shell #69

Closed PowerKiKi closed 7 years ago

PowerKiKi commented 7 years ago

I realize this may be slightly outside of the scope of this project, but I can't get my shell to trigger completion with this lib. And I would really appreciate it if you could point me in the right direction to debug the situation.

So I added this project as dep to mine and registered the command in my app. I can manually test completion with success:

$ CMDLINE_CONTENTS=hel CMDLINE_CURSOR_INDEX=1  eco _completion </dev/null
help

Then I added eval $(eco _completion --generate-hook) to my ~/.bashrc. When I open a new shell, I can also manually test that the function does exists and can be called (even though it does not return anything):

$ _eco_6e1fc6a2b8621a1c_complete
$ echo $?
0

But when I try to actually complete my commands, I get nothing (or the standard file completion) instead of my commands:

eco h TAB TAB

As far as I can tell the generated hook seems to be correct (absolute path to my app are OK). Would you have any idea where this might come from ?

$ bash --version
GNU bash, version 4.3.46(1)-release (x86_64-pc-linux-gnu)

(Ubuntu 16.04.1 LTS)

aik099 commented 7 years ago

A. What version of the library are you using:

  1. latest released one: 0.7.0
  2. the master branch

?

B. Does it help if you add -m option to the hook generation command?

PowerKiKi commented 7 years ago

Using 0.7.0. Adding -m does solve my issue, thanks a lot !

Now that I know about it, I should have mentioned that my app is in the PATH and so I use from anywhere without prefixing it with absolute path. Reverting the hook without -m and using absolute path to call the app does actually work too.

Is there any reason why I would not use the -m option ?

aik099 commented 7 years ago

Using 0.7.0. Adding -m does solve my issue, thanks a lot !

This is known issue, that auto-complete only works, when you invoke app (to be autocompleted) using absolute path. When app is in PATH, then you only type binary name (e.g. eco) and not absolute path (e.g. /path/to/eco) and that's why auto-complete isn't triggered.

The #68 PR is created, that should fix it, but it's not yet merged.