-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bash_prompt
112 lines (96 loc) · 2.86 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# define the prompt depending on some variables:
# one line function to safely source files
function sourceit(){ [ -r "$1" ] && [ -f "$1" ] && source "$1"; }
sourceit $HOME/.functions
# see https://github.com/mathiasbynens/dotfiles/blob/master/.bash_prompt
bold='';
reset="\e[m";
black="\e[1;30m";
darkgrey="\e[30;1m"
red="\e[1;31m";
darkred="\e[0;31m";
green="\e[1;32m";
darkgreen="\e[0;32m";
yellow="\e[1;33m";
brown="\e[0;33m"
blue="\e[1;34m";
darkblue="\e[0;34m";
purple="\e[1;35m";
violet="\e[0;35m";
cyan="\e[1;36m";
teal="\e[0;36m";
white="\e[1;37m";
lightgrey="\e[0;37m";
# set display of user information
if [[ "${USER}" == "root" ]]; then
user="<root>";
else
user=${USER};
fi;
# color clue about host
# set hostColor to a color name in ~/.local_bashrc depending on hostname
if [ -n ${!hostColor} ]; then
HC=${!hostColor}
else
echo "Color for host not defined: ${hostColor}"
HC=${white}
fi
# color clue about user
# set userColor to a color name in ~/.local_bashrc
if [ -n ${!userColor} ]; then
UC=${!userColor}
else
echo "Color for user not defined: ${hostColor}"
UC=${blue}
fi
# however, root is always red
if [[ "${USER}" == "root" ]]; then
UC=${red};
fi
# color clue about filesystem (usually the physcal location)
# set fsColor to a color name in ~/.local_bashrc
if [ -n ${!fsColor} ]; then
color=${!fsColor}
else
echo "Color for file system not defined: ${fsColor}"
color=${white}
fi
divs=${lightgrey}
repo=${yellow}
modified=${red}
staged=${darkgreen}
# conda virtual environemnt name can be displayed in the prompt. Normally, this
# happen automatically and is prepended at the very beginning. To have control,
# add 'changeps1: False' to $HOME/.condarc (not managed by this repo) and
# set SHOW_CONDA_ENV=1
SHOW_CONDA_ENV=1
# git info can be switched on setting variable $SHOW_GIT to 1
# might slow down the creation of the prompt
SHOW_GIT=1
GIT_INFO=""
if [[ $SHOW_GIT == 1 ]]; then
GIT_INFO+="-(\[${color}\]"; # set starting color
GIT_INFO+="\[${repo}\]\$(__git_ps1)"; # white git branch
GIT_INFO+="\[${divs}\]:";
GIT_INFO+="\[${staged}\]\$(__git_staged)"; # num of staged files
GIT_INFO+="\[${divs}\],";
GIT_INFO+="\[${modified}\]\$(__git_modified)"; # num of modified files
GIT_INFO+="\[${divs}\])";
fi
USER_INFO=""
USER_INFO+="\[${UC}\]"; # set starting color
USER_INFO+="\u"; # user
PS1="\[${divs}\]┌─("; # line linker
PS1+="${USER_INFO}";
PS1+="\[${divs}\]@";
PS1+="\[${HC}\]"; # set host color
PS1+="\h"; # hostname
PS1+="\[${divs}\])-("; # working directory
PS1+="\[${color}\]"; # set starting color
PS1+="\w"; # working directory
PS1+="\[${divs}\])"; # working directory
PS1+=$GIT_INFO;
PS1+="\n"; # newline
PS1+="\[${divs}\]└\[${color}\]\$ \[${reset}\]"; # line linker, conda_env, $, space and reset color
# PS1+="\[${divs}\]└\[${color}\]$(__conda_env)\$ \[${reset}\]"; # line linker, conda_env, $, space and reset color
export PS1;