-
Notifications
You must be signed in to change notification settings - Fork 3
/
bash_prompt
46 lines (42 loc) · 1.22 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
# vim: set filetype=sh :
jobscount() {
local background=$(jobs | grep -v 'git fetch' | wc -l)
BgGray="5;235";
ResetWithBg="\[\e[0;0;48;${BgGray}m\]"
ResetGreenBg="\[\e[38;${BgGray};48;5;10m\]"
((background)) && echo -n " ${background} ${ResetWithBg}${ResetGreenBg} "
}
# Default prompt
if [[ ${EUID} == 0 ]]; then
PS1='\[\e[01;31m\]\$\[\e[0m\] '
else
PS1='\[\e[0m\]\$ '
fi
# If sshed include hostname
if [[ "$SSH_CLIENT" ]]; then
PS1="\[\e[0;31m\]\h$PS1"
# Set host and pwd in X window title
case ${TERM} in
xterm*|rxvt*|alacritty)
PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}|${PWD/#$HOME/~}\007"'
;;
screen*)
PROMPT_COMMAND='echo -ne "\033_${HOSTNAME}|${PWD/#$HOME/~}\033\\"'
;;
esac
else
# Set pwd in X window title
case ${TERM} in
xterm*|rxvt*|alacritty)
PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
;;
screen*)
PROMPT_COMMAND='echo -ne "\033_${PWD/#$HOME/~}\033\\"'
;;
esac
fi
# Fancy git prompt if installed
if [[ -f $HOME/.bash-git-prompt/gitprompt.sh ]]; then
GIT_PROMPT_ONLY_IN_REPO=0
source $HOME/.bash-git-prompt/gitprompt.sh
fi