blob: 29dfa00f0091692dbd59ba260d7e3f3784167037 [file] [log] [blame]
Karl Swedberg8ac6e442011-02-27 17:54:35 -05001#!/bin/bash
2SCM_THEME_PROMPT_DIRTY=''
3SCM_THEME_PROMPT_CLEAN=''
4SCM_GIT_CHAR='${bold_cyan}±${normal}'
5SCM_SVN_CHAR='${bold_cyan}⑆${normal}'
6SCM_HG_CHAR='${bold_red}☿${normal}'
7SCM_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
28prompt_setter() {
29 # Save history
30 history -a
31 history -c
32 history -r
33 PS1="
Travis Swicegood1638a1a2011-02-28 14:18:46 -060034\t $(scm_char) [\[$THEME_PROMPT_HOST_COLOR\]\u@${THEME_PROMPT_HOST}\[$reset_color\]] \w
Karl Swedberg8ac6e442011-02-27 17:54:35 -050035$(doubletime_scm_prompt)\[$reset_color\] $ "
36 PS2='> '
37 PS4='+ '
38}
39
40PROMPT_COMMAND=prompt_setter
41
42git_prompt_status() {
43
44 if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
45 git_status="${bold_red}$(scm_prompt_info) ✗"
46 elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
47 git_status="${bold_yellow}$(scm_prompt_info) ^"
48 elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
49 git_status="${bold_cyan}$(scm_prompt_info) +"
50 elif [ -n "$(git status | grep 'nothing to commit' 2> /dev/null)" ]; then
51 git_status="${bold_green}$(scm_prompt_info) ${green}✓"
52 else
53 git_status="$(scm_prompt_info)"
54 fi
55 echo "[$git_status${normal}]"
56
57}
58
59# git_prompt_color() {
60#
61# if [ -n "$(git status | grep 'Changes not staged' 2> /dev/null)" ]; then
62# git_status='${bold_red} ✗'
63# elif [ -n "$(git status | grep 'Changes to be committed' 2> /dev/null)" ]; then
64# git_status='${bold_yellow} ^'
65# elif [ -n "$(git status | grep 'Untracked files' 2> /dev/null)" ]; then
66# git_status='${bold_cyan} +'
67# else
68# git_status='${bold_green} ✓'
69# fi
70# echo $git_status
71#
72# }