blob: e16ba66c2f550347795f70e2a5da7453b39124d5 [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
Travis Swicegoodba9b5d22011-03-02 23:42:01 -060029virtualenv_prompt() {
30 if [ ! -z "$VIRTUAL_ENV" ]
31 then
32 echo "(`basename $VIRTUAL_ENV`) "
33 fi
34}
35
JFSIII1b7c9412011-06-17 19:45:21 -040036function prompt_setter() {
Karl Swedberg8ac6e442011-02-27 17:54:35 -050037 # Save history
38 history -a
39 history -c
40 history -r
Travis Swicegood9623fd42011-05-30 10:12:51 -050041 if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
42 then
43 clock="\t"
44 else
45 clock=$THEME_PROMPT_CLOCK_FORMAT
46 fi
Karl Swedberg8ac6e442011-02-27 17:54:35 -050047 PS1="
JFSIII1b7c9412011-06-17 19:45:21 -040048$clock $(scm_char) [$THEME_PROMPT_HOST_COLOR\u@${THEME_PROMPT_HOST}$reset_color] $(virtualenv_prompt)\w
49$(doubletime_scm_prompt)$reset_color $ "
Karl Swedberg8ac6e442011-02-27 17:54:35 -050050 PS2='> '
51 PS4='+ '
52}
53
54PROMPT_COMMAND=prompt_setter
55
56git_prompt_status() {
57
58 if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
59 git_status="${bold_red}$(scm_prompt_info) ✗"
60 elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
61 git_status="${bold_yellow}$(scm_prompt_info) ^"
62 elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
63 git_status="${bold_cyan}$(scm_prompt_info) +"
64 elif [ -n "$(git status | grep 'nothing to commit' 2> /dev/null)" ]; then
65 git_status="${bold_green}$(scm_prompt_info) ${green}✓"
66 else
67 git_status="$(scm_prompt_info)"
68 fi
69 echo "[$git_status${normal}]"
70
71}
72
73# git_prompt_color() {
74#
75# if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
76# git_status='${bold_red} ✗'
77# elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
78# git_status='${bold_yellow} ^'
79# elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
80# git_status='${bold_cyan} +'
81# else
82# git_status='${bold_green} ✓'
83# fi
84# echo $git_status
85#
86# }