-
Notifications
You must be signed in to change notification settings - Fork 0
/
bash_profile
310 lines (264 loc) · 8.29 KB
/
bash_profile
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# One profile to rule them all...and in the terminal bind them.
# Terminal settings, environment variables, and path munging.
# Functions and aliases stored in .bashrc
source $HOME/.bash/environment.sh
source $HOME/.bash/functions.sh
########################################################################
#
# Shell configuration
#
########################################################################
export EDITOR=vim
export VISUAL=vim
export LANG=en_US.UTF-8
stty istrip
stty erase
if [ $MYSHELL == "bash" ]; then
shopt -s checkwinsize
# Fix typos in 'cd'
shopt -s cdspell
# Configure Bash history to ignore commands prefixed with space, and
# duplicates.
export HISTCONTROL=ignoreboth
# Make bash tab completion ignore certain files (like .svn directories)
export FIGNORE=.svn:.pyc:.pyo:~
shopt -u force_fignore
fi
########################################################################
#
# Path munging
#
########################################################################
# time to munge the path... why can't we all just get along?
if [[ -d /sbin ]]; then
pathmunge /sbin
fi
if [[ -d /usr/sbin ]]; then
pathmunge /usr/sbin
fi
if [[ -d /usr/X11R6/bin ]]; then
pathmunge /usr/X11R6/bin after
manpathmunge /usr/X11R6/man
fi
if [[ -d /usr/share/man ]]; then
manpathmunge /usr/share/man
fi
if [[ -d /usr/local/sbin ]]; then
pathmunge /usr/local/sbin
fi
if [[ -d /usr/local/bin ]]; then
pathmunge /usr/local/bin
fi
if [[ -d /usr/local/man ]]; then
manpathmunge /usr/local/man
fi
if [[ -d ~/bin ]]; then
pathmunge ~/bin
fi
case ${MYOS} in
"Solaris")
REV=`uname -r`
echo -e "Solaris $REV -- \c"
# Old Solaris compiler stuff...
if [[ -d /usr/ucb ]]; then
pathmunge /usr/ucb after
fi
if [[ -d /usr/ccs/bin ]]; then
pathmunge /usr/ccs/bin after
fi
platform=`uname -i`;
# platform specific binaries?
if [[ -d /usr/platform/$platform/sbin ]]; then
echo -e "prtdiag, \c"
pathmunge /usr/platform/$platform/sbin after
fi
# rsc ???
if [[ -d /usr/platform/$platform/rsc ]]; then
echo -e "rsc tool, \c"
pathmunge /usr/platform/$platform/rsc after
fi
# veritas crap
if [[ -d /opt/VRTS ]]; then
echo -e "veritas, \c"
pathmunge /opt/VRTS/bin after
manpathmunge /opt/VRTS/man after
fi
# sun C compiler
if [[ -d /opt/SUNWspro/bin ]]; then
echo -e "forte, \c"
pathmunge /opt/SUNWspro/bin after
manpathmunge /opt/SUNWspro/man after
fi
# solaris xwindows. Can you say "cruft"?
if [[ -d /usr/openwin/bin ]]; then
echo -e "openwin, \c"
pathmunge /usr/openwin/bin after
manpathmunge /usr/openwin/man after
fi
# solaris location for GNU software. why solaris, why??
if [[ -d /usr/sfw ]]; then
echo -e "sfw, \c"
pathmunge /usr/sfw/bin
manpathmunge /usr/sfw/man after
fi
;;
# Can't use the 'pathmunge' function on Cygwin. Can only set PATH variable
# in Windows' system properties.
"Cygwin")
REV=`uname -r`
echo -e "Cygwin $REV -- \c"
# Windows Resource Kit installed?
if [[ -d "/cygdrive/c/Program Files/Resource Kit" ]]; then
echo -e "Win Resource kit, \c"
fi
;;
"OSX")
REV=`uname -r`
MY_CPU_ARCH=$(arch)
echo -e "Darwin $REV $MY_CPU_ARCH -- \c"
# Fink installed? If not, you should, it's a decent package manager...
if [[ -d /sw ]]; then
echo -e "Fink, \c"
# This script sets up all Fink required environment stuff.
. /sw/bin/init.sh
fi
# MacPorts installed? Perhaps even better than Fink...
if [[ -d /opt/local ]]; then
echo -e "MacPorts, \c"
pathmunge /opt/local/bin
pathmunge /opt/local/sbin
manpathmunge /opt/local/share/man
fi
# Homebrew installed? Like GNU Stow but better...
if type brew >/dev/null 2>&1; then
if [[ $MY_CPU_ARCH = "arm64" ]]; then
echo -e "Homebrew arm64, \c"
export PATH=/opt/homebrew/bin:$PATH
pathmunge /opt/homebrew/sbin
pathmunge /opt/homebrew/bin
manpathmunge /opt/homebrew/share/man
else
echo -e "Homebrew x86, \c"
pathmunge /usr/local/sbin
pathmunge /usr/local/bin
manpathmunge /usr/local/share/man
fi
fi
;;
*BSD|Linux)
REV=`uname -r`
MYOS_NAME=`uname -s`
echo -e "$MYOS_NAME $REV -- \c"
;;
*)
;;
esac
########################################################################
#
# Pager config
#
########################################################################
if [ -x $(which less) ]; then
PAGER="$(which less) -isR"
else
PAGER="more"
fi
export PAGER
########################################################################
#
# Java / Python / Ruby config
#
########################################################################
## Java
if [[ -x /usr/bin/java ]]; then
JAVA_VERSION=`java -version 2>&1 | head -1 | awk '{print $3}'`
echo -e "Java ${JAVA_VERSION}, \c"
if [ $MYOS == "OSX" ]; then
# OSX keeps it's own set of symlinks that point to the current Java version.
export JAVA_HOME=`/usr/libexec/java_home`
export CLASSPATH=$JAVA_HOME/lib
fi
if [ $MYOS == "Solaris" ]; then
# Solaris packages will install into /usr/java ...
export JAVA_HOME=/usr/java
export CLASSPATH=/usr/java/lib
fi
fi
## Python
if which python >/dev/null 2>&1; then
# Python prints version information from '-V' to STDERR.
PYFULLVERSION=`python -V 2>&1 | awk '{print $2}'`
echo -e "Python $PYFULLVERSION, \c"
# Always use 'Distribute' for virtualenvs.
export VIRTUALENV_USE_DISTRIBUTE=1
# Use my python startup file.
export PYTHONSTARTUP=$HOME/.pythonrc
fi
## Ruby
if which ruby >/dev/null 2>&1; then
# Print which Ruby is in my path.
RUBY_VERSION=`ruby --version 2>&1 | awk '{print $2}'`
echo -e "Ruby $RUBY_VERSION, \c"
fi
########################################################################
#
# OS Specific
#
########################################################################
## Solaris quirks
if [ $MYOS == "Solaris" ]; then
# Find GCC
# Try the obvious place for gcc
if [[ -x /usr/local/bin/gcc ]]; then
export CC=/usr/local/bin/gcc
fi
# Now try the solaris place for gcc...
if [[ -x /usr/sfw/bin/gcc ]]; then
export CC=/usr/sfw/bin/gcc
fi
# Fix Solaris lack of a USER environment variable. May be obsolete...
if [ ! -e ${USER} ]; then
export USER=$LOGNAME
fi
# Let me know if vim is installed
if [[ -x /usr/local/bin/vim ]]; then
echo -e "VIM, \c"
fi
fi
## OS X quirks
if [ $MYOS == "OSX" ]; then
# Use a Solarized color pallete for LSCOLORS.
# Found at: https://github.com/seebi/dircolors-solarized/issues/10
export LSCOLORS=gxfxbEaEBxxEhEhBaDaCaD
# Homebrew on macOS installs Python with a versioned executable. e.g. python3
if [[ -x /usr/local/bin/python3 ]]; then
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3
elif [[ -x /usr/local/bin/python2 ]]; then
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2
else
VIRTUALENVWRAPPER_PYTHON=$(which python)
fi
export VIRTUALENVWRAPPER_PYTHON
fi
## Linux quirks -- placeholder
## Cygwin quirks
if [ $MYOS == "Cygwin" ]; then
umask 022
fi
########################################################################
#
# Environment Specific
#
########################################################################
## Differences for Dev / Testing / Prod environments go here.
########################################################################
#
# Misc
#
########################################################################
# Get our functions and aliases.
if [ -r "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
# Add a new line after we've printed all the stuff about our environment.
echo ""