blob: c5a8a420f989c846bd1da84a3fbe9721a7e4a4f2 [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
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
Karl Swedberg8ac6e442011-02-27 17:54:35 -050035prompt_setter() {
36 # Save history
37 history -a
38 history -c
39 history -r
40 PS1="
Travis Swicegoodba9b5d22011-03-02 23:42:01 -060041\t $(scm_char) [\[$THEME_PROMPT_HOST_COLOR\]\u@${THEME_PROMPT_HOST}\[$reset_color\]] $(virtualenv_prompt)\w
Karl Swedberg8ac6e442011-02-27 17:54:35 -050042$(doubletime_scm_prompt)\[$reset_color\] $ "
43 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# }