10 ms·
My son was taking his first programming course, and was watching him working on an assignment. He was running the compiler and executing his program in the ter
by jimbokun 5y ago
My son was taking his first programming course, and was watching him working on an assignment. He was running the compiler and executing his program in the terminal.
I mentioned to him: "Did you know you can pull up your past commands by hitting up arrow?"
His mind was blown. I think that comment doubled his productivity.
- Jtsummers 5y agoAnd 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!
- zxexz 5y agoFor bash users who are used to vi-style keybindings, you can enable vi mode[0]. When I discovered this, my "performance" must've more than doubled :) [0] https://blog.sanctum.geek.nz/vi-mode-in-bash/ https://blog.sanctum.geek.nz/vi-mode-in-bash/
- brightlancer 5y agoMy command line time is easily halved by using vi mode in Bash. (And so many coding tools are inefficient to me because I cannot use vi keybindings.)
- jcul 5y agoYes it's amazing. And for long complex commands, being able to just press v to drop into a proper vim to edit the command is very useful.
- mym1990 5y agoI am working with a junior developer who will use the mouse to click on text, click copy, click the new area, and click paste. I don't have the courage to tell him that he can Control/Cmd-C and Control/Cmd-V
- slivanes 5y agoJust let him know.
- gibolt 5y agoAnd you may have to show him during pair programming. Telling someone 10 improvements rarely changes their workflow. Letting them see/discover the change will drive them to try
- drran 5y agoIn Linux, just select and middle-click.
- dkarl 5y agoThis blew my mind when I first saw somebody do it. I was a bright-eyed young engineer in shorts visiting a customer site, and he had a PhD, dress slacks, a white button-down shirt, and a tie. I assumed had a jacket to match the slacks hanging in his office. I said, "Whoa, what terminal emulator is that? I need to check it out." It was xterm.
- deleted 5y ago[deleted]
- tomjakubowski 5y agoNext lesson: bang commands!! https://www.redhat.com/sysadmin/bash-bang-commands https://www.redhat.com/sysadmin/bash-bang-commands
- antiquark 5y agoWait until you hear about "cd -"
- hikarudo 5y agoI've recently switched from bash to zsh. Checkout the dirhistory plugin, which allows you to use Alt-left to go to change to the previous directory, Alt-up to change to the parent directory, etc. https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/dirhistory/README.md https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/dirhi...