4 ms·
Here's my PS1: # ----------------------------------------------------------------- # BASH PROMPT # ------------------------------------------------
by SeoxyS 15y ago
Here's my PS1:
# -----------------------------------------------------------------
# BASH PROMPT
# -----------------------------------------------------------------
parse_git_branch() {
git_branch=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ $git_branch ]; then
echo "•$git_branch"
fi
}
# sexy prompt
export PS1='[\[\033[0;35m\]\h\[\033[0;36m\] \w\[\033[00m\]\[\033[33m\]$(parse_git_branch)\[\03 3[00m\]]\$ '
And here's what it looks like:
http://akhun.com/seo/skitch/Screen_Shot_2011-08-02_at_8.47.12_AM-20110802-084738.png http://akhun.com/seo/skitch/Screen_Shot_2011-08-02_at_8.47.1...
- Groxx 15y agoI'm using something similar, but ran into a problem recently: go into a detached head mode (`git checkout HEAD^`). ALL your branches (local and remote) are spat out into your PS1. It's rare enough that I haven't looked into fixing it, but have any suggestions?
- telemachos 15y agoMy suggestion is to use something more like this (provided by Git's bash-completion): branch=$(__git_ps1 "%s") That doesn't have any problem with detached head: http://cl.ly/8yN8 http://cl.ly/8yN8
- Groxx 15y agoooh, very nice. Prior to this & your other reply, I hadn't seen anything using the __git functions. Everyone uses sed. Thanks!