diff options
Diffstat (limited to '11_Colors.zsh')
-rw-r--r-- | 11_Colors.zsh | 23 |
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]" |