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

Re: Change interactive command into a comment



Perry Smith wrote on Thu, Nov 14, 2019 at 07:19:01 -0600:
> 
> 
> > On Nov 13, 2019, at 10:41 PM, Danh Doan <congdanhqx@xxxxxxxxx> wrote:
> > 
> > On 2019-11-13 12:34:35 -0600, Perry Smith wrote:
> >> With bash, I got into the following habit.  If I started typing
> >> a long command and then decided I didn’t want to execute it right
> >> now for some reason, I would hit control-A to get back to the start
> >> of the line and then add a # in front and hit return.
> >> 
> >> This would put the command into history and so later I could recall
> >> it, remove the #, and execute the command.
> > 
> > Not an answer for your question, but this piece of code from grml zsh
> > config may interest you:
> > 
> > -------8<-----------------------
> > 
> > # add a command line to the shells history without executing it
> > commit-to-history () {
> > 	print -s ${(z)BUFFER}
> > 	zle send-break
> > }
> > zle -N commit-to-history
> > bindkey -M viins "^x^h" commit-to-history
> > bindkey -M emacs "^x^h" commit-to-history
> > 
> > -------8<------------------------
> > 
> > With this piece of code in your zshrc, you could press C-x C-h to
> > commit your current command to history without executing it.
> 
> Cool!  Thanks.

Shouldn't it be «print -rs -- ${(z)BUFFER}»?



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