Created
February 29, 2012 21:53
-
-
Save bensonk/1944734 to your computer and use it in GitHub Desktop.
Python, mercurial, and git friendly prompt script for bash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Put this in ~/bin/ps1, and make it executable | |
# Then add the following line to your .bashrc or .bash_profile: | |
# PROMPT_COMMAND="source $HOME/bin/ps1" | |
HG_BRANCH=`hg branch 2>&1` | |
if [[ $? == 0 ]] | |
then | |
VCS_PROMPT="\[\033[00;33m\](\[\033[00;37m\]$HG_BRANCH\[\033[00;33m\]) \[\033[01;34m\]" | |
else | |
VCS_PROMPT="" | |
fi | |
GIT_BRANCH=`git branch 2>&1` | |
if [[ $? == 0 && -z $VCS_PROMPT ]] | |
then | |
GIT_BRANCH=`git branch 2>&1 | grep \\* | cut -d ' ' -f 2` | |
VCS_PROMPT="\[\033[00;33m\](\[\033[00;37m\]$GIT_BRANCH\[\033[00;33m\]) \[\033[01;34m\]" | |
fi | |
if [[ -e $VIRTUAL_ENV ]] | |
then | |
ENVNAME=`echo $VIRTUAL_ENV | cut -d / -f 5` | |
VENV_PROMPT="\[\033[00;33m\][\[\033[00;37m\]$ENVNAME\[\033[00;33m\]] " | |
else | |
VENV_PROMPT="" | |
fi | |
export PS1="$VENV_PROMPT\[\033[01;32m\]\u@\h\[\033[01;34m\] \w $VCS_PROMPT$ \[\033[00m\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment