When I am typing into bash and I press the "tab" key to auto complete, sometimes it takes a significant time. E.g., file IO to read directories takes >5 seconds, and thus I am hung waiting for IO to complete before I can continue typing. I get frustrated and Ctrl-C so that I can redo what I was typing.

Ctrl-C is unfortunate, since I must retype everything again. How can I tell bash to stop trying to fulfill my auto complete request.

$ /long/path/to/some/d     # once I've typed this, I press <TAB>. I now will be
                           # stuck waiting for perhaps 10 seconds. The only thing I
                           # know to do is Ctrl-C. When I press Ctrl-C, I am forced
                           # to retype the original command string.

I just found this here.

Use Ctrl+\. It will stop the completion and go back to your command line without loosing the current command.

| improve this answer | |
  • Unfortunately this didn't work for me on Ubuntu – josh Jan 18 '19 at 10:09

You can have similar problems without tab completion. This does not introduce a technical difference i.e. the same solutions apply.

One possibility is to start the search in the background and write the result to a FIFO. You can read from the FIFO with a timeout then (read -t 0.3 ...).

I guess I have seen a simpler solution than FIFOs here recently... but currently I don't remember that. read -t works with a pipeline, too, but the finishing of read does not kill the earlier parts of the pipeline and the pipeline returns only after all of its parts have finished.

| improve this answer | |
  • how is this relevant to the question…? – lensovet Nov 15 '16 at 7:45
  • @lensovet If there seems not to be way to solve the problem in the requested way (i.e. aborting the search) then a hint how to (at least partly) avoid the problem seems quite useful to me. – Hauke Laging Jan 2 '17 at 0:39

On Ubuntu 16.04 hitting q worked for me.

See this https://unix.stackexchange.com/a/341025/332159.

| improve this answer | |

Your Answer

