From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19778 invoked from network); 17 Dec 2002 03:21:43 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 17 Dec 2002 03:21:43 -0000 Received: (qmail 23263 invoked by alias); 17 Dec 2002 03:21:33 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5587 Received: (qmail 23255 invoked from network); 17 Dec 2002 03:21:32 -0000 From: "Bart Schaefer" Message-Id: <1021217032103.ZM1783@candle.brasslantern.com> Date: Tue, 17 Dec 2002 03:21:03 +0000 In-Reply-To: <20021217022008.GA10031@foozle.attbi.com> Comments: In reply to "Jeremy M. Dolan" "Add ^C'd commands to history?" (Dec 16, 8:20pm) References: <20021217022008.GA10031@foozle.attbi.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: Add ^C'd commands to history? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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