4 ms·
Here'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
by MaxBarraclough 5y ago
Here'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.