// HACKER NEWS — CYBERSECURITY
A shell exclamation mark is not for yelling. Be lazy.
Event designators have been hiding in not-so-plain-sight since the late 1970s — so powerful that forgetting might be part of a massive conspiracy to wear out developer keyboards faster than otherwise.
You and I are probably very different; my choice of editor is likely to
make you cringe just thinking about it, and your favorite programming language
is statistically — definitely — not mine.
There is however one thing (and maybe that's the only thing) we all have in
common; we are a bunch of lazy bastards.
Note: This article is primarily targeting bash, csh, tcsh, and
zsh. If these shells are not your daily driver, see POSIX and the power of fc
— worth a read no matter which POSIX-compatible shell you use.
I am sure we have all ended up in arrow-up-mashing hell when repeating commands
in our shell history, but what if we instead could save ourselves the trouble
and refer to previous commands and their arguments directly?
Note: The magic described in this article applies to interactive shells
unless configured otherwise, it is not meant to be used in your new
amazing.sh shell script.
I bet you've heard it before, "do not repeat yourself", either from that
annoying colleague with all the obscure magic (who might smell a little funny) —
or perhaps you said it yourself during the last refactor session that somehow
lasted longer than the federation delay on matrix.org.
Most of us have heard DRY repeated since we were ki–, I mean junior. But is it
not funny that we've religiously been taught to apply DRY everywhere… except on
the command‑line?
Even though they might look mighty daunting at first glance, event
designators always follow the same rather simple pattern:
Note: Want to know the bare necessities? Check out
yell responsibly for the essential designators I consider
most useful.