-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
44 lines (35 loc) · 1.07 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
#!/usr/bin/env bash
# Parse current branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Custom Prompt
PROMPT_COMMAND='custom_prompt'
custom_prompt() {
exit_code=$?
bash_version=$(echo $BASH_VERSION | sed -e 's/\([0-9.]*\)(.*/\1/')
window_title="Bash $bash_version – $(pwd | grep -o '[^/]\+$')"
msg=${debian_chroot:+($debian_chroot)}
if [[ $exit_code -ne 0 ]]; then
msg="\[\e[31m\] ✘ exit $exit_code\[\e[0m\]\n$msg"
fi
reset_colour="\[\e[0m\]"
date="\[\e[32m\][\d \$(date +%k:%M:%S)] "
user="${reset_colour}\u"
at="\[\e[97m\]@"
host="\[\e[36m\]\h "
git="\[\e[32m\]$(parse_git_branch)"
dir="\[\e[33m\]\w${git} \[\e[33m\]❯ "
PS1="${msg}${date}${user}${at}${host}${dir}${reset_colour}"
echo -n -e "\033]0;$window_title\007"
}
# For fun
# if which fortune boxes lolcat &> /dev/null; then
# echo
# fortune -s | boxes -d simple -p a1l3r3 | lolcat -F 0.5
# echo
# fi
# if which figlet lolcat boxes &> /dev/null; then
# figlet -f ogre -w 150 "hello" $USER | boxes -d simple -p a1l3r3
# echo
# fi