Skip to content

Instantly share code, notes, and snippets.

@joshlawton
Created August 14, 2024 06:08
Show Gist options
  • Save joshlawton/8500c03a15109ae735ade8c080709aef to your computer and use it in GitHub Desktop.
Save joshlawton/8500c03a15109ae735ade8c080709aef to your computer and use it in GitHub Desktop.
Zsh terminal color variables/codes
# To use these color variables in your zsh scripts or terminal:
#
# 1. Save this content to a file, for example `terminal_colors.sh`.
# 2. Source the file in your script or shell session:
# ```sh
# source /path/to/terminal_colors.sh
# ```
# 3. Use the variables in your echo statements or prompts:
# ```sh
# echo "${BLUE}This is blue text${RESET}"
# echo "${BOLD_RED_ON_YELLOW}This is bold red text on a yellow background${RESET}"
# ```
#
# Remember to use the `${RESET}` variable after each colored output to return to the default terminal colors.
# Reset
RESET='\033[0m'
# Regular text colors
BLACK='\033[0;30m'
BLUE='\033[0;34m'
RED='\033[0;31m'
GREEN='\033[0;32m'
MAGENTA='\033[0;35m'
CYAN='\033[0;36m'
YELLOW='\033[0;33m'
WHITE='\033[0;37m'
# Background colors
BLACK_BG='\033[40m'
BLUE_BG='\033[44m'
RED_BG='\033[41m'
GREEN_BG='\033[42m'
MAGENTA_BG='\033[45m'
CYAN_BG='\033[46m'
YELLOW_BG='\033[43m'
WHITE_BG='\033[47m'
# Bold text colors
BOLD_BLACK='\033[1;30m'
BOLD_BLUE='\033[1;34m'
BOLD_RED='\033[1;31m'
BOLD_GREEN='\033[1;32m'
BOLD_MAGENTA='\033[1;35m'
BOLD_CYAN='\033[1;36m'
BOLD_YELLOW='\033[1;33m'
BOLD_WHITE='\033[1;37m'
# Colored text on background colors
BLACK_ON_BLUE='\033[0;30;44m'
BLACK_ON_RED='\033[0;30;41m'
BLACK_ON_GREEN='\033[0;30;42m'
BLACK_ON_MAGENTA='\033[0;30;45m'
BLACK_ON_CYAN='\033[0;30;46m'
BLACK_ON_YELLOW='\033[0;30;43m'
BLACK_ON_WHITE='\033[0;30;47m'
BLUE_ON_BLACK='\033[0;34;40m'
BLUE_ON_RED='\033[0;34;41m'
BLUE_ON_GREEN='\033[0;34;42m'
BLUE_ON_MAGENTA='\033[0;34;45m'
BLUE_ON_CYAN='\033[0;34;46m'
BLUE_ON_YELLOW='\033[0;34;43m'
BLUE_ON_WHITE='\033[0;34;47m'
RED_ON_BLACK='\033[0;31;40m'
RED_ON_BLUE='\033[0;31;44m'
RED_ON_GREEN='\033[0;31;42m'
RED_ON_MAGENTA='\033[0;31;45m'
RED_ON_CYAN='\033[0;31;46m'
RED_ON_YELLOW='\033[0;31;43m'
RED_ON_WHITE='\033[0;31;47m'
GREEN_ON_BLACK='\033[0;32;40m'
GREEN_ON_BLUE='\033[0;32;44m'
GREEN_ON_RED='\033[0;32;41m'
GREEN_ON_MAGENTA='\033[0;32;45m'
GREEN_ON_CYAN='\033[0;32;46m'
GREEN_ON_YELLOW='\033[0;32;43m'
GREEN_ON_WHITE='\033[0;32;47m'
MAGENTA_ON_BLACK='\033[0;35;40m'
MAGENTA_ON_BLUE='\033[0;35;44m'
MAGENTA_ON_RED='\033[0;35;41m'
MAGENTA_ON_GREEN='\033[0;35;42m'
MAGENTA_ON_CYAN='\033[0;35;46m'
MAGENTA_ON_YELLOW='\033[0;35;43m'
MAGENTA_ON_WHITE='\033[0;35;47m'
CYAN_ON_BLACK='\033[0;36;40m'
CYAN_ON_BLUE='\033[0;36;44m'
CYAN_ON_RED='\033[0;36;41m'
CYAN_ON_GREEN='\033[0;36;42m'
CYAN_ON_MAGENTA='\033[0;36;45m'
CYAN_ON_YELLOW='\033[0;36;43m'
CYAN_ON_WHITE='\033[0;36;47m'
YELLOW_ON_BLACK='\033[0;33;40m'
YELLOW_ON_BLUE='\033[0;33;44m'
YELLOW_ON_RED='\033[0;33;41m'
YELLOW_ON_GREEN='\033[0;33;42m'
YELLOW_ON_MAGENTA='\033[0;33;45m'
YELLOW_ON_CYAN='\033[0;33;46m'
YELLOW_ON_WHITE='\033[0;33;47m'
WHITE_ON_BLACK='\033[0;37;40m'
WHITE_ON_BLUE='\033[0;37;44m'
WHITE_ON_RED='\033[0;37;41m'
WHITE_ON_GREEN='\033[0;37;42m'
WHITE_ON_MAGENTA='\033[0;37;45m'
WHITE_ON_CYAN='\033[0;37;46m'
WHITE_ON_YELLOW='\033[0;37;43m'
# Bold colored text on background colors
BOLD_BLACK_ON_BLUE='\033[1;30;44m'
BOLD_BLACK_ON_RED='\033[1;30;41m'
BOLD_BLACK_ON_GREEN='\033[1;30;42m'
BOLD_BLACK_ON_MAGENTA='\033[1;30;45m'
BOLD_BLACK_ON_CYAN='\033[1;30;46m'
BOLD_BLACK_ON_YELLOW='\033[1;30;43m'
BOLD_BLACK_ON_WHITE='\033[1;30;47m'
BOLD_BLUE_ON_BLACK='\033[1;34;40m'
BOLD_BLUE_ON_RED='\033[1;34;41m'
BOLD_BLUE_ON_GREEN='\033[1;34;42m'
BOLD_BLUE_ON_MAGENTA='\033[1;34;45m'
BOLD_BLUE_ON_CYAN='\033[1;34;46m'
BOLD_BLUE_ON_YELLOW='\033[1;34;43m'
BOLD_BLUE_ON_WHITE='\033[1;34;47m'
BOLD_RED_ON_BLACK='\033[1;31;40m'
BOLD_RED_ON_BLUE='\033[1;31;44m'
BOLD_RED_ON_GREEN='\033[1;31;42m'
BOLD_RED_ON_MAGENTA='\033[1;31;45m'
BOLD_RED_ON_CYAN='\033[1;31;46m'
BOLD_RED_ON_YELLOW='\033[1;31;43m'
BOLD_RED_ON_WHITE='\033[1;31;47m'
BOLD_GREEN_ON_BLACK='\033[1;32;40m'
BOLD_GREEN_ON_BLUE='\033[1;32;44m'
BOLD_GREEN_ON_RED='\033[1;32;41m'
BOLD_GREEN_ON_MAGENTA='\033[1;32;45m'
BOLD_GREEN_ON_CYAN='\033[1;32;46m'
BOLD_GREEN_ON_YELLOW='\033[1;32;43m'
BOLD_GREEN_ON_WHITE='\033[1;32;47m'
BOLD_MAGENTA_ON_BLACK='\033[1;35;40m'
BOLD_MAGENTA_ON_BLUE='\033[1;35;44m'
BOLD_MAGENTA_ON_RED='\033[1;35;41m'
BOLD_MAGENTA_ON_GREEN='\033[1;35;42m'
BOLD_MAGENTA_ON_CYAN='\033[1;35;46m'
BOLD_MAGENTA_ON_YELLOW='\033[1;35;43m'
BOLD_MAGENTA_ON_WHITE='\033[1;35;47m'
BOLD_CYAN_ON_BLACK='\033[1;36;40m'
BOLD_CYAN_ON_BLUE='\033[1;36;44m'
BOLD_CYAN_ON_RED='\033[1;36;41m'
BOLD_CYAN_ON_GREEN='\033[1;36;42m'
BOLD_CYAN_ON_MAGENTA='\033[1;36;45m'
BOLD_CYAN_ON_YELLOW='\033[1;36;43m'
BOLD_CYAN_ON_WHITE='\033[1;36;47m'
BOLD_YELLOW_ON_BLACK='\033[1;33;40m'
BOLD_YELLOW_ON_BLUE='\033[1;33;44m'
BOLD_YELLOW_ON_RED='\033[1;33;41m'
BOLD_YELLOW_ON_GREEN='\033[1;33;42m'
BOLD_YELLOW_ON_MAGENTA='\033[1;33;45m'
BOLD_YELLOW_ON_CYAN='\033[1;33;46m'
BOLD_YELLOW_ON_WHITE='\033[1;33;47m'
BOLD_WHITE_ON_BLACK='\033[1;37;40m'
BOLD_WHITE_ON_BLUE='\033[1;37;44m'
BOLD_WHITE_ON_RED='\033[1;37;41m'
BOLD_WHITE_ON_GREEN='\033[1;37;42m'
BOLD_WHITE_ON_MAGENTA='\033[1;37;45m'
BOLD_WHITE_ON_CYAN='\033[1;37;46m'
BOLD_WHITE_ON_YELLOW='\033[1;37;43m'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment