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