If you're a csh/tcsh/zsh user, you've seen the supposed feature
that lets you display how many commands you've run in your
prompt:
set prompt="\! %"
The \! (or %h or %! for tcsh) displays not really a current
count of commands run, but the current history event number.
Think of it in those terms, and you'll discover it becomes quite
useful.
For example, how many times have you typed some enormously long
command line, only to have it fail because several other conditions
weren't met?
You spend the next several prompts typing various commands to
get conditions set up just right, and then have to retype the
entire long command.
Or, if it hasn't scrolled off the screen yet, just type ! followed
by the history event number displayed in the prompt for that big
long command. It's that simple:
prompt 23 % command -with some -very +long /argument/list
command: Example command failed.
prompt 24 % cd /to/correct/directory
prompt 25 % rm certain.files
prompt 26 % !23
command -with some -very +long /argument/list
command: Example command succeeds.
prompt 27 %
You can even apply the standard csh modifiers to !. For
example, particularly useful is !:p, which just prints
the command typed on prompt instead of executing it
again:
prompt 26 % !23:p
command -with some -very +long /argument/list
prompt 27 % !!
command -with some -very +long /argument/list
command: Example command succeeds.
prompt 28 % NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted
by various unix admins around the globe. UGU suggest you read and
test each tip in a non-volitile environment before placing into
production.