Created
October 9, 2013 10:37
-
-
Save dshipp/6899306 to your computer and use it in GitHub Desktop.
Add colour to Bash script output. (http://wiki.bash-hackers.org/snipplets/add_color_to_your_scripts)
This file contains 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
#!/bin/bash | |
# Colours | |
ESC_SEQ="\x1b[" | |
COL_RESET=$ESC_SEQ"39;49;00m" | |
COL_RED=$ESC_SEQ"31;01m" | |
COL_GREEN=$ESC_SEQ"32;01m" | |
COL_YELLOW=$ESC_SEQ"33;01m" | |
COL_BLUE=$ESC_SEQ"34;01m" | |
COL_MAGENTA=$ESC_SEQ"35;01m" | |
COL_CYAN=$ESC_SEQ"36;01m" | |
echo -e "${COL_RED}You can colourize output by adding -e to the echo command and including one of the colour codes we set up" | |
ls | |
echo "If you don't use \$COL_RESET then the colour will continue to be used, including output of commands. the output of ls will have been red." | |
echo -e "${COL_RESET}Now colours have been set back to normal" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment