4 ms·
The one shortcut I use the most, in addition to the listed ones, is "Ctrl-e Ctrl-e" which opens an editor then sends the resulting content to the shell. Using
by stevekemp 5y ago
The one shortcut I use the most, in addition to the listed ones, is "Ctrl-e Ctrl-e" which opens an editor then sends the resulting content to the shell.
Using an editor is great for loops, loops with nested conditions, etc.
- nine_k 5y agoHmm, does not work for me; Ctrl+X Ctrl+E does, as expected. (Be sure to set VISUAL to something nice.)
- stevekemp 5y agoSorry yes I made a mistake, and too late to edit!
- MaxBarraclough 5y agoHere's a (rather less sophisticated) personal favourite of mine: alt + # causes a # symbol to be prepended to the line, and then runs it. Useful for entering a nearly-finished line into your command history for later, commented out, if you realise you need to fix up something else beforehand. Slightly faster than ctrl-a followed by # followed by return.
- masklinn 5y agoI usually use C-q for that: it stores the current line in a buffer which it restores after the next execution.
- MaxBarraclough 5y agoOn my machine, ctrl-q appears to do nothing. (Aside: I've never seen the sense in using C to denote ctrl. How do you denote C?)
- masklinn 5y ago> On my machine, ctrl-q appears to do nothing. Ah apparently it's a ZSH-specific shortcut for "push-line". readline follows Emacs' (not illogical but probably less useful here) "quoted-insert" (generally used to include non-literal code e.g. C-q a does nothing as "a" is already literal, but C-q C-q should insert 0x 11 / XON / DC1). > (Aside: I've never seen the sense in using C to denote ctrl. How do you denote C?) c. Or C for S-c (shift-c). a-b indicates a single keystroke, meaning a modified key, so the first character can only signify a modifier key[0]. Which "c" is not. The sequence "upper case C then lowercase c" is "C c", not "C-c". [0] well technically you could have keystrokes of non-modifiers as modern keyboards can handle concurrent keycodes, but historical systems don't so a keystroke is only a bunch of modifiers + a single key e.g. C-S-M-c is unambiguously Control-Shift-Meta-c
- theli0nheart 5y ago> Aside: I've never seen the sense in using C to denote ctrl. How do you denote C? To denote a capital c, use Shift-c or some variant thereof.
- jlokier 5y agoJust "C". Ctrl is "C-", prefixed to another key without a space, so it's unambiguous.
- cassepipe 5y agoOr, if you are using vim mode with set -o vi (works with zsh and bash) you can just type # in normal mode to comment that line, do other things then come back up in history with k and run that line with # too.