Skip to content

Instantly share code, notes, and snippets.

@thauber
Forked from anonymous/gist:4229107
Created December 12, 2012 02:31
Show Gist options
  • Save thauber/4264360 to your computer and use it in GitHub Desktop.
Save thauber/4264360 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