It makes me wonder – what's that one command or concept you CLI vets wish you'd learned way earlier that totally changed your game, something that might be in that 'next 20%'? Curious about those 'aha!' moments!
bat # cat with syntax highlighting
zoxide # keeps track of directories
tig # ncurses git viewer
atuin # shell history across machines
choose # easier cut or "awk '{print $1}'"
direnv # set environment vars when you enter a directory
fd # better find
fzf # fuzzy find anything, total game changer
gh # GitHub client
rg # really fast recursive grep
One of my favorites from the book is to alias "xdg-open" to "open" because I never remember the command. So now I can just type "open X" to open a file system location or file in a normal GUI program when needed. It is a small thing but I use it a lot.
Something that I didn't put in the book because I learned it only recently is the use of "notify-send", aka you can send yourself a system notification from the command line or script (at least it workd for me in Gnome). For instance once a task is finished:
> echo "when finished send notification" && notify-send "system notification"
Pretty cool if you ask me!
In my Linux install (Debian 12/Bookworm) /usr/bin/open is a symlink to /usr/bin/xdg-open so I was always using xdg-open without even knowing it.
grep, sed, awk and regular expressions would probably be part of my 1st hour course if I were to produce one. And by awk I mean the super basic stuff like -F',' '{print $3" "$NF}' is already a long way
also any command | while read line; do something $line; done
and find and vi of course
These might seem basic but they made a huge difference when I learnt them:
set -o vi
set -o xtrace
xargs, xargs -I
parameter expansion (see the Parameter Expansion section in the bash manual)
ctrl + r
find -exec
lsof
Get really comfortable with find and grep. They’re incredibly powerful. perl -pe is way easier than awk.
I'll second that. And would like to add that find plus xargs is important to know, as it often works much better than the clumsy "exec in find itself.
Oh, and thus of course
find ... | xargs perl -lne "fancy stuff"
to do some fancy stuff with found files ;-) I really think you should use:
find ... -exec perl -lne "fancy stuff" {} +
because for one it doesn't mess with stdin, and for another you don't have to worry about filenames with spaces or newlines in them. I also like -execdir since if my script dumps any output to other files I'll probably want that output near the sources. And did I mention it does nothing if there are no matching files? I also think it looks better and is shorter.If you really can't remember that or want to continue to pollute the environment with extra heat generated by running two cpus to do the job one can do, you should at least use -print0/xargs -0 because of spaces, and always use -r to more sensibly handle an empty result-set from find et al (gnu xargs runs once!)