Shell snippets are below.
    
Paul
    
      function parse_git_branch() {
          git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/*
      \(.*\)/(\1) /'
          
      }
      
      function get_git_color() {
      
          isred=`git status -s 2> /dev/null | egrep "^.[^? ]" | wc |
      awk '{print $1}'`
          isorange=`git status -s 2> /dev/null | egrep "^[^? ]" | wc
      | awk '{print $1}'`
      
          git_prompt_color=32
      
          if [ $isorange -ne 0 ]
          then
          git_prompt_color=33
          fi
          if [ $isred -ne 0 ]
          then
          git_prompt_color=31
          fi
          
          echo "$git_prompt_color"
      }
      
    
# Guide to prompt:
      #  * set the title bar to show the current time (\t) & current
      working directory (\w): "\[\e]0;\t \w\a\]"
      #  * set the prompt to show:
      #      * current user (\u) and host (\h) in green (\[\e[32m\]), 
      #      * working directory (\w) in yellow (\[\[e[33m\]):
      "\[\e[32m\]\u@\h \[\e[33m\]\w 
      #  * add the git branch name to the prompt: $(parse_git_branch)
      #  * set color for git branch name based on status:
      #     * all previously tracked files up-to-date/committed: green
      #     * any previously tracked files NOT added: red
      #     * some previously tracked files added but not committed:
      orange
      export PS1="\[\e]0;\t \w\a\]\[\e[32m\]\u@\h
      \[\e[33m\]\w\[\e[1;\$(get_git_color)m\]
      \$(parse_git_branch)\[\e[0m\]> "
    
-- -- ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ -- Paul Wilson ~ UW-Madison ~ 608-263-0807 ~ cal: http://bit.ly/pphw-cal Associate Professor, Engineering Physics. ~ http://cnerg.engr.wisc.edu Chair, Energy Analysis & Policy Program ~ http://nelson.wisc.edu/eap