From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13911 invoked by alias); 24 Sep 2013 06:24:27 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17997 Received: (qmail 14912 invoked from network); 24 Sep 2013 06:24:20 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130923232442.ZM20511@torch.brasslantern.com> Date: Mon, 23 Sep 2013 23:24:42 -0700 In-reply-to: <20130923220002.GB49013@redoubt.spodhuis.org> Comments: In reply to Phil Pennock "Re: Colored-character displayed on CTRL-C ?" (Sep 23, 3:00pm) References: <130923130204.ZM20058@torch.brasslantern.com> <20130923220002.GB49013@redoubt.spodhuis.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-users@zsh.org" Subject: Re: Colored-character displayed on CTRL-C ? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 23, 3:00pm, Phil Pennock wrote: } Subject: 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 Hm, I wondered about that. You can change the zle line in handle-interrupt to read zle -I && zle .kill-buffer && zle .send-break and maybe get better behavior that way. } 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). I think send-break will help there, too, but in case not: } It seems that handling these requires the TRAPINT to return non-zero, } but doing so interacts with the widget above to double-prompt (badly). You can check for [[ $CONTEXT == vared ]] in the TRAPINT function and return nonzero when appropriate. (It'll normally be unset outside of ZLE.) } 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). "zle .send-break" sets the internal error flags so normally it's just like invoking "return 1" ... but you can use an "always" block to get around that.