2

On Bash I was using ESC # after Ctrl+R to prefix a # to the found line and keep it in the terminal, something similar for zsh?

2
  • Depending on your use-case you might be interested in the zle widgets push-line and push-line-or-edit. This pushes the current command to the stack and clears the buffer. The next time the line editor starts up (e.g. the next prompt) the command is popped off the stack and put into the buffer. This is quite useful to put a longer command on hold if you need to do something before you can actually run it. Commented Oct 30, 2014 at 10:08
  • @Adaephon thank you, nice feature I didn't know about, it doesn't cover always this particular case (sometime I just use a history entry as a visual reference) but I'll give a try on the field, can't wait for the next long command :) Commented Oct 30, 2014 at 13:35

1 Answer 1

7

See man zshzle for the pound-insert and vi-pound-insert widgets. The first will toggle a pound sign at the beginning of the buffer, the second at the beginning of the current line. Only pound-insert is bound by default, and then only in the vicmd key map, to #. To bind pound-insert, add this line to your .zshrc:

bindkey '\e#' pound-insert 
1
  • 1
    Thank you that was easy once pointed in the right direction bindkey '^[#' pound-insert :-) Commented Oct 28, 2014 at 22:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.