prompt user vs root

This commit is contained in:
Meutel 2017-05-01 13:04:44 +02:00
parent f3b19befc2
commit a735c0d758

35
_bashrc
View File

@ -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 #####