# HG changeset patch # User Steve Losh # Date 1244246833 14400 # Node ID 16cd7f5d90e419c1ca44236766ed869ca4227f4d # Parent 8a766979b5780a9125cd7a1c121b7157174477c9 Restructure the prompt. A lot. diff -r 8a766979b578 -r 16cd7f5d90e4 .bashrc --- a/.bashrc Wed Jun 03 23:54:18 2009 -0400 +++ b/.bashrc Fri Jun 05 20:07:13 2009 -0400 @@ -1,6 +1,5 @@ alias ls='ls -Goh ' alias less='less -R ' -alias webf-mysql-tunnel='ssh -NL 3306:sjl.webfactional.com:3306 webf' alias hl='less -R' alias pm='python manage.py ' alias tunnel_webf_mysql='ssh -NL 3306/web45.webfaction.com/3306 webf' @@ -12,34 +11,36 @@ # Extra shell extensions like j and tab completion for Mercurial ------------- source ~/lib/j/j.sh -source ~/lib/hg/hg-tab-completion +source ~/lib/hg/bash_completion source ~/lib/virtualenvwrapper_bashrc # Prompt stuff --------------------------------------------------------------- +DEFAULT="[37;40m" +PINK="[35;40m" +GREEN="[32;40m" +ORANGE="[33;40m" + hg_dirty() { hg status --no-color 2> /dev/null \ - | awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \ - | sort | uniq | head -c1 -} - -hg_in_repo() { - [[ `hg branch 2> /dev/null` ]] && echo 'on ' + | awk '$1 == "?" { unknown = 1 } + $1 != "?" { changed = 1 } + END { + if (changed) printf "!" + else if (unknown) printf "?" + }' } hg_branch() { - hg branch 2> /dev/null + hg branch 2> /dev/null | \ + awk '{ printf "\033[37;0m on \033[35;40m" $1 }' + hg bookmarks 2> /dev/null | \ + awk '/\*/ { printf "\033[37;0m at \033[33;40m" $2 }' } -COLOR_DEFAULT="[37;40m" -COLOR_PINK="[35;40m" -COLOR_GREEN="[32;40m" -COLOR_ORANGE="[33;40m" +export PS1='\n\e${PINK}\u \ +\e${DEFAULT}at \e${ORANGE}\h \ +\e${DEFAULT}in \e${GREEN}\w\ +$(hg_branch)\e${GREEN}$(hg_dirty)\ +\e${DEFAULT}\n$ ' -export PS1='\n\[\e${COLOR_PINK}\]\u \ -\[\e${COLOR_DEFAULT}\]at \[\e${COLOR_ORANGE}\]\h \ -\[\e${COLOR_DEFAULT}\]in \[\e${COLOR_GREEN}\]\w \ -\[\e${COLOR_DEFAULT}\]$(hg_in_repo)\ -\[\e${COLOR_PINK}\]$(hg_branch)\[\e${COLOR_GREEN}\]$(hg_dirty) \ -\[\e${COLOR_DEFAULT}\]\n$ ' -