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

Re: Fw: Zsh - push current command on history without executing it



---------- Forwarded message ----------
From: Chris Johnson <cjohnson@xxxxxxxxxx>
Date: 20 Dec 2007 19:26
Subject: Re: command-cancellation with #
To: Micah Elliott <mde@xxxxxxxxxxxxxxxx>, zsh-users@xxxxxxxxxx


Micah Elliott sent me the following 1.3K:

> On 2007-12-20 Mikael Magnusson wrote:
>
> > On 20/12/2007, Micah Elliott <mde@xxxxxxxxxxxxxxxx> wrote:
> > >     $ #ls foo
> > >     zsh: bad pattern: #ls
> > >
> > > Is there a way to make this work in zsh the way it does in bash?
> >
> > setopt interactivecomments
>
> Great, that works.  Thanks!
>
> Is there some way I could have discovered that?  I don't see it
> in zshall(1).  I do see that it (and a few others) are set now by
> running 'setopt', but it would be nice to know what all the
> available options are (which aren't in the manpage).

It's in my zshall, and more narrowly, in zshoptions.

For the functionality of "pausing" a command line, you can also bind the
push-line widget (check out the zshzle man page for key binding and
line-editing options) to temporarily interrupt a command so as to
execute another, and have the interrupted command return for editing
automatically.  I bind this to Alt-Q (or Escape-Q):

   bindkey "^[Q" push-line

And I have this custom widget to help me store a command line in history
without executing it:

   commit-to-history() {
      print -s ${(z)BUFFER}
      zle send-break
   }
   zle -N commit-to-history
   bindkey "^X^H" commit-to-history

So, I type a command, hit Ctrl-X Ctrl-H, and then retrieve my command
from history when I need it.

--
Chris Johnson
cjohnson@xxxxxxxxxx
http://www.cs.utk.edu/~cjohnson


On 04/01/2008, Peter Stephenson <pws@xxxxxxx> wrote:
> Forwarded from someone presumably not on the list.
>
>
> Begin forwarded message:
>
> Date: Mon, 24 Dec 2007 03:59:55 +0200
> From: Casper Gripenberg <casper.gripenberg@xxxxxxxxxxxxx>
> To: pws@xxxxxxx
> Subject: Zsh - push current command on history without executing it
>
>
>
> Hi..I was reading the zsh manual and trying to
> figure out how to push the current command line
> into the history list wihout actually executing
> the command.
>
> push-line does almost what I want, but it pops
> the command back into view after I issue the next
> command. What I'm looking for is something like
> push-history..  but I can't find it. Is there
> such a thing or any way to make zsh do something
> like that?
>
> Thanks.
>
> Casper
>


-- 
Mikael Magnusson



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