Skip to content

Instantly share code, notes, and snippets.

@vhata
Created August 14, 2012 11:09
Show Gist options
  • Save vhata/3348222 to your computer and use it in GitHub Desktop.
Save vhata/3348222 to your computer and use it in GitHub Desktop.
# Colorize PS1 according to privileges
if [[ ${EUID} == 0 ]] ; then
PS1="\[\033[01;31m\][\h]"
else
PS1="\[\033[01;32m\][\u@\h]"
fi
# git branch
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}
PS1="${PS1} \[\033[01;31m\]\$(parse_git_branch)"
# Add path
PS1="${PS1}\[\033[01;34m\]\w \\\$ \[\033[00m\]"
# Prepend time and exit code of previous command
PS1="\A/$? ${PS1}"
# Prepend ANSI code to return to beginning of line
# Useful if previous command had output that didn't end in a newline
#PS1="\[\033[G\]${PS1}"
export PS1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment