-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbash_functions
53 lines (48 loc) · 1.25 KB
/
bash_functions
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
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\033[0;32m\]'
c_path='\[\e[0;33m\]'
c_git_clean='\[\e[0;36m\]'
c_git_dirty='\[\e[0;35m\]'
else
c_reset=
c_user=
c_path=
c_git_clean=
c_git_dirty=
fi
# Thy holy prompt.
type __git_ps1 >/dev/null 2>&1
export HAVE_GIT_PS1=$([[ $? -eq 0 ]] && echo 1 || echo 0)
set_ps1()
{
if [[ ${VIM:+set} ]]; then
vim="VIM-"
fi
if [ ${HAVE_GIT_PS1:-0} -eq 1 ]; then
git=$(__git_ps1 " (%s)")
#if [[ "$git" =~ [^-_.a-zA-Z0-9]\) ]]; then
#fi
fi
if [ $USER = "root" ]; then
c_user='\[\033[0;31m\]'
prompt='#'
else
c_user='\[\033[0;32m\]'
prompt='>'
fi
# PS1="\[\033[1;34m\]\u@\h:\w$\[\033[0m\] "
if [[ $PWD =~ src/[^/]* || $PWD =~ personal/[^/]* ]]; then
c_path='\[\e[0;31m\]'
elif [[ $PWD =~ src/[^/]* || $PWD =~ personal/[^/]* ]]; then
c_path='\[\e[0;35m\]'
elif [[ $PWD =~ src/[^/]*t.st || $PWD =~ personal/[^/]*t.st ]]; then
c_path='\[\e[0;36m\]'
else
c_path='\[\e[0;37m\]'
fi
echo "${vim}${c_user}\u${c_reset}:${c_path}\w${c_reset}${git}${prompt} "
}
export PROMPT_COMMAND='PS1="$(set_ps1)"'
##export PROMPT_COMMAND='PS1="${c_user}\h${c_reset}:${c_path}\w${c_reset}$(set_ps1)\$ "'