-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_prompt
69 lines (59 loc) · 1.88 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
force_color_prompt=yes
function bash_prompt {
local return_val=$?;
local history_number=`history | tail -1 | awk '{print $1}'`
local history_length=$(( `echo ${history_number} | wc -c | awk '{print $1}'` - 1))
local lm=""
local rm=""
local code="${EMY}${history_number}${NONE}"
local BGR="\[\033[41m\]"
local EMY="\[\033[1;33m\]"
local EMW="\[\033[1;37m\]"
local Y="\[\033[0;33m\]"
local NONE="\[\033[0m\]"
if (( ${return_val} != 0 )) ; then
local prec=${return_val}
local prec_length=$((`echo ${prec} | wc -c | awk '{print $1}'` - 1))
local margin=$((${history_length} - ${prec_length}))
if (( ${margin} == 1 )) ; then
lm=" "
else
while (( ${margin} > 0 ))
do
lm="${lm} "
if (( ${margin} != 1 )) ; then
rm="${rm} "
fi
margin=$((${margin}-2))
done
fi
code="${EMY}${BGR}${lm}${prec}${rm}${NONE}"
REMIND=1
else
if [[ "${LAST_HISTORY}" == "${history_number}" ]] ; then
margin=$((${history_length} - 1))
if (( ${margin} == 1 )) ; then
lm=" "
else
while (( ${margin} > 0 ))
do
lm="${lm} "
if (( ${margin} != 1 )) ; then
rm="${rm} "
fi
margin=$((${margin}-2))
done
fi
code="${lm}↺${rm}"
fi
if [[ "${REMIND}" == "1" ]] ; then
code="${history_number}"
fi
unset REMIND
fi
LAST_HISTORY=${history_number}
PS1="[${code}]${EMW}\u${NONE}@\h:\W${Y}\$${NONE} "
set ?=${return_val}
}
PROMPT_COMMAND=bash_prompt
export `grep -P '^[^\=:space:]*?\=' $HOME/.bashrc | sed 's/=.*//g' |xargs`