mirror of
https://github.com/dcarrillo/prezto.git
synced 2026-04-19 09:54:06 +00:00
spectrum: optimize ANSI color initialization loops
Split the single loop that initializes both named ANSI colors (0–7) and the remaining 256-color indices into two separate loops. The first loop sets both numeric and name keys for the named ANSI colors without per-iteration checks, and the second loop sets only numeric keys for the remaining indices.
This commit is contained in:
@@ -56,14 +56,18 @@ FX=(
|
|||||||
FG[none]="$FX[none]"
|
FG[none]="$FX[none]"
|
||||||
BG[none]="$FX[none]"
|
BG[none]="$FX[none]"
|
||||||
colors=(black red green yellow blue magenta cyan white)
|
colors=(black red green yellow blue magenta cyan white)
|
||||||
for color in {0..255}; do
|
|
||||||
if (( $color >= 0 )) && (( $color < $#colors )); then
|
|
||||||
index=$(( $color + 1 ))
|
|
||||||
FG[$colors[$index]]="\e[38;5;${color}m"
|
|
||||||
BG[$colors[$index]]="\e[48;5;${color}m"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# Named ANSI colors (0–7) have both numeric and name keys.
|
||||||
|
for color in {0..7}; do
|
||||||
|
FG[$colors[color+1]]="\e[38;5;${color}m"
|
||||||
|
BG[$colors[color+1]]="\e[48;5;${color}m"
|
||||||
FG[$color]="\e[38;5;${color}m"
|
FG[$color]="\e[38;5;${color}m"
|
||||||
BG[$color]="\e[48;5;${color}m"
|
BG[$color]="\e[48;5;${color}m"
|
||||||
done
|
done
|
||||||
unset color{s,} index
|
|
||||||
|
# Remaining 256-color indices have only numeric keys.
|
||||||
|
for color in {8..255}; do
|
||||||
|
FG[$color]="\e[38;5;${color}m"
|
||||||
|
BG[$color]="\e[48;5;${color}m"
|
||||||
|
done
|
||||||
|
unset color{s,}
|
||||||
|
|||||||
Reference in New Issue
Block a user