Thursday, December 08, 2005

Command-line Comments

Shell comments start with #. Important for scripts, but useless on the command-line, right? Wrong.

Suppose you've typed most of a line, but you need to stop and check on something -- how some file or command is spelled, for example.

Just go to the beginning of the line (Home), type a #, and press Enter. What happens? Nothing. It's a comment.

But it goes into the history. When you've finished checking on whatever it was, recall the command, make any needed modifications, delete the #, and press Enter again. Voila!

If you're using vi-style editing, use Esc to switch to command mode, then type the command #. Bash will insert a # at the beginning of the line and give you a new prompt for the next command.

In otherwords,
emacs: Home # Enter
vi: Escape #

0 Comments:

Post a Comment

<< Home