I am trying to understand how terminal works by doing different tricks, like writing from one tty to another, changing settings tty1 from tty2, etc. Also, I am trying to change a color by sending escape sequence from keyboard, directly. That is, not by echo -e '\e[0;31m' command, but by direct keyboard input. It doesn’t work.
I do this steps:
- Open
tty1andtty2 - In the
tty2putbashinto the sleep mode, bysleep 10m. Type word 'one'.
- Go to
tty1, doecho -n ^[[0;31m > /dev/tty2. The first character^[is typed by this way Ctrl + v Esc - Return to
tty2, type word 'two'. Yes - the color has been changed to red by command from another tty.
- Repeat steps 3,4, but with green color and word 'three'
- And finally, I am trying to send the escape sequence not by another
tty, but from keyboard directly - by typing^[[0;37mintty2. I do everything the same way - Esc (Ctrl + v doesn't needed, because readline is sleeping), then[0;37m, but get this:
Question: Why does it work this way? All characters the same, terminal state the same, but in one case terminal get escape sequence, and in another case don't.
Edit
The question was answered here: Echoed escape sequences doesn't interpreted in Linux tty.





sttyto inspect the terminal file. Otherwise one difference is that sleep is not doing anything with the input, while the output fromechoor external data is written to the terminal. – thrig Jun 07 '17 at 23:06Ctrl+vis needed to "add the next character typed to the line verbatim. This is how to insert characters like C-q, for example." Quote fromman bash. So, if I want to insertEsccode verbatim, I doCtrl+v, then pressEscbutton. – MiniMax Sep 12 '19 at 23:32