-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path.shared_env
255 lines (200 loc) · 5.5 KB
/
.shared_env
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
#!/bin/sh
#
# Adam's shared environment startup file
#
# $Id$
#
# This should get run as part of setting up the environment
# of any sh-compatible shell, including non-interactive ones;
# hence it should be kept as fast and as portable as possible.
# Note that that means silly things like [ ! -e foo ] rather
# than ! [ -e foo ] ...
# Allow disabling of entire environment suite
[ -n "$INHERIT_ENV" ] && return 0
[ -n "$shared_env_loaded" ] && return 0
# {{{ Are we interactive?
case "$-" in
*i*) shell_interactive=y ;;
*) shell_interactive= ;;
esac
# }}}
# {{{ Loading status
#[ "$shell" = -zsh ] && unsetopt function_argzero
sh_load_status () {
# Find the name of the running shell
_this_shell=${shell:-${0##*/}}
# Find the filename of the running script
if [ -n "$BASH_SOURCE" ]; then
_this_script="${BASH_SOURCE[0]}"
# Deduct 1 because array starts at 0, and another 1 because
# we want to ignore this stack frame (inside sh_load_status)
_this_script="${BASH_SOURCE[$(( ${#BASH_SOURCE[@]} - 2))]}"
# Sheesh. $ZSH_SOURCE[-2], anyone?
else
_this_script="$0"
# Unfortunately in zsh there seems to be no way of determining
# the currently running file if a function is being run, unless
# function_argzero is unset :-/
[ "$_this_script" = sh_load_status ] && _this_script=
[ "$_this_script" = -zsh ] && _this_script=
fi
[ -n "$_this_script" ] && _this_script=": $_this_script"
# Leave status printed?
if [ "$DEBUG_LOCAL_HOOKS" -ge 2 ]; then
debug="\n"
fi
# \e[0K is clear to right
if [ -n "$shell_interactive" ]; then
echo -e -n "\r$_this_shell$_this_script: $* ... \e[0K$debug"
fi
}
# }}}
sh_load_status .shared_env
# {{{ ZDOTDIR, ZDOTDIRPATH, ZDOTUSER
# See .zshenv
zdotdir=${ZDOTDIR:-$HOME}
export ZDOTDIR="$zdotdir"
# Define a search path to be used by run_hooks
if [ "$ZDOTDIR" = "$HOME" ]; then
ZDOTDIRPATH=$ZDOTDIR
ZDOTDIRREVPATH=$ZDOTDIR
else
export OTHER_USER=1
ZDOTDIRPATH="$ZDOTDIR $HOME"
ZDOTDIRREVPATH="$HOME $ZDOTDIR"
fi
export ZDOTDIRPATH ZDOTDIRREVPATH
[ -z "$ZDOTUSER" ] && [ -e ~/.zdotuser ] && ZDOTUSER=`cat ~/.zdotuser`
export ZDOTUSER
# }}}
# {{{ HOST / HOSTNAME
: ${HOST:=${HOSTNAME:-`hostname`}}
: ${HOSTNAME:=$HOST}
export HOST HOSTNAME
# }}}
# {{{ USER / USERNAME
: ${USER:=${USERNAME:-`id -un`}}
: ${USERNAME:=$USER}
export USER USERNAME
# }}}
# {{{ HOME
# Don't leave history files in /
: ${HOME:=/}
if [ "$HOME" = '/' ]; then
if [ -d /root ]; then
HOME=/root
elif [ -d /var/tmp ]; then
new_home=/var/tmp/root.tmphome
if [ -d "$new_home" ] || mkdir "$new_home"; then
HOME="$new_home"
fi
fi
fi
[ "$HOME" = '/' ] && echo "Warning: ~ is /"
# }}}
# {{{ PATH
# Don't trust system-wide PATH? Remember what it was, for reference.
syspath=$HOME/.syspath.$HOST
if ! [ -e $syspath ]; then
# Ignore failed write as home directory is sometimes locked down
# cross-WAN.
echo "$PATH" 2>/dev/null > "$syspath"
fi
PATH=/usr/local/bin:/usr/X11R6/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
# ... or *do* trust system-wide PATH
#PATH=/usr/local/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/sbin:/sbin:$PATH
. $ZDOTDIR/.zsh/functions/enable_wordsplit
newpaths=
for dir in $ZDOTDIRREVPATH; do
for newpath in \
$dir/sbin \
$dir/bin \
$dir/local/$OSTYPE/bin \
$dir/local/sbin \
$dir/local/bin \
; do
if [ -d $newpath ]; then
if [ -z "$newpaths" ]; then
newpaths=$newpath
else
newpaths=$newpaths:$newpath
fi
fi
done
done
restore_wordsplit
PATH=$newpaths:$PATH
# }}}
# {{{ MANPATH
# In order to avoid forks here, this is done in .zshrc
# }}}
# {{{ grep
# Why would you ever want grep to treat dirs like normal files?
export GREP_OPTIONS='--directories=skip'
# }}}
# {{{ GNU screen
case "$TERM" in
screen*) IN_SCREEN=yes ; export IN_SCREEN ;;
esac
export SCREENRC=$ZDOTDIR/.screenrc
# }}}
# {{{ INPUTRC
# no crappy RedHat inputrcs, thankyouverymuch. Which fucking *idiot*
# set convert-meta to off?
[ -n "$INPUTRC" ] && unset INPUTRC
# }}}
# {{{ COLUMNS
# Some programs might find this handy. Shouldn't do any harm.
export COLUMNS
# }}}
# {{{ OSTYPE
# Can come in handy too, if the shell sets it (bash and zsh do).
export OSTYPE
# }}}
# {{{ Pager
export METAMAIL_PAGER='less -r'
export PERLDOC_PAGER='less -r'
export PAGER='less'
export LESS='-h100 -i -j1 -M -q -y100'
export LESSOPEN="|$ZDOTDIR/bin/lesspipe.sh %s"
#export LESSCLOSE='/usr/local/bin/lessclose.sh %s %s'
# }}}
# {{{ POSIXLY_CORRECT for patch
#export POSIXLY_CORRECT=yes
# }}}
# {{{ Commonly used directories
# Have cdable_vars set in zsh, so don't need 'hash -d' in front of these
# and can be reused from any shell
# Notice that it's worth setting these even if they don't exist on the
# machine they're being set on, as they could still come in handy when
# constructing scp/rsync command-lines etc.
if [ -d /usr/src/packages ]; then
_topdir=/usr/src/packages
else
_topdir=/usr/src/redhat
fi
RP=$_topdir/RPMS
I3=$RP/i386
I4=$RP/i486
I5=$RP/i586
I6=$RP/i686
NA=$RP/noarch
SR=$_topdir/SRPMS
SP=$_topdir/SPECS
SO=$_topdir/SOURCES
BU=$_topdir/BUILD
LI=/usr/src/linux
L4=/usr/src/linux-2.4
CV=/usr/local/cvsroot
RC=/etc/rc.d/init.d
ID=/etc/init.d # LSB
VL=/var/log
VLH=$VL/httpd
SC=/etc/sysconfig
SCN=/etc/sysconfig/network
NS=/etc/sysconfig/network-scripts
# in zsh:
#hash -df
# }}}
. $ZDOTDIR/.zsh/functions/run_hooks .shared_env.d
shared_env_loaded=y