Last active
March 17, 2025 21:35
-
-
Save mauriciopazpp/6a01f015c7598b6eb4ce367cc7d590bc to your computer and use it in GitHub Desktop.
Bash terminal echo colors
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
An example is | |
Code: | |
echo "\033[1;31m Hello \033[0m" | |
The '31' and the '1' are the things you change. The '31' is the color code, and the '1' is where you put whatever you want to color. The rest of it is the same for every color coding; the beginning starts coloring, and the stuff afterwards stops coloring ('0' switches it back to default text color). You can use the following color codes: | |
Code: | |
30 - black | |
31 - red | |
32 - green | |
33 - yellow | |
34 - blue | |
35 - magenta | |
36 - cyan | |
37 - white | |
You can make a pretty nice prompt with it. Also, you can modify it further by including another control char: | |
Code: | |
%{\033[1;31m%}%m%{\033[0m%} | |
In this case, the '1' will make the following color bold. You can use the following modifiers: | |
Code: | |
0 - normal | |
1 - bold | |
2 - normal again | |
3 - background color | |
4 - underline the text | |
5 - blinking | |
You can also specify both a foreground and a background color. | |
Code: | |
echo "\033[5;41;1;37m *** ERROR *** \033[0m" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment