summaryrefslogtreecommitdiff
path: root/11_Colors.zsh
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2009-03-06 14:20:56 +0100
committerHugues Hiegel <hugues@hiegel.fr>2009-03-06 14:20:56 +0100
commit51d319dc8421587e4f55f9ae84be74d6b75077ee (patch)
treed031466846ad789b20fd8ee03305441ff856ccc3 /11_Colors.zsh
parent0c2f884cb91aab0e2f3f8ace3ed32f6634f8b972 (diff)
[COLORS] tests 256/88 colors256_colors
Diffstat (limited to '11_Colors.zsh')
-rw-r--r--11_Colors.zsh23
1 files changed, 18 insertions, 5 deletions
diff --git a/11_Colors.zsh b/11_Colors.zsh
index 7cf4007..5b26c01 100644
--- a/11_Colors.zsh
+++ b/11_Colors.zsh
@@ -22,11 +22,24 @@ typeset -A prompt_colors git_colors mail_colors correct_colors battery_colors da
#
# I'm storing the resulting dominant color in $prompt_colors[generic]
-PS1_ROOT=${PS1_ROOT:-$color[red]}
-PS1_USER=${PS1_USER:-$color[blue]}
-PS1_SUDO=${PS1_SUDO:-$color[green]}
-PS1_USER_SSH=${PS1_USER_SSH:-$color[magenta]}
-PS1_USER_SCR=${PS1_USER_SCR:-$color[cyan]}
+if [ "$termcap[Co]" = "256" -o "$termcap[Co]" = "88" ]
+then
+ # We have a 256 colors term !
+
+ local nb_colors=$(( 256 - 16 ))
+
+ PS1_ROOT=${PS1_ROOT:-38;5;$(( 16 + (36 * $SHLVL) % $nb_colors ))}
+ PS1_USER=${PS1_USER:-38;5;$(( 16 + $SHLVL % $nb_colors ))}
+ PS1_SUDO=${PS1_USER:-38;5;$(( 88 - $SHLVL % $nb_colors ))}
+ PS1_USER_SSH=${PS1_USER_SSH:-38;5;$(( 88 - $SHLVL % $nb_colors ))}
+ PS1_USER_SCR=${PS1_USER_SCR:-38;5;$(( 88 - $SHLVL % $nb_colors ))}
+else
+ PS1_ROOT=${PS1_ROOT:-$color[red]}
+ PS1_USER=${PS1_USER:-$color[blue]}
+ PS1_SUDO=${PS1_SUDO:-$color[green]}
+ PS1_USER_SSH=${PS1_USER_SSH:-$color[magenta]}
+ PS1_USER_SCR=${PS1_USER_SCR:-$color[cyan]}
+fi
correct_colors[error]="$color[red];$color[bold]"
correct_colors[suggest]="$color[blue];$color[bold]"