thomasg | 18 Sep 23:49

Append cancelled commands to history

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
Simon Ruderich | 19 Sep 18:20

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

Gmane