3 ms·
> [1]: You can type ^[ (escape) by pressing CTRL-'['. Don't type ^ and [ as separate chars, that won't work. You can also use the \x1b escape code(or the \e al
by account42 3y ago
> [1]: You can type ^[ (escape) by pressing CTRL-'['. Don't type ^ and [ as separate chars, that won't work.
You can also use the \x1b escape code(or the \e alias) together with a command that accepts escape code in order to avoid nonprintable characters on the command-line:
echo -e '\e[48;2;255;0;0mHello\e[0m'
For scripts, always use printf though since echo -e is nonstandard and even plain echo differs in edge cases:
printf '\e[48;2;255;0;0mHello\e[0m\n'
- vardump 3y agoPlease note I was talking about Windows 10/11 command prompt. Your tip works on Linux.