Last active
September 21, 2025 10:46
-
-
Save bcap/5682077 to your computer and use it in GitHub Desktop.
Useful terminal control characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Terminal output control (http://www.termsys.demon.co.uk/vtansi.htm) | |
| TC='\e[' | |
| CLR_LINE_START="${TC}1K" | |
| CLR_LINE_END="${TC}K" | |
| CLR_LINE="${TC}2K" | |
| # Hope no terminal is greater than 1k columns | |
| RESET_LINE="${CLR_LINE}${TC}1000D" | |
| # Colors (based on https://github.com/demure/dotfiles/blob/master/subbash/prompt) | |
| RCol="${TC}0m" # Reset Color | |
| # Regular Bold Underline High Intensity BoldHigh Intensity Background High Intensity Backgrounds | |
| Bla="${TC}0;30m"; BBla="${TC}1;30m"; UBla="${TC}4;30m"; IBla="${TC}0;90m"; BIBla="${TC}1;90m"; On_Bla="${TC}40m"; On_IBla="${TC}0;100m"; | |
| Red="${TC}0;31m"; BRed="${TC}1;31m"; URed="${TC}4;31m"; IRed="${TC}0;91m"; BIRed="${TC}1;91m"; On_Red="${TC}41m"; On_IRed="${TC}0;101m"; | |
| Gre="${TC}0;32m"; BGre="${TC}1;32m"; UGre="${TC}4;32m"; IGre="${TC}0;92m"; BIGre="${TC}1;92m"; On_Gre="${TC}42m"; On_IGre="${TC}0;102m"; | |
| Yel="${TC}0;33m"; BYel="${TC}1;33m"; UYel="${TC}4;33m"; IYel="${TC}0;93m"; BIYel="${TC}1;93m"; On_Yel="${TC}43m"; On_IYel="${TC}0;103m"; | |
| Blu="${TC}0;34m"; BBlu="${TC}1;34m"; UBlu="${TC}4;34m"; IBlu="${TC}0;94m"; BIBlu="${TC}1;94m"; On_Blu="${TC}44m"; On_IBlu="${TC}0;104m"; | |
| Pur="${TC}0;35m"; BPur="${TC}1;35m"; UPur="${TC}4;35m"; IPur="${TC}0;95m"; BIPur="${TC}1;95m"; On_Pur="${TC}45m"; On_IPur="${TC}0;105m"; | |
| Cya="${TC}0;36m"; BCya="${TC}1;36m"; UCya="${TC}4;36m"; ICya="${TC}0;96m"; BICya="${TC}1;96m"; On_Cya="${TC}46m"; On_ICya="${TC}0;106m"; | |
| Whi="${TC}0;37m"; BWhi="${TC}1;37m"; UWhi="${TC}4;37m"; IWhi="${TC}0;97m"; BIWhi="${TC}1;97m"; On_Whi="${TC}47m"; On_IWhi="${TC}0;107m"; | |
| # example: | |
| # echo -n "${BBlu}${On_Whi}bold blue text on white background${RCol}"; sleep 3; echo "${RESET_LINE}${Red}${On_Pur}becomes red text on purple background${RCol}" |
Thanks man, it helps a lot~ Notice that you might need to use
echo -efor those color escaped sequences to work.
Agreed! It's 'echo -e' for me too. Wonder if this can be set globally via system variable or so. But this is great! Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks man, it helps a lot~ Notice that you might need to use
echo -efor those color escaped sequences to work.