zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Add ^C'd commands to history?
Date: Tue, 17 Dec 2002 03:21:03 +0000	[thread overview]
Message-ID: <1021217032103.ZM1783@candle.brasslantern.com> (raw)
In-Reply-To: <20021217022008.GA10031@foozle.attbi.com>

On Dec 16,  8:20pm, Jeremy M. Dolan wrote:
} 
} Many times I type out a long command, maybe iptables or something,
} then realize I need to do $X first, so I have to ^C the command.

As Stephen Rueger has already pointed out, this is exactly what push-line
is for.  (Actually I prefer push-line-or-edit for the case of multi-line
buffers.)

The difficulty with binding anything like this to ^C is that (normally)
the tty driver interprets ^C before zsh ever sees it, and sends an INT
signal.  Zsh doesn't know where the INT signal came from, and the ZLE
module can't presume to handle non-keyboard interrupts, so in order to
have the line editor do something on ^C you have to use the stty command
to disable the driver interpretation of that keystroke.  That can be a
problem if you also want to use it to send an actual interrupt.

So my recommendation is to get used to typing something else when you
want a line stored in the history, and use ^C for what it was meant for.

However, if you really want to hang yourself, here is the rope:

    function push-to-history {
	print -s "$BUFFER"
	zle send-break
    }
    zle -N push-to-history
    bindkey '^C' push-to-history
    export STTY='intr ^C'
    ttyctl -u
    stty intr ''
    ttyctl -f

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


      parent reply	other threads:[~2002-12-17  3:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-17  2:20 Jeremy M. Dolan
2002-12-17  2:29 ` Stephen Rueger
2002-12-17  2:45 ` Paul Ackersviller
2002-12-17  2:53   ` Jeremy M. Dolan
2002-12-17  2:56     ` Geoff Wing
2002-12-17  3:21     ` Stephen Rueger
2002-12-17  3:21 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1021217032103.ZM1783@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).