I have a bash autocompletion function which consults a database to provide possible completions for the current command line in bash. It takes about 3 seconds to complete and during this time the user doesn't have any indication that he has triggered the autocompletion -- prompting him to press TAB
a few more times, leading to the autocompletion possibly being run several more times.
Is it possible to manipulate the command line in a way to show that there is something being done, as soon as autocompletion is initiated? For example, when I press TAB
twice after the command foo
, I would like the following to happen immediately:
$ foo
autocompleting...
and then after the possible completions are determined, to change to:
$ foo
bar baz jazz
Alternatively, if I type foo j
and press TAB
once, the following:
$ foo j
autocompleting...
should change to
$ foo jazz
without any extra text beneath it, as expected.
The next step would be to consider if it's possible to have a dynamic output while the autocompletion is running, for example, printing the characters \ | / -
in a single place, as if a line is rotating in place -- to visually indicate that something is happening. Would this be possible?