Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Colored-character displayed on CTRL-C ?



On 2013-09-23 at 13:02 -0700, Bart Schaefer wrote:
> This should do it for you:
> 
>     autoload -Uz colors
>     colors
>     handle-interrupt() {
>       print -n "$bg_bold[yellow]${(V)KEYS:-^C}$reset_color"
>       zle -I && zle .kill-buffer
>     }
>     zle -N handle-interrupt
>     TRAPINT() { zle && zle handle-interrupt }

This seems to interact poorly with vared, resulting in vared not being
left until enter is pressed, and the value of the variable being blanked
out as a result.  Also, in bck-i-search (^R) the prompt is re-shown,
and the mode is still in bck-i-search (although the current selected
value is blanked out, but typing continues the search).

It seems that handling these requires the TRAPINT to return non-zero,
but doing so interacts with the widget above to double-prompt (badly).

I like the widget (which is why I found these issues).  :)  Just can't
figure out how to fix these issues.

Ideally, I'd be able to set $? after this, so a manual invocation of
precmd would correct the prompt variables, since precmd() isn't invoked
normally, given that widget, whereas it is with a straight Ctrl-C
without TRAPINT (albeit with $? set to 1).

-Phil



Messages sorted by: Reverse Date, Date, Thread, Author