-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
43 lines (33 loc) · 1.04 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
# CUSTOM PROMPT
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
# disable the default virtualenv prompt change
export VIRTUAL_ENV_DISABLE_PROMPT=1
# Display active Python virtualenv details.
virtualenv_path() {
if test -z "$VIRTUAL_ENV" ; then
printf ""
else
printf "($VIRTUAL_ENV) "
fi
}
# Optional newline
# Insert a newline before the line with virtualenv and git info, iff the line is present
optional_prompt_newline() {
if [ -z "$VIRTUAL_ENV" ] && [ -z "$(parse_git_branch)" ]; then
printf ""
else
printf "\n"
fi
}
show_current_time() {
echo -n "[$(date +%H:%M:%S)]"
}
# Set the full bash prompt.
set_bash_prompt() {
optional_prompt_newline
PS1="$(optional_prompt_newline)\[\033[95m\]$(virtualenv_path)\[\033[93m\]$(parse_git_branch)\[\033[00m\] \n$(show_current_time) \[\033[96m\]\u \[\033[92m\]\w \[\033[97m\]\n$\[\033[0m\] "
}
# Tell bash to execute this function just before displaying its prompt.
PROMPT_COMMAND=set_bash_prompt