-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
47 lines (42 loc) · 1.44 KB
/
.bash_prompt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Based on work by woods https://gist.github.com/31967
# The various escape codes that we can use to color our prompt.
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[0;31m\]"
LIGHT_GREEN="\[\033[0;32m\]"
WHITE="\[\033[0;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
# Return the prompt symbol to use, colorized based on the return value of the
# previous command.
function set_prompt_symbol () {
if test $1 -eq 0 ; then
PROMPT_SYMBOL="${GREEN}\u${COLOR_NONE}"
else
PROMPT_SYMBOL="${RED}\u${COLOR_NONE}"
fi
}
# Determine active Python virtualenv details.
function _set_env () {
if [[ $TERM == "screen" ]]; then
SCREEN="$(echo $STY | cut -d "." -f 2)"
DIR_ENV="${RED}[screen: $SCREEN] "
else
if test -z "$VIRTUAL_ENV" ; then
DIR_ENV=""
else
DIR_ENV="${BLUE}[`basename \"$VIRTUAL_ENV\"`]${COLOR_NONE} "
fi
fi
}
function _ruby_version() {
echo "$(tput setaf 0)[$(ruby --version | cut -d' ' -f1,2)]" # use to be 8
}
# Tell bash to execute this function just before displaying its prompt.
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWCOLORHINTS=1
GIT_PS1_SHOWUPSTREAM="auto"
export PROMPT_COMMAND='set_prompt_symbol $?; _set_env; history -a; __git_ps1 "${PROMPT_SYMBOL} ${COLOR_NONE}in ${DIR_ENV}$(tput setaf 05)\h: ${BLUE}\w${COLOR_NONE}" " $(_ruby_version)${COLOR_NONE} \n$ "'