blob: 17def320f558138408c7495eb8406a1c11775212 [file] [log] [blame]
Karl Swedberg8ac6e442011-02-27 17:54:35 -05001#!/bin/bash
2SCM_THEME_PROMPT_DIRTY=''
3SCM_THEME_PROMPT_CLEAN=''
JFSIII1b7c9412011-06-17 19:45:21 -04004SCM_GIT_CHAR="${bold_cyan}±${normal}"
5SCM_SVN_CHAR="${bold_cyan}⑆${normal}"
6SCM_HG_CHAR="${bold_red}☿${normal}"
Karl Swedberg8ac6e442011-02-27 17:54:35 -05007SCM_THEME_PROMPT_PREFIX=""
8SCM_THEME_PROMPT_SUFFIX=""
Travis Swicegood11995c12011-07-23 21:42:48 -05009RVM_THEME_PROMPT_PREFIX="(rb: "
10RVM_THEME_PROMPT_SUFFIX=") "
11VIRTUALENV_THEME_PROMPT_PREFIX="(py: "
12VIRTUALENV_THEME_PROMPT_SUFFIX=") "
Karl Swedberg8ac6e442011-02-27 17:54:35 -050013
Travis Swicegood1638a1a2011-02-28 14:18:46 -060014if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then
15 THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`);
16else
17 THEME_PROMPT_HOST_COLOR="$blue"
18fi
19
Karl Swedberg8ac6e442011-02-27 17:54:35 -050020doubletime_scm_prompt() {
21 CHAR=$(scm_char)
Jeff Carouth6e8733e2011-06-25 10:05:25 -050022 if [ $CHAR = $SCM_NONE_CHAR ]; then
Karl Swedberg8ac6e442011-02-27 17:54:35 -050023 return
Jeff Carouth6e8733e2011-06-25 10:05:25 -050024 elif [ $CHAR = $SCM_GIT_CHAR ]; then
Karl Swedberg8ac6e442011-02-27 17:54:35 -050025 echo "$(git_prompt_status)"
Jeff Carouth6e8733e2011-06-25 10:05:25 -050026 else
27 echo "[$(scm_prompt_info)]"
Karl Swedberg8ac6e442011-02-27 17:54:35 -050028 fi
29}
30
JFSIII1b7c9412011-06-17 19:45:21 -040031function prompt_setter() {
Karl Swedberg8ac6e442011-02-27 17:54:35 -050032 # Save history
33 history -a
34 history -c
35 history -r
Travis Swicegood9623fd42011-05-30 10:12:51 -050036 if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
37 then
38 clock="\t"
39 else
40 clock=$THEME_PROMPT_CLOCK_FORMAT
41 fi
Karl Swedberg8ac6e442011-02-27 17:54:35 -050042 PS1="
Travis Swicegood1251c202011-07-23 21:42:22 -050043$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)$(rvm_version_prompt)\w
JFSIII1b7c9412011-06-17 19:45:21 -040044$(doubletime_scm_prompt)$reset_color $ "
Karl Swedberg8ac6e442011-02-27 17:54:35 -050045 PS2='> '
46 PS4='+ '
47}
48
49PROMPT_COMMAND=prompt_setter
50
51git_prompt_status() {
52
53 if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
54 git_status="${bold_red}$(scm_prompt_info) ✗"
55 elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
56 git_status="${bold_yellow}$(scm_prompt_info) ^"
57 elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
58 git_status="${bold_cyan}$(scm_prompt_info) +"
59 elif [ -n "$(git status | grep 'nothing to commit' 2> /dev/null)" ]; then
60 git_status="${bold_green}$(scm_prompt_info) ${green}✓"
61 else
62 git_status="$(scm_prompt_info)"
63 fi
64 echo "[$git_status${normal}]"
65
66}
67
68# git_prompt_color() {
69#
70# if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
71# git_status='${bold_red} ✗'
72# elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
73# git_status='${bold_yellow} ^'
74# elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
75# git_status='${bold_cyan} +'
76# else
77# git_status='${bold_green} ✓'
78# fi
79# echo $git_status
80#
81# }