Karl Swedberg | 8ac6e44 | 2011-02-27 17:54:35 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | SCM_THEME_PROMPT_DIRTY='' |
| 3 | SCM_THEME_PROMPT_CLEAN='' |
| 4 | SCM_GIT_CHAR='${bold_cyan}±${normal}' |
| 5 | SCM_SVN_CHAR='${bold_cyan}⑆${normal}' |
| 6 | SCM_HG_CHAR='${bold_red}☿${normal}' |
| 7 | SCM_THEME_PROMPT_PREFIX="" |
| 8 | SCM_THEME_PROMPT_SUFFIX="" |
| 9 | RVM_THEME_PROMPT_PREFIX=" (" |
| 10 | RVM_THEME_PROMPT_SUFFIX=")" |
| 11 | |
| 12 | doubletime_scm_prompt() { |
| 13 | CHAR=$(scm_char) |
| 14 | if [ $CHAR = $SCM_NONE_CHAR ] |
| 15 | then |
| 16 | return |
| 17 | else |
| 18 | echo "$(git_prompt_status)" |
| 19 | fi |
| 20 | } |
| 21 | |
| 22 | prompt_setter() { |
| 23 | # Save history |
| 24 | history -a |
| 25 | history -c |
| 26 | history -r |
| 27 | PS1=" |
Travis Swicegood | 0c2f309 | 2011-02-28 13:46:22 -0600 | [diff] [blame^] | 28 | \t $(scm_char) [\[$blue\]\u@${THEME_PROMPT_HOST}\[$reset_color\]] \w |
Karl Swedberg | 8ac6e44 | 2011-02-27 17:54:35 -0500 | [diff] [blame] | 29 | $(doubletime_scm_prompt)\[$reset_color\] $ " |
| 30 | PS2='> ' |
| 31 | PS4='+ ' |
| 32 | } |
| 33 | |
| 34 | PROMPT_COMMAND=prompt_setter |
| 35 | |
| 36 | git_prompt_status() { |
| 37 | |
| 38 | if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then |
| 39 | git_status="${bold_red}$(scm_prompt_info) ✗" |
| 40 | elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then |
| 41 | git_status="${bold_yellow}$(scm_prompt_info) ^" |
| 42 | elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then |
| 43 | git_status="${bold_cyan}$(scm_prompt_info) +" |
| 44 | elif [ -n "$(git status | grep 'nothing to commit' 2> /dev/null)" ]; then |
| 45 | git_status="${bold_green}$(scm_prompt_info) ${green}✓" |
| 46 | else |
| 47 | git_status="$(scm_prompt_info)" |
| 48 | fi |
| 49 | echo "[$git_status${normal}]" |
| 50 | |
| 51 | } |
| 52 | |
| 53 | # git_prompt_color() { |
| 54 | # |
| 55 | # if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then |
| 56 | # git_status='${bold_red} ✗' |
| 57 | # elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then |
| 58 | # git_status='${bold_yellow} ^' |
| 59 | # elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then |
| 60 | # git_status='${bold_cyan} +' |
| 61 | # else |
| 62 | # git_status='${bold_green} ✓' |
| 63 | # fi |
| 64 | # echo $git_status |
| 65 | # |
| 66 | # } |