summaryrefslogtreecommitdiff
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
parent0c2f884cb91aab0e2f3f8ace3ed32f6634f8b972 (diff)
[COLORS] tests 256/88 colors256_colors
-rw-r--r--11_Colors.zsh23
-rw-r--r--12_Prompts.zsh2
2 files changed, 19 insertions, 6 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]"
diff --git a/12_Prompts.zsh b/12_Prompts.zsh
index 8aa70c6..bbb5e11 100644
--- a/12_Prompts.zsh
+++ b/12_Prompts.zsh
@@ -20,7 +20,7 @@ else
# That's so good, use it ! :-)
prompt_colors[generic]=${PS1_USER_SSH:-$PS1_USER}
fi
- if ( [ "$TERM" = "screen" ] )
+ if ( echo "$TERM" | grep "^screen.*$" >/dev/null )
then
# Are we under a screen session ?
prompt_colors[generic]=${PS1_USER_SCR:-$PS1_USER}