From af9c1de40bff87ae6ccc9430c364f7e18990dca8 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Thu, 5 Feb 2009 16:32:14 +0100 Subject: [Colors] better initialization of colors + sudo user color --- 12_Prompts.zsh | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to '12_Prompts.zsh') diff --git a/12_Prompts.zsh b/12_Prompts.zsh index 77aad63..4151f32 100644 --- a/12_Prompts.zsh +++ b/12_Prompts.zsh @@ -8,8 +8,31 @@ ## these files with or without this notice. ## -prompt_colors[generic]=`print -Pn "%(! $PS1_ROOT $PS1_USER)"` -set_prompt_colors $prompt_colors[generic] +prompt_colors[generic]=${PS1_USER:-} +if privileged_user +then + prompt_colors[generic]=${PS1_ROOT:-$color[red]} +else + if ( [ "$SSH_TTY" != "" ] ) + then + # This allows us to easily distinguish shells + # which really are on the local machine or not. + # That's so good, use it ! :-) + prompt_colors[generic]=${PS1_USER_SSH:-$PS1_USER} + fi + if ( [ "$TERM" = "screen" ] ) + then + # Are we under a screen session ? + prompt_colors[generic]=${PS1_USER_SCR:-$PS1_USER} + fi + if ( [ ! -z "$SUDO_USER" ] ) + then + # Are we sudo-ed under another user than root ? + prompt_colors[generic]=${PS1_SUDO:-$PS1_USER} + fi +fi + +set_prompt_colors ## Prompts # -- cgit v1.2.3