forked from BlackIkeEagle/bashrc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbash.bashrc.local
More file actions
229 lines (200 loc) · 6.17 KB
/
bash.bashrc.local
File metadata and controls
229 lines (200 loc) · 6.17 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#
# /etc/bash.bashrc.local
#
# add .bin to path if found in home
[ -d ~/.bin ] && PATH=$PATH:~/.bin
#add local composer bin
[ -d ~/.composer/vendor/bin/ ] && PATH=$PATH:~/.composer/vendor/bin/
[ -d ~/.config/composer/vendor/bin/ ] && PATH=$PATH:~/.config/composer/vendor/bin/
# If not running interactively, stop here
[[ $- != *i* ]] && return
# Command history.
export HISTIGNORE="&:ls:[bf]g:exit:reset:clear:cd*";
export HISTSIZE=4096;
export HISTIGNORE="&:ls:exit:reset:clear"
export HISTCONTROL="ignoreboth:erasedups"
shopt -s histreedit;
# File manipulation.
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:';
if ls --version > /dev/null 2>&1; then
alias ls='ls --color=auto'; #gnu
else
alias ls='ls -G'; #osx
fi
alias grep='grep --color';
alias cd..='cd ..';
[ -x /usr/bin/pacman-color ] && alias pacman='pacman-color';
export EDITOR=vim;
#some extra's
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Text Styling :)
COLBLK='30m'
COLRED='31m'
COLGRN='32m'
COLYLW='33m'
COLBLU='34m'
COLPUR='35m'
COLCYN='36m'
COLWHT='37m'
REG='\033[0;'
BLD='\033[1;'
UND='\033[4;'
BGBLK='\033[40;'
BGRED='\033[41;'
BGGRN='\033[42;'
BGYLW='\033[43;'
BGBLU='\033[44;'
BGPUR='\033[45;'
BGCYN='\033[46;'
BGWHT='\033[47;'
TXRES='\033[0m'
function smiley {
local res=$?
if [ "$res" == "0" ]; then
SMCOL=${BLD}${COLGRN}
SMILE=":-)"
else
SMCOL=${BLD}${COLRED}
SMILE=":'("
fi
echo -ne ${SMCOL}${SMILE}
return $res
}
function scmbranch {
local res=$?
if which git > /dev/null 2>&1; then
git symbolic-ref HEAD > /dev/null 2>&1
if [ $? -eq 0 ]; then
GITBRANCH=$(git symbolic-ref HEAD 2>/dev/null)
GITBRANCH=${GITBRANCH##*/}
if [ ${GITBRANCH} == "master" ]; then
GITBRANCH="${REG}${COLGRN}--${GITBRANCH}${TXRES}${BLD}${COLYLW}-git"
elif [ ${GITBRANCH} == "hotfix" ]; then
GITBRANCH="${REG}${COLRED}--${GITBRANCH}${TXRES}${BLD}${COLYLW}-git"
else
GITBRANCH="${REG}${COLBLU}--${GITBRANCH}${TXRES}${BLD}${COLYLW}-git"
fi
echo -ne ${GITBRANCH}
fi
fi
if which hg > /dev/null 2>&1; then
hg branch > /dev/null 2>&1
if [ $? -eq 0 ]; then
HGBRANCH=$(hg branch 2>/dev/null)
if [ ${HGBRANCH} == "default" ]; then
HGBRANCH="${REG}${COLGRN}--${HGBRANCH}${TXRES}${BLD}${COLYLW}-hg"
else
HGBRANCH="${REG}${COLGRN}--${HGBRANCH}${TXRES}${BLD}${COLYLW}-hg"
fi
echo -ne ${HGBRANCH}
fi
fi
if which svn > /dev/null 2>&1; then
svn info > /dev/null 2>&1
if [ $? -eq 0 ]; then
SVNBRANCH=$(svn info | sed -ne 's/^URL: //p')
SVNBRANCHROOT=$(svn info | sed -ne 's/^Repository Root: //p')
SVNTAG=${SVNBRANCH//$SVNBRANCHROOT}
if [ -z "$SVNTAG" ] || [ ${SVNTAG} == "" ]; then
SVNTAG="/trunk"
fi
if [ ${SVNTAG} == "/trunk" ]; then
SVNBRANCH="${REG}${COLGRN}--${SVNTAG}${TXRES}${BLD}${COLYLW}-svn"
else
SVNBRANCH="${REG}${COLRED}--${SVNTAG}${TXRES}${BLD}${COLYLW}-svn"
fi
echo -ne ${SVNBRANCH}
fi
fi
return $res
}
function fldcol {
local res=$?
if [ `id -u` != "0" ]; then
if [[ $PWD =~ \/Sites ]]; then
FLDCOL=${BLD}${COLBLK}${UND}${COLYLW};
elif [[ $PWD =~ \/projects ]]; then
FLDCOL=${BLD}${COLBLK}${UND}${COLBLU}
elif [[ $PWD =~ \/PROD ]]; then
FLDCOL=${BLD}${COLBLK}${UND}${COLPUR}
fi
fi
if [ "${FLDCOL}" = "" ]; then
if [[ $PWD =~ ^\/etc ]]; then
FLDCOL=${BLD}${COLBLK}${UND}${COLRED}
elif [[ $PWD =~ ^\/var/log ]]; then
FLDCOL=${BLD}${COLBLK}${UND}${COLRED}
else
FLDCOL=${BLD}${COLCYN};
fi
fi
echo -ne ${FLDCOL}
return $res
}
# configure prompt
if [ `id -u` != "0" ]; then
PSCOL=${REG}${COLYLW};
USRCOL=${BLD}${COLYLW};
else
PSCOL=${REG}${COLRED};
USRCOL=${BLD}${COLRED};
fi
# configure host coloring
#switch
if which hostname > /dev/null 2>&1; then
#hostname util exists
hostname=$(hostname)
else
#linux if hostname util does not exist
hostname=$(cat /proc/sys/kernel/hostname)
fi
case $hostname in
localhost)
HSTCOL=${BLD}${COLBLK}${BGRED}${COLWHT}
;;
*.testing)
HSTCOL=${BLD}${COLBLK}${BGRED}${COLYLW}
;;
*.staging)
HSTCOL=${BLD}${COLGRN}
;;
*.production)
HSTCOL=${BLD}${COLCYN}
;;
*)
HSTCOL=${PSCOL}
;;
esac
# configure session coloring
if [ "$TERM" = "screen" ]; then
SESSCOL=${BLD}${COLCYN}
elif [ "$SSH_CLIENT" != "" ]; then
SESSCOL=${BLD}${COLRED}
else
SESSCOL=${PSCOL}
fi
PS1="\[${PSCOL}\]┌─┤\$(smiley)\[${TXRES}\]\[${PSCOL}\]├─┤\[${TXRES}\]\[${SESSCOL}\]\t\[${TXRES}\]\[${PSCOL}\]├─┤\[${USRCOL}\]\u\[${TXRES}\]\[${PSCOL}\] @ \[${TXRES}\]\[${HSTCOL}\]\h\[${TXRES}\]\[${PSCOL}\]├─┤\$(fldcol)\w\[${TXRES}\]\$(scmbranch)\[${TXRES}\]\[${PSCOL}\]├─╼\n└╼\[${TXRES}\] "
PS2="\[${PSCOL}\]╶╼\[${TXRES}\] "
PS3="\[${PSCOL}\]╶╼\[${TXRES}\] "
PS4="\[${PSCOL}\]╶╼\[${TXRES}\] "
export PS1 PS2 PS3 PS4