Skip to content

Instantly share code, notes, and snippets.

@ryderstorm
Created September 9, 2019 15:59
Show Gist options
  • Save ryderstorm/39d4235c66ac05ffa9fb650b386ae117 to your computer and use it in GitHub Desktop.
Save ryderstorm/39d4235c66ac05ffa9fb650b386ae117 to your computer and use it in GitHub Desktop.
Method for easily adding colors to your bash script outputs.
#!/bin/bash
# Sets variables that can be used to add color to text in bash scripts.
# Must use "echo -e" or "printf" for colors to work
# Load this file in your bash scripts by including this line:
# source /path/to/this/file
#
# Example usage:
# echo -e "${BLUE}This is blue.${YELLOW}And this is yellow.${NC}And this is the defaul color."
BLACK='\033[0;30m'
WHITE='\033[1;37m'
BLUE='\033[0;34m'
ORANGE='\033[0;33m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
PURPLE='\033[0;35m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
LIGHTBLUE='\033[1;34m'
LIGHTCYAN='\033[1;36m'
LIGHTGREEN='\033[1;32m'
LIGHTPURPLE='\033[1;35m'
LIGHTRED='\033[1;31m'
LIGHTGRAY='\033[0;37m'
DARKGRAY='\033[1;30m'
# Resets text back to default color for shell.
# Should always be added to the end of any color strings to ensure
# that text color is reset back to normal for all strings that follow.
NC='\033[0m'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment