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

Re: Change interactive command into a comment




> 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.

Attachment: smime.p7s
Description: S/MIME cryptographic signature



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