![]() That should work in anything based on GNU Readline.Īs for Zsh, which uses its own alternative named ZLE, it only honours the original Emacs C-q binding when in Vi mode, ironically enough, but C-v still works in the default Emacs-like input mode. This is how to insert key sequences like C-q, for example. Here's the description from the Readline manual:Īdd the next character typed to the line verbatim. It began as an Emacs function named quoted-insert and, since the default keybinds for Bash and Zsh mimic Emacs, they also copied it.īash gets it via the GNU Readline input library that other things like Python's import rlcompleter enhancement also use. You'll get a sequence like ^[Oa and you'll have to translate the ^[ into \e or \033 or \x1b or whatever other representation your keybinding system expects for the escape character. The easiest way I've found to check what escape sequence is generated by a key or key combo is to press Ctrl v in a terminal and then press the key/combo you want to know about. Key combinations like Ctrl-Up don't have corresponding entries in the terminfo database, so to find out what they send, either read the source or documentation for the corresponding terminal or try it out with the sed -n l method described above. You can look up what key corresponds to a given sequence with your current terminal with infocmp (here assuming ncurses infocmp): $ infocmp -L1 | grep -F '=\E[Z' Would tell you what escape sequence is send by rxvt upon pressing the Delete key. ![]() The terminfo database records a number of sequences for a number of common keys for a number of terminals (based on $TERM value).įor instance: TERM=rxvt tput kdch1 | sed -n l The $ is not to be included, it's only to show you where the end of the line is.Ībove that means that Ctrl-Up (which I've pressed) send the 6 characters ESC, [, 1,, 5 and A (0x1b 0x5b 0x31 0x3b 0x35 0x41) The first line is caused by the local terminal echo done by the terminal device (it may not be reliable as terminal device settings would affect it). Then you'll see something like: $ sed -n l The best way to find out what a key or key combination sends for your terminal, is run sed -n l and to type it followed by Enter on the keyboard. Most of the function and navigation keys generally send a sequence of characters that starts with the ^[ (control-[), also known as ESC or \e (0x1b, 033 octal), but the exact sequence varies from terminal to terminal. If you press or, then generally send the ^I character also known as TAB or \t (0x9). When you press the A key, generally terminals send the a (0圆1) character. Nothing to do with bash or readline per se, but you'll want to know what sequence of characters a given key or key combination sends if you want to configure readline to do something upon a given key press. Those are sequences of characters sent by your terminal when you press a given key.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |