-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bashrc-global
143 lines (121 loc) · 3.52 KB
/
.bashrc-global
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
# .bashrc
# Karol Kozlowski
# colors
rblk="\001\e[0;30m\002" # Black
rred="\001\e[0;31m\002" # Regular Red
rgrn="\001\e[0;32m\002" # Regular Green
rylw="\001\e[0;33m\002" # Regular Yellow
rblu="\001\e[0;34m\002" # Regular Blue
rpur="\001\e[0;35m\002" # Regular Purple
rcyn="\001\e[0;36m\002" # Regular Cyan
rwht="\001\e[0;37m\002" # Regular White
gray="\001\e[1;30m\002" # Gray
lred="\001\e[1;31m\002" # Light Red
lgrn="\001\e[1;32m\002" # Light Green
lylw="\001\e[1;33m\002" # Light Yellow
lblu="\001\e[1;34m\002" # Light Blue
lpur="\001\e[1;35m\002" # Light Purple
lcyn="\001\e[1;36m\002" # Light Cyan
lwht="\001\e[1;37m\002" # Light White
rst="\001\e[m\002" # Text Reset
#lf='\e[0;10m' # Line Feed
#lf=' \n' # Line Feed
lf=' '
# local secrets
[ -r ~/.shellrc-secrets ] && source ~/.shellrc-secrets
# source common
[ -r ~/.shellrc ] && source ~/.shellrc
# local overrides
[ -r ~/.shellrc-local ] && source ~/.shellrc-local
# to enable zsh:
# echo 'export ENABLE_ZSH=${ENABLE_ZSH:-true}' >> ~/.shellrc-local
if [ "${ENABLE_ZSH}" = true ] && test -t 1 && command -v zsh > /dev/null; then
exec zsh
fi
# OS dependant variables
host_color=${rred}
user_color=${lblu}
major_release() {
if [ -f /etc/redhat-release ]; then
sed 's/.*\([0-9]\)\.[0-9].*/\1/' /etc/redhat-release
else
echo -n 0
fi
}
case `uname` in
'Linux')
# on Linux
host_color=${rgrn}
[ $EUID -eq 0 ] && user_color=${rred}
;;
'SunOS')
# on Solaris
host_color=${lylw}
export TERM=xterm
[ $EUID -eq 0 ] && user_color=${rred}
bind -f ~/.inputrc-sol
;;
*)
echo 'What am I?'
;;
esac
export LS_OPTIONS
# set username color in prompt (red if root)
case $(hostname | cut -d"." -f1) in
'localhost')
host_alias="\h(local)"
;;
*)
host_alias="\h"
;;
esac
# Enable bash completion RHEL 6
[ -e /etc/bash_completion ] && . /etc/bash_completion
# Enable bash completion RHEL 7
[ -e /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion
# https://asdf-vm.com/guide/getting-started.html#_3-install-asdf
[ -e $HOME/.asdf/asdf.sh ] && . $HOME/.asdf/asdf.sh
[ -e $HOME/.asdf/completions/asdf.bash ] && . $HOME/.asdf/completions/asdf.bash
if which direnv > /dev/null 2>&1; then
eval "$(direnv hook bash)"
fi
exitstatus() {
if [ $? == 0 ]; then
echo -ne ""
else
echo -ne "${rred}"
fi
}
scm() {
info=""
if [ -d $(git rev-parse --git-dir 2>/dev/null) ]; then
if git config --local --get remote.origin.url >/dev/null 2>/dev/null; then
# GIT
git_color="${lcyn}"
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
elif git config --local --get svn-remote.svn.url >/dev/null 2>/dev/null; then
# GIT-SVN
git_color="${lpur}"
branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
fi
fi
if [ -n "$branch" ]; then
info=" ${info}[${git_color}${branch}${rst}]${rst}"
else
info=" "
fi
echo -ne "$info"
}
# run powerline only on non-ssh shells
if [ "$SSH_CONNECTION" == "" ]; then
if [ -e /usr/share/powerline/bindings/bash/powerline.sh ]; then
# powerline
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bindings/bash/powerline.sh
fi
fi
PS1="${user_color}\\u${rst}@${host_color}${host_alias}${rst} \$(exitstatus)\w${rst}\$(scm)\\$ "
PS2="${lylw}> ${rst}"