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

Re: Change interactive command into a comment



On 2019-11-14 15:40:13+0000, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
-------8<-----------------------

# add a command line to the shells history without executing it
commit-to-history () {
	print -rs ${(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.
> 
> Shouldn't it be «print -rs -- ${(z)BUFFER}»?

Yes, that's right, without `-r', escaped character will be evaluated.

Thanks.

-- 
Danh



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