28 lines
711 B
Text
28 lines
711 B
Text
# Determine whether or not we should support color.
|
|
case "$TERM" in
|
|
xterm-color|*-256color|rxvt-unicode) color_prompt=yes;;
|
|
esac
|
|
|
|
# Emit the current date and time.
|
|
__prompt_date() {
|
|
echo "$(date '+%D %r')"
|
|
}
|
|
|
|
# Define a function that extracts the current git branch, if available.
|
|
__git_branch() {
|
|
ref="$(git symbolic-ref HEAD 2>/dev/null | cut -d'/' -f3)"
|
|
if [ ! -z $ref ]; then
|
|
echo " $ref"
|
|
else
|
|
echo ""
|
|
fi
|
|
}
|
|
|
|
# Assign the prompt.
|
|
if [ "$color_prompt" = yes ]; then
|
|
PS1='\[\033[01;32m\]\u:\[\033[01;34m\]\w\[\033[00m\]\[\033[01;31m\]$(__git_branch)\[\033[00m\] $(__prompt_date)\n\$ '
|
|
else
|
|
PS1='\u:\w$(__git_branch) $(__prompt_date)\n\$ '
|
|
fi
|
|
|
|
unset color_prompt
|