In Bash, if you have typed a very long command (applicable to shorter commands too :-)), and then realize you don't want to execute it yet, don't delete it.
Then what ?
Ans :
Simply append a # to the beginning of the line (command), and then hit enter.
So bash is not going to execute this command (as its commented), but will store it in history. So later you can go back, remove the # from the front, and execute it.
e.g.
Lets see my history (output of history command)
Well, if you are wondering how I have added the "command execution timestamp" to the history command output, here is the tip
And if you want to know how I made my Primary bash prompt (PS1) a colorful one, here is another tip
3 comments:
I added this to my .inputrc.
"\C-o": insert-comment
so I can hit crtl-o so the # is added automatically. Also I don't have to hit enter.
Please don't forget that there is a shortcut for this: ESC # (it's doing ^A#^M).
@Rattus, thats a real great tip. I never knew that. Thanks.
Post a Comment