-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile
338 lines (321 loc) · 8.83 KB
/
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
#!/usr/bin/false This file is meant to be sourced
# ========================================================================
# Copyright (c) 1994-2018 T. R. Burghart.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ========================================================================
#
# .profile - Shell startup script for Bourne-ish login shells
#
# Refer to files in https://github.com/tburghart/local_env
#
# Install to $HOME/.profile
#
shome="$HOME"
stype="$(uname -s)"
mtype="$(uname -m)"
usern="${LOGNAME:-${USER:-$(id -un)}}"
if [[ -n "$__sh_sh" ]]
then
shell="$__sh_sh"
else
shell="${0#-}"
shell="${shell##*/}"
if [[ "$shell" != *sh && -n "$SHELL" ]]
then
shell="${SHELL##*/}"
fi
fi
unset_vars='shell shome stype mtype usern'
# Hopefully we'll pick this up from /etc/profile having been sourced.
if [ -z "$__sh_which" ]
then
#
# Order shell tests to check for those that may be emulating others before
# checking for those that may be emulated by them.
#
if [[ -n "$ZSH_VERSION" ]]
then
__sh_which='whence -p'
elif [[ -n "$BASH_VERSION" ]]
then
__sh_which='type -P'
elif [[ -n "$KSH_VERSION" ]]
then
__sh_which='whence -p'
#
# See if we're in a shell that has a suitable builtin to use as 'which'.
# Use 'mkdir' as our test target, since it's almost certainly an actual
# executable file on the $PATH.
#
elif whence -p mkdir 1>/dev/null 2>&1 \
&& [ `whence -p mkdir 2>&1` = */mkdir ]
then
__sh_which='whence -p'
elif type -P mkdir 1>/dev/null 2>&1 \
&& [ `type -P mkdir 2>&1` = */mkdir ]
then
__sh_which='type -P'
else
__sh_which='which'
fi
fi
otp_check='/opt/erlang /opt/local /usr/local/erlang /usr/local'
unset_vars="$unset_vars otp_check"
if [[ -d "$HOME/prj/wday" ]]
then
WDAY_PRJ_BASE="$HOME/prj/wday"
export WDAY_PRJ_BASE
otp_check+=" $WDAY_PRJ_BASE/local"
fi
if [[ -d "$HOME/prj/r3r" ]]
then
R3R_PRJ_BASE="$HOME/prj/r3r"
export R3R_PRJ_BASE
fi
if [[ -d "$HOME/prj/basho" ]]
then
BASHO_PRJ_BASE="$HOME/prj/basho"
export BASHO_PRJ_BASE
otp_check+=" $BASHO_PRJ_BASE/local"
fi
if [[ -d "$HOME/prj/tedb" ]]
then
TRB_PRJ_BASE="$HOME/prj/tedb"
export TRB_PRJ_BASE
otp_check+=" $TRB_PRJ_BASE/local"
if [[ -d "$TRB_PRJ_BASE/local_env" ]]
then
ledir="$TRB_PRJ_BASE/local_env"
unset_vars="$unset_vars ledir"
LOCAL_ENV_DIR="$ledir/env"
export LOCAL_ENV_DIR
fi
fi
for LOCAL_OTP_DIR in $otp_check $HOME/local
do
[[ ! -d "$LOCAL_OTP_DIR" || ! -w "$LOCAL_OTP_DIR" ]] || break
done
export LOCAL_OTP_DIR
pathbeg="$ledir /usr/local /opt/local"
pathadd=''
if [[ "$stype" == 'SunOS' ]]
then
pathbeg="$pathbeg /usr/gnu /usr/xpg6 /usr/xpg4"
pathadd="$pathadd /usr/ucb"
fi
pathbeg="$pathbeg /usr /opt"
pathend='/usr/local/cuda /usr/local/mysql'
bpath=''
spath=''
unset_vars="$unset_vars pathbeg pathend pathadd bpath spath"
if [[ "$stype" == 'Darwin' && "$(sw_vers -productName)" == 'Mac OS X' ]]
then
gui='OSX'
if [[ -d "$HOME/bin/OsX" ]]
then
bpath="${bpath:+${bpath}:}$HOME/bin/OsX"
fi
if [[ -d "${HOME}/sbin/OsX" ]]
then
spath="${spath:+${spath}:}$HOME/sbin/OsX"
fi
else
pathend="/usr/X11R7 /usr/X11R6 $pathend"
pathadd="$pathadd /usr/bin/X11R7 /usr/bin/X11R6 /usr/bin/X11"
fi
unset_vars="$unset_vars gui"
for d in "/$stype/$mtype" "/$stype" ''
do
if [[ -d "$HOME/bin${d}" ]]
then
bpath="${bpath:+${bpath}:}${HOME}/bin${d}"
fi
if [[ -d "$HOME/sbin${d}" ]]
then
spath="${spath:+${spath}:}${HOME}/sbin${d}"
fi
done
unset_vars="$unset_vars d"
for d in $pathbeg ${PATH//:/ } / $pathend
do
case "$d" in
/ )
b='/bin'
s='/sbin'
;;
*/bin )
b="$d"
s=''
;;
*/sbin )
b=''
s="$d"
;;
* )
b="$d/bin"
s="$d/sbin"
;;
esac
if [[ -n "$b" && -d "$b" ]] && ! [[ "$bpath" =~ ^(.*:)?$b(:.*)?$ ]]
then
bpath="${bpath:+${bpath}:}$b"
fi
if [[ -n "$s" && -d "$s" ]] && ! [[ "$spath" =~ ^(.*:)?$s(:.*)?$ ]]
then
spath="${spath:+${spath}:}$s"
fi
done
unset_vars="$unset_vars b s"
#
# handle explicit paths
#
for d in $pathadd
do
if [[ -d "$d" ]] && ! [[ "$bpath" =~ ^(.*:)?$d(:.*)?$ ]]
then
bpath="${bpath:+${bpath}:}$d"
fi
done
PATH="$bpath:$spath"
export PATH
[[ -n "$LANG" ]] || LANG='C'
if [[ -z "$ECP" ]]
then
if [[ "$stype" == 'Darwin' ]]
then
ECP='/bin/cp -pX'
else
ECP='/bin/cp -p'
fi
fi
[[ -n "$EGREP" ]] || EGREP="$($__sh_which grep 2>/dev/null || echo grep) -E"
[[ -n "$ESED" ]] || ESED="$($__sh_which sed 2>/dev/null || echo sed) -E"
[[ -n "$GIT" ]] || GIT="$($__sh_which git 2>/dev/null || echo git)"
if [[ -z "$MAKE" ]]
then
case "$stype" in
Darwin|Linux)
MAKE="$($__sh_which /usr/bin/make 2>/dev/null \
|| $__sh_which make 2>/dev/null \
|| $__sh_which gmake 2>/dev/null || echo make)"
;;
*)
MAKE="$($__sh_which gmake 2>/dev/null \
|| $__sh_which make 2>/dev/null || echo gmake)"
;;
esac
fi
[[ -n "$REBAR" ]] || \
REBAR="$($__sh_which /usr/local/bin/rebar 2>/dev/null \
|| $__sh_which rebar 2>/dev/null || echo rebar)"
[[ -n "$REBAR3" ]] || \
REBAR3="$($__sh_which /usr/local/bin/rebar3 2>/dev/null \
|| $__sh_which rebar3 2>/dev/null || echo rebar3)"
export ECP EGREP ESED GIT LANG MAKE REBAR REBAR3
BLOCKSIZE=1024
for EDITOR in $($__sh_which vi 2>/dev/null) \
$($__sh_which vim 2>/dev/null) $($__sh_which nano 2>/dev/null) vi
do
break
done
for PAGER in $($__sh_which less 2>/dev/null) \
$($__sh_which more 2>/dev/null) more
do
break
done
export BLOCKSIZE EDITOR PAGER
if [[ -n "$SSH_TTY" ]]
then
MATE="$($__sh_which rmate 2>/dev/null)"
else
MATE="$($__sh_which mate 2>/dev/null)"
fi
if [[ -n "$MATE" ]]
then
export MATE
[[ -n "$VISUAL" ]] || VISUAL="$MATE --wait"
else
unset MATE
if [[ -z "$VISUAL" ]]
then
VISUAL="$($__sh_which tedit 2>/dev/null)"
[[ -n "$VISUAL" ]] || VISUAL="$EDITOR"
fi
fi
P4EDITOR="$VISUAL"
WINEDITOR="$VISUAL"
export VISUAL P4EDITOR WINEDITOR
case "$shell" in
bash)
# bash stupidly doesn't source its rc files from an interactive login shell
if [[ "$-" = *i* || -n "$__sh_interactive" || -n "$PS1" ]]
then
for f in "$HOME/.bashrc" "$HOME/.shrc"
do
if [[ -f "$f" ]]
then
if [[ "$f" != "$HOME/.bashrc" ]]
then
echo Warning: '***' non-standard environment file $f \
will not be sourced by interactive bash \
subshells, consider installing as $HOME/.bashrc
fi
. "$f"
break
fi
done
unset_vars="$unset_vars f ENV"
else
unset_vars="$unset_vars ENV"
fi
;;
ksh)
if [[ -z "$ENV" || "$ENV" = "$HOME/.kshrc" || ! -f "$ENV" ]]
then
if [[ ! -f "$HOME/.kshrc" && -f "$HOME/.shrc" ]]
then
ENV="$HOME/.shrc"
export ENV
else
unset_vars="$unset_vars ENV"
fi
fi
;;
sh)
if [[ -z "$ENV" || ! -f "$ENV" ]]
then
if [[ -f "$HOME/.shrc" ]]
then
ENV="$HOME/.shrc"
export ENV
else
unset_vars="$unset_vars ENV"
fi
fi
;;
zsh)
if [[ ! -f "$HOME/.zshrc" && -o interactive && -f "$HOME/.shrc" ]]
then
echo Warning: '***' non-standard environment file $HOME/.shrc \
will not be sourced by interactive zsh subshells, consider \
installing as $HOME/.zshrc
. "$HOME/.shrc"
fi
unset_vars="$unset_vars ENV"
;;
*)
unset_vars="$unset_vars ENV"
;;
esac
unset $unset_vars unset_vars 2>/dev/null