Smart shortcuts and articles I miss
About not forgetting and making life easier.
More often than not, I read an article that I think, this might be handy one day, discard it, only to find myself three weeks later thinking, what was that one article about shell tricks?
It's a reminder that I need to write down things more often. This article was about terminal shortcuts. Over a lifetime, these shortcuts can save you hours if not days. Here's a couple of my favorites.
(disclaimer: I'm on mac so I'm not sure this works on another OS)
CTRL + W: it deletes the last word (I usedALT + Backspacefor that in the past so this is faster), this also works while typing outside of the terminal.CTRL + U: cut out everything from the cursor to the beginning of the line, and then you can useCTRL + Yto paste it later.CTRL + A&CTRL + E: go to the start and end of the line.cd -: go to the previous directory.CTRL + R: reverse incremental search through previous used commands. PressCTRL + R, type a keyword to find commands from your history. PressCTRL + Ragain to cycle backwards through matches. I usedhistory | grep <keyword>for this in the past.sudo !!: you're typing a command but forgot to run sudo. Instead of having to run it again, runsudo !!and the same command will run with sudo.
A couple of others were more advanced that I might circle back to later.