1

I am trying to code an autocomplete script. It should also outputs some description. I have one function that manage the autocompletation AND the fetching of the description. The autocompletion related part works fine but i have an issue when i want to display the help. In short, this is what i have now :

$> myFunction -myOption1<TAB>
Description for myOption1<CURSOR>

What i woud like :

$> myFunction -myOption1<TAB>
Description for myOption1 
$> myFunction -myOption1<CURSOR>

There is no conflict between the autocompletion and the output. The description can only be displayed when the myOption1 is complete. (myOpt will be completed as myOption1 and hence, does not display the description). I made severals attempts to make it work but i guess i am missing a step. The "Description for myOption1" is an 'echo'. I think it's related because compgen is waiting for some value (I give it none for the moment). I tried to trick compgen with some escape characters, spaces : no successes. The autocomplete script should continue to run after this description.

Thanks in advance for the help ;-)

Kol

Koller14
  • 11
  • 1

1 Answers1

0

What I would do:

  1. set COMPREPLY in every case (you don't want to mess with it). (move out of the else)
  2. before messing the screen, I would do a tput sc before the echo, and tput rc afterwards. Note, that will still screw up your screen if your terminal scrolls because of your echo
pihentagy
  • 5,975
  • 9
  • 39
  • 58