On Tue, Feb 09, 2021 at 05:23:45PM -0500, Stefan Monnier wrote: > You can also try `C-v` instead of `C-q` to quote the next key (not sure > where this comes from, but it works in bash and zsh, IIUC), i.e. use > `C-v TAB` to insert a TAB character.
It's deeper than just shells. It's also in the "canonical" processing layer of the terminal driver. unicorn:~$ stty -a | grep lnext werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0; unicorn:~$ man stty | grep -A1 lnext * lnext CHAR CHAR will enter the next character quoted unicorn:~$ man termios | grep -A3 VLNEXT VLNEXT (not in POSIX; 026, SYN, Ctrl-V) Literal next (LNEXT). Quotes the next input character, depriving it of a possible special meaning. Recognized when IEXTEN is set, and then not passed as input. You can see its behavior, for example, by running "cat" with no arguments in a terminal. Type some stuff, then press Ctrl-V and Enter, and you should see ^M (a token representing a carriage return) in your typed input. Shells don't operate in canonical mode, but they emulate this feature because it's useful and expected.