Thursday, February 14, 2008

Save your command for later execution

Sometimes, you change your mind when you are in the middle of typing in a command at the command prompt. You don't want to execute the command until a later time, but you don't want to retype the line again. What to do?

You can hit Control-C to abandon the command. The problem with Control-C is that what you have entered already is lost: the line won't go to your command history.

A neat trick is to comment the line out. First, hit Control-A to go to the start of the line, and then enter # (the "pound sign"). This essentially makes the entire line a comment line. The line will not be executed, but it does go to the command history.

When you are ready to execute the command, just go back in the command history (via manual scrolling or search), remove the #, and execute the command.


Anonymous said...

hehe cool, never thought about it :)

Anonymous said...

You can use ctrl+k or ctrl+e to copy and ctrl+y to paste