-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
40 lines (33 loc) · 1.03 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
default_username='kalema'
PURPLE="\[\e[33;35m\]"
YELLOW="\[\e[33;40m\]"
RED="\[\e[31;40m\]"
GREEN="\[\e[32;40m\]"
BLUE="\[\e[34;40m\]"
CYAN="\[\e[34;36m\]"
RESET="\[\e[0m\]"
NONEP="\[\e[38;40m\]"
git_info() {
# check if we're in a git repo
git rev-parse --is-inside-work-tree &>/dev/null || return
# quickest check for what branch we're on
branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
# check if it's dirty (via github.com/sindresorhus/pure)
dirty=$(git diff --quiet --ignore-submodules HEAD &>/dev/null; [ $? -eq 1 ]&& echo -e "*")
echo $WHITE" "$GREEN$branch$RED$dirty
}
usernamehost() {
if [ "$USER" != "$default_username" ]; then echo "${BLUE}[$USER at $HOSTNAME]"; fi
}
prompt_func() {
previous_return_value=$?;
prompt="\n$(usernamehost) ${CYAN}\w$(git_info) "
# did the last request return an error
if test $previous_return_value -eq 0
then
PS1="${prompt}${YELLOW}➔ ${RESET}"
else
PS1="${prompt}${RED}➔ ${RESET}"
fi
}
PROMPT_COMMAND=prompt_func