feat(bash): add assoc array of ANSI color codes

This commit is contained in:
Victor Westerlund 2026-01-25 09:16:53 +01:00
parent e3577a414c
commit e28c8d7cdf
Signed by: vlw
GPG key ID: D0AD730E1057DFC6

View file

@ -3,8 +3,53 @@ if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# Declare ANSI color escape codes
declare -A ANSI=(
[RESET]="\e[0m"
# Text colors
[RED]="\e[0;31m"
[BLUE]="\e[0;34m"
[CYAN]="\e[0;36m"
[BLACK]="\e[0;30m"
[GREEN]="\e[0;32m"
[WHITE]="\e[0;37m"
[PURPLE]="\e[0;35m"
[YELLOW]="\e[0;33m"
# High intensity text colors
[HI_RED]="\e[0;91m"
[HI_BLUE]="\e[0;94m"
[HI_CYAN]="\e[0;96m"
[HI_BLACK]="\e[0;90m"
[HI_GREEN]="\e[0;92m"
[HI_WHITE]="\e[0;97m"
[HI_PURPLE]="\e[0;95m"
[HI_YELLOW]="\e[0;93m"
# Background colors
[BG_RED]="\e[41m"
[BG_BLUE]="\e[44m"
[BG_CYAN]="\e[46m"
[BG_BLACK]="\e[40m"
[BG_GREEN]="\e[42m"
[BG_WHITE]="\e[47m"
[BG_PURPLE]="\e[45m"
[BG_YELLOW]="\e[43m"
# High intensity background colors
[BG_HI_RED]="\e[0;101m"
[BG_HI_BLUE]="\e[0;104m"
[BG_HI_CYAN]="\e[0;106m"
[BG_HI_BLACK]="\e[0;100m"
[BG_HI_GREEN]="\e[0;102m"
[BG_HI_WHITE]="\e[0;107m"
[BG_HI_PURPLE]="\e[0;105m"
[BG_HI_YELLOW]="\e[0;103m"
)
# Enable shell prompt colors (will not apply to command prompt).
export PS1='\[\e[38;5;46m\]\u\[\e[38;5;2m\]@\[\e[38;5;46m\]\h\[\e[38;5;2m\]:\[\e[38;5;33m\]\w\[\033[0m\]$ '
export PS1="\[\e[0;32m\]\u\[\e[38;5;2m\]@\[\e[38;5;46m\]\h\[\e[38;5;2m\]:\[\e[38;5;33m\]\w\[\033[0m\]$ "
# Export GPG_TTY for signing stuff with gpg
export GPG_TTY=$(tty)
@ -19,4 +64,4 @@ export V="/var/www/fw/vegvisir/"
export XDG_BIN_HOME="$HOME/.local/bin"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CONFIG_HOME="$HOME/.config"