4 ms·
In ~20 years of professional programming, I have never explored much beyond these shortcuts, except for also using: * ctrl-left/ctrl-right to go back/forward
by wdfx 4y ago
In ~20 years of professional programming, I have never explored much beyond these shortcuts, except for also using:
* ctrl-left/ctrl-right to go back/forward word by word instead of char by char
* ^C to cancel the current line
- sillysaurusx 4y agoOh my gosh thank you. I once went back by a word and swore I hallucinated, then realized the shortcut probably exists but never bothered to look into it.
- fiddlerwoaroof 4y agoThe emacs shortcut works here too: Alt-b for back a word and Alt-f for forward a word (at least if your terminal maps alt correctly)
- chaosite 4y agoIf we're counting ^C, then I'd also add: * ^D - Send EOF, which exits most shell-like programs (if you're on an empty line, so try ^C^D) And the job control bindings: * ^Z - Suspend current foreground process and return to shell, use `fg` to resume it in foreground and `bg` to resume it in background (see also `disown`) * ^S - "Stop" current process, useful if it's printing a lot of stuff and you want to pause it for a bit, otherwise useless and usually done by mistake * ^Q - resume a stopped process, probably after you ^S'ed by mistake
- wdfx 4y agoFor enough, but yes these are not to do with readline but terminal behaviour
- klibertp 4y agoI hated ^S until I disabled it with `stty -ixon`. The thing is, this key is actually bound to a really useful command: the reverse of ^R, ie. search forward in history. It's very useful when you assemble a new command from a few separate ones. You just ^R to the first one you want, mark and copy the part you want with ^Space and Alt+w, then search forward to the next one with ^S. I do use fzf, and it's great, but not for this specific use case. Also, it's worth noting that you can give a prefix argument to many commands by pressing Alt+1-9 (possibly multiple times). For example, the sequence Alt+2 Alt+. pasted not the last, but second to last word from the previous command. Oh, and Alt+x also works! With completion under TAB! The terminal looks simple, and most people prefer GUIs for good reasons. Not to mention the actual complexity of interpreting escape sequence and emulating the teletype (TTY). By the same token, though, terminal is something that was developed and polished by hordes of programmers since the teletypes. It's amazing, and the result is quirky as hell, but also incredibly powerful.
- nicwolff 4y agoIt's mentioned in the linked page, but not really explored: instead of `^C` (aka `C-c`, `Control-c`, &c) use `M-#` (aka `Alt-#` or `option-shift-3`) which adds a `#` before whatever you've typed on the current line and hits `return`, putting the line you're cancelling in the history as a comment so you can go back and `C-a C-d return` to submit it.