-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_prompt
83 lines (74 loc) · 2.08 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
font() {
local esc="\033"
case $# in
2)
echo "\[${esc}[${1};5;${2}m\]"
;;
3)
echo "\[${esc}[${2};${1};5;${3}m\]"
;;
4)
echo "\[${esc}[${2};${3};${1};5;${4}m\]"
;;
5)
echo "\[${esc}[${2};${3};${4};${1};5;${5}m\]"
;;
6)
echo "\[${esc}[${2};${3};${4};${5};${1};5;${6}m\]"
;;
*)
echo "\[${esc}[0m\]"
;;
esac
}
set_prompt() {
# Background & Foreground
local bg="48"
local fg="38"
# Colours
local black="16"
local blue="27"
local cyan="51"
local green="46"
local orange="202"
local purple="201"
local red="196"
local white="15"
local yellow="11"
# Controls
local blink_off="25"
local blink_on="5"
local bold="1"
local dim="2"
local inverse_off="27"
local inverse_on="7"
local normal="22"
local reset="0"
local transparent="8"
local underline_off="24"
local underline_on="4"
local cwd="\W"
local date="\d"
local host="\h"
local pwd="\w"
local shell="\s"
local time="\t"
local user="\u"
local files=$(ls -A | wc -l)
local total_size=$(ls -lah | grep -m 1 total | sed 's/total //')
local uptime=$(uptime | awk -F ' up ' '{print $2}' | awk -F ',' '{print $1}' | awk '{$1=$1;print}')
local git_info=$(__git_ps1)
if [[ ${git_info} ]]; then
git_info="$(font ${fg} ${yellow})${git_info}$(font)"
fi
PS1="┌─[$(font ${fg} ${cyan})${cwd}$(font) ${files} files, ${total_size}]"
PS1+="───[${date} ${time} ${uptime}]"
PS1+="───[$(font ${fg} ${yellow})${user}@$(font ${fg} ${yellow})${host}$(font)]"
PS1+="───[$(font ${fg} ${green})${pwd}${git_info}$(font)]"
PS1+="\n└─▶ "
}
GIT_PS1_SHOWUPSTREAM="auto" # '<' behind, '>' ahead, '<>' diverged, '=' no difference
GIT_PS1_SHOWDIRTYSTATE=1 # staged '+', unstaged '*'
GIT_PS1_SHOWSTASHSTATE=1 # '$' something is stashed
GIT_PS1_SHOWUNTRACKEDFILES=1 # '%' untracked files
PROMPT_COMMAND=set_prompt