* Add ^C'd commands to history?
@ 2002-12-17 2:20 Jeremy M. Dolan
2002-12-17 2:29 ` Stephen Rueger
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jeremy M. Dolan @ 2002-12-17 2:20 UTC (permalink / raw)
To: zsh-users
Hi all.
I'd very much like zsh to add commands to history that I ^C instead of
entering.
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. That
leaves it still visible so I can use gpm or X to copy and paste it, if
they happen to be available. But I'd really prefer zsh to add entered
commands as well as canceled ones to history.
I didn't see any option in the man pages about this, so what do you
think? Logical thing to have added? Or is there a way?
Thanks.
(please cc on replies)
--
Jeremy M. Dolan <mailto:jmd@pobox.com> <http://jmd.us/>
PGP: 1024D/3C68A1BA 9470 210C A476 FFBB 6D11 0223 0D1C ABFC 3C68 A1BA
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add ^C'd commands to history?
2002-12-17 2:20 Add ^C'd commands to history? Jeremy M. Dolan
@ 2002-12-17 2:29 ` Stephen Rueger
2002-12-17 2:45 ` Paul Ackersviller
2002-12-17 3:21 ` Bart Schaefer
2 siblings, 0 replies; 7+ messages in thread
From: Stephen Rueger @ 2002-12-17 2:29 UTC (permalink / raw)
To: zsh-users
佮⁍潮Ⱐ䑥挠ㄶⰠ㈰〲琠〸㨲〺〸偍〶〰Ⱐ䩥牥浹⁍⸠䑯污渠睲潴攺ਾ⁈椠慬氮ਾ 㸠䤧搠癥特畣栠汩步⁺獨⁴漠慤搠捯浭慮摳⁴漠桩獴潲礠瑨慴⁉⁞䌠楮獴敡搠潦ਾ湴敲楮朮ਾ 㸠䵡湹⁴業敳⁉⁴祰攠潵琠愠汯湧潭浡湤Ⱐ浡祢攠楰瑡扬敳爠獯浥瑨楮本ਾ⁴桥渠牥慬楺攠䤠湥敤⁴漠摯․堠晩牳琬漠䤠桡癥⁴漠幃⁴桥潭浡湤⸠周慴ਾ敡癥猠楴瑩汬⁶楳楢汥漠䤠捡渠畳攠杰洠潲⁘⁴漠捯灹湤⁰慳瑥琬昊㸠瑨敹慰灥渠瑯攠慶慩污扬攮⁂畴⁉❤敡汬礠灲敦敲⁺獨⁴漠慤搠敮瑥牥搊㸠捯浭慮摳猠睥汬猠捡湣敬敤湥猠瑯楳瑯特⸊㸠ਾ⁉楤渧琠獥攠慮礠潰瑩潮渠瑨攠浡渠灡来猠慢潵琠瑨楳Ⱐ獯⁷桡琠摯⁹潵ਾ⁴桩湫㼠䱯杩捡氠瑨楮朠瑯慶攠慤摥搿⁏爠楳⁴桥牥⁷慹㼊牥獳⁞儠⡢潵湤⁴漠≰畳栭汩湥∠楮浡捳潤攩湳瑥慤映幃⸊੭晧Ⰺ瑥灨敮⁒ﱧ敲ਊⴭ 䑡祤牥慭楮本⁴桥礧牥慹摲敡浩湧Ⰺ瑨敹牥慭映瑨攠摡礠睨敮⁴桥⁷潲汤❳潮湡桡湧攮慹摲敡浩湧Ⱐ瑨敹❲攠摡祤牥慭楮本ੴ桥礧牥牥慭楮朠瑨敩爠汩晥猠慷慹⸠ⴠ䑩攠呯瑥渠䡯獥測•䑡祤牥慭楮朢ਊ
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add ^C'd commands to history?
2002-12-17 2:20 Add ^C'd commands to history? 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 3:21 ` Bart Schaefer
2 siblings, 1 reply; 7+ messages in thread
From: Paul Ackersviller @ 2002-12-17 2:45 UTC (permalink / raw)
To: Jeremy M. Dolan; +Cc: zsh-users
On Mon, Dec 16, 2002 at 08:20:08PM -0600, Jeremy M. Dolan wrote:
> I'd very much like zsh to add commands to history that I ^C instead of
> entering.
Instead of interrupting, you can run the command commented out simply
with the `#' command in vi mode. I'm not sure about emacs mode.
--
Paul Ackersviller
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add ^C'd commands to history?
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
0 siblings, 2 replies; 7+ messages in thread
From: Jeremy M. Dolan @ 2002-12-17 2:53 UTC (permalink / raw)
To: Paul Ackersviller; +Cc: zsh-users
On Mon, 16 Dec 2002 21:45:40 -0500, Paul Ackersviller wrote:
> Instead of interrupting, you can run the command commented out simply
> with the `#' command in vi mode. I'm not sure about emacs mode.
Yeah, and it occurs to me I could "^Aecho " to get it in history, then
wipe out this echo to run it, but I think my hands are too wired to ^C
for things along this line to work very well.
I'm surprised "# foo" tries to run a command called "#". That could be
a fun program name.
I think HIST_ADD_CANCELED would be useful to enough people to have it
added. (at least as useful as the 30 or so other history options)
--
Jeremy M. Dolan <mailto:jmd@pobox.com> <http://jmd.us/>
PGP: 1024D/3C68A1BA 9470 210C A476 FFBB 6D11 0223 0D1C ABFC 3C68 A1BA
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add ^C'd commands to history?
2002-12-17 2:53 ` Jeremy M. Dolan
@ 2002-12-17 2:56 ` Geoff Wing
2002-12-17 3:21 ` Stephen Rueger
1 sibling, 0 replies; 7+ messages in thread
From: Geoff Wing @ 2002-12-17 2:56 UTC (permalink / raw)
To: zsh-users
Jeremy M. Dolan <jmd@pobox.com> typed:
: I'm surprised "# foo" tries to run a command called "#". That could be
: a fun program name.
setopt INTERACTIVE_COMMENTS
Regards,
Geoff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add ^C'd commands to history?
2002-12-17 2:20 Add ^C'd commands to history? Jeremy M. Dolan
2002-12-17 2:29 ` Stephen Rueger
2002-12-17 2:45 ` Paul Ackersviller
@ 2002-12-17 3:21 ` Bart Schaefer
2 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2002-12-17 3:21 UTC (permalink / raw)
To: zsh-users
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add ^C'd commands to history?
2002-12-17 2:53 ` Jeremy M. Dolan
2002-12-17 2:56 ` Geoff Wing
@ 2002-12-17 3:21 ` Stephen Rueger
1 sibling, 0 replies; 7+ messages in thread
From: Stephen Rueger @ 2002-12-17 3:21 UTC (permalink / raw)
To: zsh-users
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=iso-10646-1, Size: 895 bytes --]
On Mon, Dec 16, 2002 at 08:53:36PM -0600, Jeremy M. Dolan wrote:
> Yeah, and it occurs to me I could "^Aecho " to get it in history, then
> wipe out this echo to run it, but I think my hands are too wired to ^C
> for things along this line to work very well.
You could also put a "echo " in front of it and a "> sometempfile" at
the end, run the other command you want to execute and then "source
sometempfile". And there are probably even more painful ways to do it...
> I think HIST_ADD_CANCELED would be useful to enough people to have it
> added. (at least as useful as the 30 or so other history options)
When I press ^C to cancel a command, i do it to really cancel and never
ever see it again. Why would i want it to add to the history? It gets
long enough without several dozens of wrong commands.
Just use the buffer stack that zle provides like anybody else.
mfg,
Stephen Rüger
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-12-17 3:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-17 2:20 Add ^C'd commands to history? 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
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).