-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash_prompt
More file actions
38 lines (32 loc) · 730 Bytes
/
bash_prompt
File metadata and controls
38 lines (32 loc) · 730 Bytes
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
#!/usr/bin/env bash
GREEN="\[\e[32m\]"
BLUE="\[\e[34m\]"
RED="\[\e[31m\]"
YELLOW="\[\e[33m\]"
PURPLE="\[\e[35m\]"
NC="\[\e[0m\]"
function gitBranchInfo {
git branch > /dev/null 2>&1
if test $? -ne 0 ;then
echo "-"
else
echo "$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
fi
return 0
}
function virtualEnv {
test -z $VIRTUAL_ENV && echo "-" || echo $VIRTUAL_ENV | rev | cut -d "/" -f 1,2 | rev
}
function prompt {
if test $? -eq 0 ;then
cs=$GREEN\$$NC
else
cs=$RED\$$NC
fi
mc=$GREEN$(whoami)@$(hostname)
wd=$BLUE$(basename $(pwd))
bi=$PURPLE$(gitBranchInfo)
vi=$YELLOW$(virtualEnv)
PS1="$mc $wd $bi $vi $cs "
}
PROMPT_COMMAND=prompt