Skip to content

Instantly share code, notes, and snippets.

@kevinnls
Last active September 1, 2020 05:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinnls/76328757b84b18277287175aed26d912 to your computer and use it in GitHub Desktop.
Save kevinnls/76328757b84b18277287175aed26d912 to your computer and use it in GitHub Desktop.

color codes in ... i think ANSI escape sequences?

declare -A fclr
declare -A bclr
declare -A mode
# modes
mode[0]="\[\e[0m\]"
mode[bold]="\[\e[1m\]"
mode[dim]="\[\e[2m\]"
mode[underline]="\[\e[4m\]"
mode[blink]="\[\e[5m\]"
mode[invert]="\[\e[7m\]"
mode[hide]="\[\e[8m\]"
mode[strike]="\[\e9m\]"
# fg colors
fclr[w]="\[\e[97m\]";fclr[k]="\[\e[30m\]"
fclr[gy]="\[\e[90m\]";fclr[l_gy]="\[\e[37m\]"
fclr[r]="\[\e[31m\]";fclr[l_r]="\[\e[91m\]"
fclr[g]="\[\e[32m\]";fclr[l_g]="\[\e[92m\]"
fclr[y]="\[\e[33m\]";fclr[l_y]="\[\e[93m\]"
fclr[b]="\[\e[34m\]";fclr[l_b]="\[\e[94m\]"
fclr[m]="\[\e[35m\]";fclr[l_m]="\[\e[95m\]"
fclr[c]="\[\e[36m\]";fclr[l_c]="\[\e[96m\]"
# bg colors
bclr[w]="\[\e[107m\]";bclr[k]="\[\e[40m\]"
bclr[gy]="\[\e[100m\]";bclr[l_gy]="\[\e[47m\]"
bclr[r]="\[\e[41m\]";bclr[l_r]="\[\e[101m\]"
bclr[g]="\[\e[42m\]";bclr[l_g]="\[\e[102m\]"
bclr[y]="\[\e[43m\]";bclr[l_y]="\[\e[103m\]"
bclr[b]="\[\e[44m\]";bclr[l_b]="\[\e[104m\]"
bclr[m]="\[\e[45m\]";bclr[l_m]="\[\e[105m\]"
bclr[c]="\[\e[46m\]";bclr[l_c]="\[\e[106m\]"
unset fclr bclr mode
@kevinnls
Copy link
Author

kevinnls commented Aug 30, 2020

image

the colors for comparision

PS1='
\[\e[31m\]Red
\[\e[0m\]==
\[\e[91m\]LRed
\[\e[0m\]==
\[\e[1;31m\]BRed
\[\e[0m\]==
\[\e[1;91m\]BLRed
\[\e[0m\]==
\[\e[2;31m\]DRed
\[\e[0m\]==
\[\e[2;91m\]DLRed
\[\e[0m\]$ ' `# obviously not exact code`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment