dotfiles/home/.bash_prompt

46 lines
853 B
Bash

# defines __git_ps1
if [ -f ~/.bash_git ]; then
GIT_PS1_SHOWCOLORHINTS=1
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto"
source ~/.bash_git
PROMPT_COMMAND=show_prompt
fi
function show_prompt {
# Time
local pre='\[\e[01;30m\]\A '
local post
# Check last return value
if [[ $? -eq 0 ]]; then
pre+='\[\e[32m\]✔ '
else
pre+='\[\e[31m\]✘ '
fi
case "$TERM" in
xterm*|rxvt*)
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"
;;
*)
;;
esac
# Test if root
if [ $EUID -ne 0 ]; then
pre+='\[\e[01;34m\]\u\[\e[01;33m\]@\[\e[01;36m\]\H'
post='\[\e[01;34m\]\w'
else
pre+='\[\e[31m\]\u\[\e[01;33m\]@\[\e[01;36m\]\H'
post='\[\e[01;33m\]\w'
fi
post+='\n \[\e[01;30m\]\# \[\e[31m\]\$ \[\e[00m\]'
__git_ps1 "$pre " "$post" '\[\e[01;30m\](%s\[\e[01;30m\]) '
}