ASCII escape sequences start with ESC followed by a number of bytes.
The ESC code is 033 in octal and 27 in decimal
A terminal will respond to escape codes that are output to it. Typing an escape code on keyboard by pressing ESC followed by sequence is treated as an input by the terminal and the it will not act on it therefore you need some way to echo the escape sequence back to the terminal as output for it to action it.
Linux example
echo -e "\033[31;1;4mHello\033[0m"
Powershell example
PS C:\Users\pdj10> $esc = "$([char]27)" # 27 is the escape character
PS C:\Users\pdj10> write-host "$esc[32m hello" # print hello in green
hello
PS C:\Users\pdj10>
^L - clear the screen.
^V - take the next character literally e.g. typing ctrl-V followed by ctrl-l the terminal will display '^L' and not clear the screen.
Linux example
echo -e "\033[31;1;4mHello\033[0m"
Powershell example
PS C:\Users\pdj10> $esc = "$([char]27)" # 27 is the escape character
PS C:\Users\pdj10> write-host "$esc[32m hello" # print hello in green
hello
PS C:\Users\pdj10>
^L - clear the screen.
^V - take the next character literally e.g. typing ctrl-V followed by ctrl-l the terminal will display '^L' and not clear the screen.
No comments:
Post a Comment