4

I try the following:

clear-cmdline() {
    zle && zle kill-buffer
    sched +3 clear-cmdline
}
sched +3 clear-cmdline

After I run this code, I enter a few letters at prompt, and wait. Nothing happens. Unless I continue typing, then the command line gets cleared. How to obtain desired effect of just clear of the command line?

Itzie
  • 139
  • 1
  • 1
  • 4
  • Hmm, per the docs "Commands are executed either immediately before a prompt, or while the shell's line editor is waiting for input." so in theory it should run while you're twiddling your thumbs... – thrig Sep 11 '16 at 15:07

1 Answers1

2

It does work. It's just that the prompt is not redrawn until the next time you type something. Add a zle -R to redraw the prompt:

clear-cmdline() {
  zle && zle kill-buffer && zle -R
  sched +3 clear-cmdline
}
sched +3 clear-cmdline
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501