Last active
July 22, 2024 11:30
-
-
Save kennethreitz/be23571a5631e00b19d4223999667e5b to your computer and use it in GitHub Desktop.
Bash foreground ANSI terminal colors script.
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
#!/usr/bin/env bash | |
function bake_fg_color { | |
BLACK="\033[0;30m" | |
BLACK_BOLD="\033[1;30m" | |
WHITE="\033[0;37m" | |
WHITE_BOLD="\033[1;37m" | |
RED="\033[0;31m" | |
RED_BOLD="\033[1;31m" | |
GREEN="\033[0;32m" | |
GREEN_BOLD="\033[1;32m" | |
YELLOW="\033[0;33m" | |
YELLOW_BOLD="\033[1;33m" | |
BLUE="\033[0;34m" | |
BLUE_BOLD="\033[1;34m" | |
PURPLE="\033[0;35m" | |
PURPLE_BOLD="\033[1;35m" | |
CYAN="\033[0;36m" | |
CYAN_BOLD="\033[1;36m" | |
NO_COLOR="\033[0m" | |
CHOSEN_COLOR="${1}" | |
ARGV_INPUT="${2}" | |
COLOR="${!CHOSEN_COLOR}" | |
if [ -z "$ARGV_INPUT" ]; then | |
read -r INPUT | |
else | |
INPUT="$ARGV_INPUT" | |
fi | |
echo -e "${COLOR}${INPUT}${NO_COLOR}" | |
} | |
function red { | |
bake_fg_color 'RED' "$1" | |
} |
Author
kennethreitz
commented
Sep 22, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment