Created
September 30, 2014 19:17
-
-
Save stoneage7/2e2ae14dec45e2b98fdf to your computer and use it in GitHub Desktop.
Bash Prompt with git and virtualenv (2 lines)
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
case "$TERM" in | |
xterm*|screen) | |
# last command status ($?) shown as tick/cross and color | |
ok="\[\033[01;32m\]\342\234\223" | |
notok="\[\033[01;31m\]\342\234\227" | |
cmdresult="\$([[ \$? == 0 ]] && echo \"$ok\" || echo \"$notok\")" | |
# git current branch | |
git="\$( git branch 2> /dev/null | sed -n '/\\* /s///;s/^/ [/;s/$/]/p' )" | |
# virtualenv | |
virtualenv="\${VIRTUAL_ENV+\" (\$(basename \$VIRTUAL_ENV))\"}" | |
export VIRTUAL_ENV_DISABLE_PROMPT=1 | |
# put only prompt on 2nd line | |
ln1="\[\033[01;37m\]\342\225\255 $cmdresult$virtualenv$git \u@\h:\w" | |
ln2="\[\033[01;37m\]\342\225\260 \$ " | |
PS1="${ln1}\n${ln2}\[\033[00m\]" | |
unset ok notok cmdresult ln1 ln2 git virtualenv | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment