Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to cancel a completion once it has been started? I sometimes foolishly press tab to autocomplete make targets (only from sheer indolence) and then end up having to wait for a longer time than if I had just typed the whole of "install" or "check" out myself.

I didn't see anything of note in the zshzle man page, but maybe I missed something? Do any other shells have this capability?

EDIT: Trivial answer. So instead: is there a way for zsh to estimate that tab completion would take a relatively long time to execute and instead ask whether the user would like this to be done?

share|improve this question
2  
ctrl-c doesn't work? –  arx May 26 '12 at 19:25
1  
Damn it, it does! That didn't occur to me for some reason. I guess I thought Ctrl-C would have done something more dramatic. Delete the question? (Or maybe you want some rep?) –  Zorawar May 26 '12 at 19:29
1  
I don't think there is a way to estimate the time it takes for a tab completion. You may cache results but that's probably it. –  Ulrich Dangel May 26 '12 at 22:31
1  
@zorawar, I am just trying to help, not get high score :] –  arx May 26 '12 at 23:26
1  
ctrl-c does not work for all zsh's completion mechanisms. If anyone knows of other ways to halt this. It would be great to have that answer here. –  xer0x Sep 30 '13 at 17:28

1 Answer 1

up vote 4 down vote accepted

A SIGINT interrupts the current completion operation and brings you back to the line editor. So press Ctrl+C. The effect might not be immediate: the interpreter only checks for signals at certain points during execution (they're frequent, though), and the signal might take a while if the zsh process is blocked in a system call (for example, if it's waiting for a filesystem to respond).

Unfortunately, if you press Ctrl+C at the wrong time and there is no completion in progress by the time the signal is delivered, your current command line will be canceled. This is difficult to fix without having two different interrupt keys, one for completion and one for the rest, and I'm not sure if zsh supports this.

It's not really feasible to warn you if a completion might take a long time. The speed of a completion function is often mainly driven by the speed at which some information can be read from the filesystem; whether this information is in cache or not, how much there is, and what kind of a filesystem it is (e.g. ramdisk, hard disk or NFS mount) has a lot of influence.

share|improve this answer
1  
Perhaps a configurable timeout for tab completion would be a sane default. –  antiduh Jun 14 '13 at 20:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.