4 ms·
And the next lesson: C-r will search the command history (at least in most *nix shells). So when needing to do something but you aren't sure how far back it was
by Jtsummers 5y ago
And the next lesson: C-r will search the command history (at least in most *nix shells). So when needing to do something but you aren't sure how far back it was (not on the screen or not recallable) but you know it is in the history and some text in it, just C-r <something> [C-r repeatedly until you get to the correct version].
- TaurenHunter 5y agoGreat tip! I've found more like that at: https://www.redhat.com/sysadmin/cli-speedup https://www.redhat.com/sysadmin/cli-speedup
- mindcrime 5y agoRelated trick: type the first couple of characters of the command in question, and hit PGUP until you find the correct version.
- nitrogen 5y agoThis one's my favorite. Not every distribution of readline enables this, so you might need to uncomment or add the binding for history-search-backward/forward into /etc/inputrc or ~/.inputrc. Similarly editrc for programs that use libedit instead of readline to avoid the GPL.
- cogman10 5y agoJust as useful, history | grep pattern With all the useful grep abilities (like peaking at commands before or after the given pattern).
- mrich 5y agoOn Windows, Ctrl+Backspace will delete the word left from the cursor, Ctrl+Delete the word to the right. It's pretty much unknown as far as I'm aware but it has boosted my editing productivity immensely. vi users will probably laugh at this.
- copperx 5y agoUnknown? You can't work inside Windows at all without those shortcuts. In Emacs it's alt+Backspace, so it's not too hard to organically find in other environments by trial and error. Whenever I switch editors, I quickly look for the following shortcuts: * How do you delete a word forwards and backwards? (there might be a better shortcut such as Ctrl+W) * How do you move to the word ahead and the word behind? * How do you kill a line? * How do you duplicate a line? * How do you move a line up and down? * How do you activate multiple cursors? * How do you comment/uncomment a line/block? * How do you expand/contract a selection? I think that covers about 80% of the common actions, and learning them will make you instantly productive in your new editor.
- Aeolun 5y agoI really only use one of those on a consistent basis.
- dumpsterdiver 5y agoOne of my favorites is option-arrow (left or right) to jump between words in the terminal.
- d0gsg0w00f 5y agoset -o vi
- dan-robertson 5y agoIf it’s readline-based like bash and you are still using default shortcuts then you can do M-b and M-f for backward/forward a word at a time (not sure what the Meta equivalent is on a Mac. On my keyboard it is the ‘Alt’ key.) Many Mac apps/text inputs support emacs-style shortcuts like these.
- blastro 5y agoi only recently learned this. been big
- sokoloff 5y ago:mindblown: I've been using *nix shells for 30 years and just learned and tried this now. Thank you!