Created
June 6, 2012 16:10
-
-
Save philchristensen/2882970 to your computer and use it in GitHub Desktop.
Mega developers prompt
This file contains 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
export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
function parse_svn_branch { | |
if [ -d '.svn' ]; then | |
ref=$(svn info | grep URL | awk -F/ '{print $NF}' 2> /dev/null) || return | |
cur=$(pwd | awk -F/ '{print $NF}' 2> /dev/null) || return | |
if [ $ref != $cur ]; then | |
echo -ne "\xE2\x9C\xB6${ref}" | |
fi | |
fi | |
} | |
function parse_git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return | |
echo -ne "\xE2\x9C\xB9${ref#refs/heads/}" | |
} | |
function display_virtualenv { | |
if [ -n "$VIRTUAL_ENV" ]; then | |
ref=$(basename $VIRTUAL_ENV) | |
echo -ne "\xE2\x9D\xB0${ref}\xE2\x9D\xB1" | |
fi | |
} | |
function display_virtualenv_path { | |
if [ -n "$VIRTUAL_ENV" ]; then | |
ref=$(basename $VIRTUAL_ENV) | |
echo -ne "${ref}" | |
fi | |
} | |
function decorate_prompt { | |
clock= #"[\[\e[31;49m\]\@\[\e[0m\]] " | |
svn="\[\e[1;35m\]\$(parse_svn_branch)\[\e[0m\]" | |
git="\[\e[1;34m\]\$(parse_git_branch)\[\e[0m\]" | |
user="\h:" #"\u@\h:" | |
ref=$(basename "$VIRTUAL_ENV") | |
basedir=$(pwd | awk -F/ '{print $NF}' 2> /dev/null) | |
if [ "$basedir" == "$ref" ]; then | |
virtual="\[\e[31;36m\]\$(display_virtualenv_path)\[\e[0m\]" | |
working_dir=$(dirname `pwd`) | |
export PS1="${clock}${user}\[\e[37m\]${working_dir/\/home\/phil/~}\[\e[0m\]/${virtual}${svn}${git} \$ " | |
else | |
virtual="\[\e[31;36m\]\$(display_virtualenv)\[\e[0m\]" | |
export PS1="${clock}${user}\[\e[37m\]\w\[\e[0m\]${virtual}${svn}${git} \$ " | |
fi | |
} | |
function pcommand { | |
if [ "$WINDOW_NAME" ]; then | |
echo -ne "\033]0;${WINDOW_NAME}\007" | |
return | |
else | |
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007" | |
if [ "$TERM" == "screen" ]; then | |
name=`basename ${PWD}` | |
echo -ne "\ek${name}\e\\" | |
fi | |
fi | |
decorate_prompt | |
} | |
export PROMPT_COMMAND=pcommand |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result
Example: