In bash we can prepend a command with #
and insert the non-executed command into our history. Is there a way to achieve similar behavior through some shortcuts or keybinds?
Asked
Active
Viewed 142 times
0

Kahn
- 1,702
- 2
- 20
- 39
1 Answers
2
In vi
(set -o vi
) mode, you can hit ESC and then #; that will prepend the current command with #
and enter it -- harmlessly into the shell as a commented command and also into the command history.

Jeff Schaller
- 67,283
- 35
- 116
- 255
-
Thank you, this works for me. – Kahn Nov 06 '19 at 14:41
-
If anyone knows a shortcut for emacs mode, feel free to edit it in! – Jeff Schaller Nov 06 '19 at 14:42