Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2012 22:35
Show Gist options
  • Save anonymous/4229107 to your computer and use it in GitHub Desktop.
Save anonymous/4229107 to your computer and use it in GitHub Desktop.
# Add this to your .bashrc
source ~/.make_ps1
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/'
}
parse_virtualenv() {
echo '['$(basename $VIRTUAL_ENV 2> /dev/null)']' | sed -e '/\[\]/d'
}
function mworkon()
{
workon "$@"
source ~/.make_ps1
}
alias workon="mworkon"
# Create file in your home directory ".make_ps1" and add this to the top
PS1_L1="\[\e[1;30m\]Exit with [$?] @ \@\n"
PS1_L2="\[\e[1;31m\]\$(parse_git_branch)\[\e[1;33m\]\$(parse_virtualenv)\[\e[0;32m\][\u]\[\e[0;34m\]\w$ \[\e[1;33m\]"
PS1=$PS1_L1$PS1_L2
#example (minus the color)
Exit with [0] @ 02:35 PM
[master][gather][thauber]~/Projects/TCF$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment