blob: 997b3f248ea24e1357d8e3233f45aae8dbd1cf5b [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=""
9RVM_THEME_PROMPT_PREFIX=" ("
10RVM_THEME_PROMPT_SUFFIX=")"
11
Travis Swicegood1638a1a2011-02-28 14:18:46 -060012if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then
13 THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`);
14else
15 THEME_PROMPT_HOST_COLOR="$blue"
16fi
17
Karl Swedberg8ac6e442011-02-27 17:54:35 -050018doubletime_scm_prompt() {
19 CHAR=$(scm_char)
Jeff Carouth6e8733e2011-06-25 10:05:25 -050020 if [ $CHAR = $SCM_NONE_CHAR ]; then
Karl Swedberg8ac6e442011-02-27 17:54:35 -050021 return
Jeff Carouth6e8733e2011-06-25 10:05:25 -050022 elif [ $CHAR = $SCM_GIT_CHAR ]; then
Karl Swedberg8ac6e442011-02-27 17:54:35 -050023 echo "$(git_prompt_status)"
Jeff Carouth6e8733e2011-06-25 10:05:25 -050024 else
25 echo "[$(scm_prompt_info)]"
Karl Swedberg8ac6e442011-02-27 17:54:35 -050026 fi
27}
28
JFSIII1b7c9412011-06-17 19:45:21 -040029function prompt_setter() {
Karl Swedberg8ac6e442011-02-27 17:54:35 -050030 # Save history
31 history -a
32 history -c
33 history -r
Travis Swicegood9623fd42011-05-30 10:12:51 -050034 if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
35 then
36 clock="\t"
37 else
38 clock=$THEME_PROMPT_CLOCK_FORMAT
39 fi
Karl Swedberg8ac6e442011-02-27 17:54:35 -050040 PS1="
JFSIII1b7c9412011-06-17 19:45:21 -040041$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)\w
42$(doubletime_scm_prompt)$reset_color $ "
Karl Swedberg8ac6e442011-02-27 17:54:35 -050043 PS2='> '
44 PS4='+ '
45}
46
47PROMPT_COMMAND=prompt_setter
48
49git_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# }