blob: c3bf453d1fc67258798507a9bb5d2acce880031f [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 Swicegood41ca5672011-07-23 21:48:07 -05009if [ ! -z $RVM_THEME_PROMPT_COLOR ]; then
10 RVM_THEME_PROMPT_COLOR=$(eval echo $`echo ${RVM_THEME_PROMPT_COLOR}`);
11else
12 RVM_THEME_PROMPT_COLOR="${red}"
13fi
14RVM_THEME_PROMPT_PREFIX="(${RVM_THEME_PROMPT_COLOR}rb${normal}: "
Travis Swicegood11995c12011-07-23 21:42:48 -050015RVM_THEME_PROMPT_SUFFIX=") "
Travis Swicegood41ca5672011-07-23 21:48:07 -050016if [ ! -z $VIRTUALENV_THEME_PROMPT_COLOR ]; then
17 VIRTUALENV_THEME_PROMPT_COLOR=$(eval echo $`echo ${VIRTUALENV_THEME_PROMPT_COLOR}`);
18else
19 VIRTUALENV_THEME_PROMPT_COLOR="${green}"
20fi
21VIRTUALENV_THEME_PROMPT_PREFIX="(${VIRTUALENV_THEME_PROMPT_COLOR}py${normal}: "
Travis Swicegood11995c12011-07-23 21:42:48 -050022VIRTUALENV_THEME_PROMPT_SUFFIX=") "
Karl Swedberg8ac6e442011-02-27 17:54:35 -050023
Travis Swicegood1638a1a2011-02-28 14:18:46 -060024if [ ! -z $THEME_PROMPT_HOST_COLOR ]; then
25 THEME_PROMPT_HOST_COLOR=$(eval echo $`echo ${THEME_PROMPT_HOST_COLOR}`);
26else
27 THEME_PROMPT_HOST_COLOR="$blue"
28fi
29
Karl Swedberg8ac6e442011-02-27 17:54:35 -050030doubletime_scm_prompt() {
31 CHAR=$(scm_char)
Jeff Carouth6e8733e2011-06-25 10:05:25 -050032 if [ $CHAR = $SCM_NONE_CHAR ]; then
Karl Swedberg8ac6e442011-02-27 17:54:35 -050033 return
Jeff Carouth6e8733e2011-06-25 10:05:25 -050034 elif [ $CHAR = $SCM_GIT_CHAR ]; then
Karl Swedberg8ac6e442011-02-27 17:54:35 -050035 echo "$(git_prompt_status)"
Jeff Carouth6e8733e2011-06-25 10:05:25 -050036 else
37 echo "[$(scm_prompt_info)]"
Karl Swedberg8ac6e442011-02-27 17:54:35 -050038 fi
39}
40
JFSIII1b7c9412011-06-17 19:45:21 -040041function prompt_setter() {
Karl Swedberg8ac6e442011-02-27 17:54:35 -050042 # Save history
43 history -a
44 history -c
45 history -r
Travis Swicegood9623fd42011-05-30 10:12:51 -050046 if [[ -z "$THEME_PROMPT_CLOCK_FORMAT" ]]
47 then
48 clock="\t"
49 else
50 clock=$THEME_PROMPT_CLOCK_FORMAT
51 fi
Karl Swedberg8ac6e442011-02-27 17:54:35 -050052 PS1="
Travis Swicegood1251c202011-07-23 21:42:22 -050053$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 -040054$(doubletime_scm_prompt)$reset_color $ "
Karl Swedberg8ac6e442011-02-27 17:54:35 -050055 PS2='> '
56 PS4='+ '
57}
58
59PROMPT_COMMAND=prompt_setter
60
61git_prompt_status() {
62
63 if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
64 git_status="${bold_red}$(scm_prompt_info) ✗"
65 elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
66 git_status="${bold_yellow}$(scm_prompt_info) ^"
67 elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
68 git_status="${bold_cyan}$(scm_prompt_info) +"
69 elif [ -n "$(git status | grep 'nothing to commit' 2> /dev/null)" ]; then
70 git_status="${bold_green}$(scm_prompt_info) ${green}✓"
71 else
72 git_status="$(scm_prompt_info)"
73 fi
74 echo "[$git_status${normal}]"
75
76}
77
78# git_prompt_color() {
79#
80# if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
81# git_status='${bold_red} ✗'
82# elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
83# git_status='${bold_yellow} ^'
84# elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
85# git_status='${bold_cyan} +'
86# else
87# git_status='${bold_green} ✓'
88# fi
89# echo $git_status
90#
91# }