mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-29 06:26:06 +02:00
perf(spectrum): build the FG and BG tables without a 256-iteration loop (#14073)
This commit is contained in:
+10
-4
@@ -14,10 +14,16 @@ FX=(
|
|||||||
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
reverse "%{[07m%}" no-reverse "%{[27m%}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for color in {000..255}; do
|
# Build the tables with array operations instead of a 256-iteration loop
|
||||||
FG[$color]="%{[38;5;${color}m%}"
|
() {
|
||||||
BG[$color]="%{[48;5;${color}m%}"
|
setopt localoptions noksharrays
|
||||||
done
|
local -a codes fg bg
|
||||||
|
codes=({000..255})
|
||||||
|
fg=( "%{"$'\e'"[38;5;"${^codes}"m%}" )
|
||||||
|
bg=( "%{"$'\e'"[48;5;"${^codes}"m%}" )
|
||||||
|
FG=( ${codes:^fg} )
|
||||||
|
BG=( ${codes:^bg} )
|
||||||
|
}
|
||||||
|
|
||||||
# Show all 256 colors with color number
|
# Show all 256 colors with color number
|
||||||
function spectrum_ls() {
|
function spectrum_ls() {
|
||||||
|
|||||||
Reference in New Issue
Block a user