blob: b8bcc22616e27c0ff918f049bde74b3d4eba1f06 [file] [log] [blame]
Nils Winkler460382a2013-11-07 14:08:42 +01001#!/bin/bash
2
3# Two line prompt showing the following information:
4# (time) SCM [username@hostname] pwd (SCM branch SCM status)
5# →
6#
7# Example:
8# (14:00:26) ± [foo@bar] ~/.bash_it (master ✓)
9# →
10#
11# The arrow on the second line is showing the exit status of the last command:
12# * Green: 0 exit status
13# * Red: non-zero exit status
14#
15# The exit code functionality currently doesn't work if you are using the 'fasd' plugin,
16# since 'fasd' is messing with the $PROMPT_COMMAND
17
18
19PROMPT_END_CLEAN="${green}→${reset_color}"
20PROMPT_END_DIRTY="${red}→${reset_color}"
21
22function prompt_end() {
23 echo -e "$PROMPT_END"
24}
25
26prompt_setter() {
27 local exit_status=$?
28 if [[ $exit_status -eq 0 ]]; then PROMPT_END=$PROMPT_END_CLEAN
29 else PROMPT_END=$PROMPT_END_DIRTY
30 fi
31 # Save history
32 history -a
33 history -c
34 history -r
35 PS1="(\t) $(scm_char) [${blue}\u${reset_color}@${green}\H${reset_color}] ${yellow}\w${reset_color}$(scm_prompt_info) ${reset_color}\n$(prompt_end) "
36 PS2='> '
37 PS4='+ '
38}
39
40PROMPT_COMMAND=prompt_setter
41
42SCM_THEME_PROMPT_DIRTY=" ${bold_red}✗${normal}"
43SCM_THEME_PROMPT_CLEAN=" ${bold_green}✓${normal}"
44SCM_THEME_PROMPT_PREFIX=" ("
45SCM_THEME_PROMPT_SUFFIX=")"
46RVM_THEME_PROMPT_PREFIX=" ("
47RVM_THEME_PROMPT_SUFFIX=")"