From a735c0d7587a86028b795159d3f1dc41715e4828 Mon Sep 17 00:00:00 2001 From: Meutel Date: Mon, 1 May 2017 13:04:44 +0200 Subject: [PATCH] prompt user vs root --- _bashrc | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/_bashrc b/_bashrc index fd1b4a9..e11f353 100644 --- a/_bashrc +++ b/_bashrc @@ -39,19 +39,6 @@ WHITE='\[\033[0;37m\]' WHITEB='\[\033[1;37m\]' RESET='\[\033[0;00m\]' -##### FUNCTIONS ##### - -# status indicator -prompt_status() -{ - if [[ "$?" == "0" ]] - then - echo -n "${GREENB}-" - else - echo -n "${REDB}X" - fi -} - ##### INCLUDES ##### # Alias definitions. @@ -98,6 +85,26 @@ export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock ##### PROMPT ##### +# status indicator +prompt_status() +{ + if [[ "$?" == "0" ]] + then + echo -n "${GREENB}-" + else + echo -n "${REDB}X" + fi +} +prompt_root() +{ + if [[ "$(id -u)" == "0" ]] + then + echo -n "${REDB}#" + else + echo -n "${WHITEB}$" + fi +} + __ps1() { ps1pre="$1" @@ -105,7 +112,7 @@ __ps1() PS1="$ps1pre$ps1post" } PS1pre='"${REDB}>> ${WHITEB}(${WHITE}\u@${GREEN}\h${WHITEB}) ${BLUEB}\w${RESET}"' -PS1post='"\n$(prompt_status)${REDB}>${WHITE} "' +PS1post='"\n$(prompt_status)$(prompt_root)${RESET} "' PROMPT_COMMAND="__ps1 $PS1pre $PS1post" ##### GIT #####