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

Re: Append cancelled commands to history



On Thu, Sep 18, 2008 at 11:50:42PM +0200, thomasg wrote:
> Hello list,
>
> I was curious if it's possible to append canceled (CTRL+C) commands to the
> histfile.
> In case there is not yet a function to do this, is it generally possible to
> bind CTRL+C to a custom function?
>
> Greetings,
>
> thomasg

Hi,

I'm using the following function which works fine for me, not sure though if
it's the best solution:

    TRAPINT() {
        # Store the current buffer in the history.
        zle && print -s $BUFFER

        # Return the default exit code so zsh aborts the current command.
        return $1
    }

Hope this helps,
Simon
-- 
+ privacy is necessary
+ using http://gnupg.org
+ public key id: 0x6115F804EFB33229

Attachment: pgpxhSiOBmDP5.pgp
Description: PGP signature



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