This afternoon I found out that I knew something I didn’t know I knew (say what?).
I was spending a lot of time opening and closing SSH sessions and some of those were connecting to an IP address that I couldn’t remember. To assist my memory, I was grep’ing my history and then copying and pasting what I needed. At some point in the course of doing that, I had this memory of a way to re-issue a particular command from the history:
me@mine [~] $ history | grep ssh 13 ssh rob@rob 297 ssh rob@rwilkerson 298 ssh rob@rwilkerson1 299 ssh rob@rwilkerson 301 ssh rob@rwilkerson-old 303 ssh email@example.com 432 ssh firstname.lastname@example.org 434 ssh email@example.com 465 history | grep ssh 466 ssh firstname.lastname@example.org 467 history | grep ssh 468 ssh email@example.com 501 history | grep ssh me@mine [~] $ !468 ssh firstname.lastname@example.org email@example.com's password:
The first command displays the entire history buffer and pipes it through a grep for the ssh command. The second executes the 468th command in the history buffer, in this case ssh firstname.lastname@example.org, without having to retype it or even paste it. Now that I remember that I know how to do this, I suspect it’ll play a larger role in my terminal operations.