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!
It’s always a bit confusing to reason about which startup files
bash(1) is going to run in a given situation. It is documented, but the logic is not trivial.
So I made a chart (using PlantUML!). You’re welcome.
EDIT: There is also one for
The main takeaway from this exercise is:
zsh do slightly different things.
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).