Skip to content

Instantly share code, notes, and snippets.

@inlinestyle
Created August 3, 2012 04:03
Show Gist options
  • Save inlinestyle/3244214 to your computer and use it in GitHub Desktop.
Save inlinestyle/3244214 to your computer and use it in GitHub Desktop.
A sweet PS1 for displaying git state and virtualenv
red="\[\e[0;31m\]"
green="\[\e[0;32m\]"
yellow="\[\e[0;33m\]"
purple="\[\e[0;35m\]"
cyan="\[\e[0;36m\]"
end="\[\e[0m\]"
GIT_PS1_SHOWUPSTREAM=auto
GIT_PS1_SHOWSTASHSTATE=true
GIT_PS1_SHOWDIRTYSTATE=true
VIRTUAL_ENV_DISABLE_PROMPT=true
display_virtualenv () {
[ ${VIRTUAL_ENV} ] && echo `basename ${VIRTUAL_ENV}`
}
display_cool_pipe () {
if [[ $(__gitdir) && ${VIRTUAL_ENV} ]]
then
echo "|"
fi
}
export PS1="${cyan}\w @ \@${end} ${purple}(${end}${yellow}\$(display_virtualenv)${end}${purple}\$(display_cool_pipe)${end}${yellow}\$(__git_ps1 "%s")${end}${purple})${end}\n${purple}-> ${end}"
@inlinestyle
Copy link
Author

The PS1 looks super awkward because I have to escape the function calls, which would escape any color formatting that they would return

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment