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 | |
Travis Swicegood | 1638a1a | 2011-02-28 14:18:46 -0600 | [diff] [blame] | 12 | if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then |
| 13 | THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`); |
| 14 | else |
| 15 | THEME_PROMPT_HOST_COLOR="$blue" |
| 16 | fi |
| 17 | |
Karl Swedberg | 8ac6e44 | 2011-02-27 17:54:35 -0500 | [diff] [blame] | 18 | doubletime_scm_prompt() { |
| 19 | CHAR=$(scm_char) |
| 20 | if [ $CHAR = $SCM_NONE_CHAR ] |
| 21 | then |
| 22 | return |
| 23 | else |
| 24 | echo "$(git_prompt_status)" |
| 25 | fi |
| 26 | } |
| 27 | |
Travis Swicegood | ba9b5d2 | 2011-03-02 23:42:01 -0600 | [diff] [blame] | 28 | virtualenv_prompt() { |
| 29 | if [ ! -z "$VIRTUAL_ENV" ] |
| 30 | then |
| 31 | echo "(`basename $VIRTUAL_ENV`) " |
| 32 | fi |
| 33 | } |
| 34 | |
Karl Swedberg | 8ac6e44 | 2011-02-27 17:54:35 -0500 | [diff] [blame] | 35 | prompt_setter() { |
| 36 | # Save history |
| 37 | history -a |
| 38 | history -c |
| 39 | history -r |
| 40 | PS1=" |
Travis Swicegood | ba9b5d2 | 2011-03-02 23:42:01 -0600 | [diff] [blame] | 41 | \t $(scm_char) [\[$THEME_PROMPT_HOST_COLOR\]\u@${THEME_PROMPT_HOST}\[$reset_color\]] $(virtualenv_prompt)\w |
Karl Swedberg | 8ac6e44 | 2011-02-27 17:54:35 -0500 | [diff] [blame] | 42 | $(doubletime_scm_prompt)\[$reset_color\] $ " |
| 43 | PS2='> ' |
| 44 | PS4='+ ' |
| 45 | } |
| 46 | |
| 47 | PROMPT_COMMAND=prompt_setter |
| 48 | |
| 49 | git_prompt_status() { |
| 50 | |
| 51 | if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then |
| 52 | git_status="${bold_red}$(scm_prompt_info) ✗" |
| 53 | elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then |
| 54 | git_status="${bold_yellow}$(scm_prompt_info) ^" |
| 55 | elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then |
| 56 | git_status="${bold_cyan}$(scm_prompt_info) +" |
| 57 | elif [ -n "$(git status | grep 'nothing to commit' 2> /dev/null)" ]; then |
| 58 | git_status="${bold_green}$(scm_prompt_info) ${green}✓" |
| 59 | else |
| 60 | git_status="$(scm_prompt_info)" |
| 61 | fi |
| 62 | echo "[$git_status${normal}]" |
| 63 | |
| 64 | } |
| 65 | |
| 66 | # git_prompt_color() { |
| 67 | # |
| 68 | # if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then |
| 69 | # git_status='${bold_red} ✗' |
| 70 | # elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then |
| 71 | # git_status='${bold_yellow} ^' |
| 72 | # elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then |
| 73 | # git_status='${bold_cyan} +' |
| 74 | # else |
| 75 | # git_status='${bold_green} ✓' |
| 76 | # fi |
| 77 | # echo $git_status |
| 78 | # |
| 79 | # } |