As idle musing, and a way to show off my mastery of shell pipelines, I was wondering what my most-used shell commands are. It’s an easy few commands to pipe.
history | sed 's/^ *//;s/ \+/ /g' | cut -d' ' -f 2 | sort | uniq -c | sort -n | tail -n 20
The outcome is rather expected. I feel validated (by my shell) in my own self-perception!
I finally mastered the shell (beit bash or zsh, but really, this is readline)’s history with command replacement. It took me 19 years and my entire family fortune to gather enough wits to read that part of the manual with enough attention and will as to learn to use it.
Essentially, you can recall previous commands from the history with
!number. You can then change some content of the previous command programmatically before running it by adding
:gs/PATTERN/REPLACEMENT/ (the first one will replace the first occurrence, the second one will replace them all).