el/dot-emacs.el (mdw-fontify-rust): Fix integer literal syntax.
[profile] / dot / profile
CommitLineData
74a53e28
MW
1### -*-sh-*-
2###
3### Session startup things.
4
5## The shell-specific hook will run us if it thinks we haven't been run
6## before. We should therefore let it know.
7__mdw_profile=t; export __mdw_profile
8
9###--------------------------------------------------------------------------
10### Utility functions.
11
12## __mdw_addto VAR DIR PATH ...
13##
14## VAR is the name of a PATH-like environment variable (i.e., one which
15## contains a sequence of pathnames separated by colons). DIR is either `l'
16## or `r'. The PATHs are pathnames. Those PATHs which correspond to
17## existing directories but which aren't currently named in the variable are
18## added to the left or right (depending on DIR) of VAR. The relative order
19## of PATHs added in the same invokation is the same as the order they
20## appeared in PATHs: the DIR argument only affects which end of the VAR they
21## get added to.
22__mdw_addto () {
23 local var=$1 val dir=$2 new="" change=nil
24 eval val=\$$var
25 shift 2
26 for i in "$@"; do
27 case "$new:" in *:$i:*) continue;; esac
28 if ! [ -d $i ]; then continue; fi
29 case "$val" in
30 "") val=$i change=t; continue ;;
31 $i) continue ;;
32 *:$i:*) val=${val%%:$i:*}:${val#*:$i:} ;;
33 $i:*) val=${val#$i:} ;;
34 *:$i) val=${val%:$i} ;;
35 esac
36 new=$new:$i change=t
37 done
38 case $dir in
39 l) val=${new#:}:$val ;;
40 r) val=$val$new ;;
41 esac
42 case $change in t) eval $var=\$val ;; esac
43}
44
45## __mdw_programp NAME
46##
47## Does NAME exist as an executable program?
48__mdw_programp () { type >/dev/null 2>&1 "$1"; }
49
50## __mdw_setconf VAR CONF [DEFAULT]
51##
52## If CONF is defined in `~/.mdw.conf' then set VAR to its value; otherwise,
53## set VAR to DEFAULT, if given; otherwise, do nothing at all.
54__mdw_setconf () {
55 local var=$1 conf=$2 val; shift 2
56 if val=$(mdw-conf 2>/dev/null "$conf" "$@"); then
57 eval "$var=\$val; export $var"
58 fi
59}
60
61###--------------------------------------------------------------------------
62### Other preliminaries.
63
64## Work out my home directory, resolving symbolic links.
65HOME=$(cd "$HOME"; pwd -P)
66case ${SCHROOT_SESSION_ID+t} in t) ;; *) cd "$HOME" ;; esac
67
68## CDE's session structure is demented and doesn't leave us with a proper
69## logout hook, so synthesize one here.
70case ${DT+t} in t) trap "source $HOME/.shell-logout" EXIT; esac
71
72###--------------------------------------------------------------------------
73### Set some basic paths.
74
75## The main path.
76export PATH
77__mdw_addto PATH l \
78 "$HOME"/bin \
79 /usr/local/bin /usr/local/sbin /usr/local/games \
80 /usr/bin /usr/sbin /usr/games \
81 /usr/X11R6/bin /usr/local/X11R6/bin \
82 /bin /sbin \
83 /opt/nfast/bin /opt/nfast/sbin
84
85## If we have Plan 9 from User Space, then add that in.
8fd6f7da
MW
86for i in /opt/plan9 /usr/local/plan9; do
87 if [ -d $i ]; then
88 PLAN9=$i; export PLAN9
89 __mdw_addto PATH r $i/bin
90 break
91 fi
92done
74a53e28 93
b97b3f8e
MW
94## Check for some standard path hacks.
95for i in ccache; do
96 __mdw_addto PATH l "$HOME"/bin/hacks/$i
97done
98
74a53e28
MW
99###--------------------------------------------------------------------------
100### Some other preliminaries.
101
102## Establish a temporary directory.
103case ${TMPDIR+t} in
104 t) ;;
105 *) if __mdw_programp tmpdir; then eval $(tmpdir -b); fi
106esac
107TMP=$TMPDIR; export TMP
108
109## Sensible umask if users have their own groups.
110umask 002
111
112###--------------------------------------------------------------------------
113### Text editor configuration.
114
115MDW_EDITOR=ed
116emacs_startup_args="--no-site-file --mdw-fast-startup -nw"
117for ed in \
118 "emacs24 $emacs_startup_args" \
119 "emacs23 $emacs_startup_args" \
120 "emacs22 $emacs_startup_args" \
121 "emacs21 $emacs_startup_args" \
122 zile mg \
123 "emacs -nw" \
124 vi pico nano ae
125do
126 name=${ed%% *}
127 if __mdw_programp "$name"; then MDW_EDITOR=$ed; break; fi
128done
129EDITOR=mdw-editor VISUAL=mdw-editor
130export EDITOR VISUAL MDW_EDITOR
131unset ed emacs_startup_args
132
133###--------------------------------------------------------------------------
134### Locale configuration.
135
2c44f386
MW
136case ${LC_MDWSSHLANG+t},${DISPLAY+t} in
137 t,*)
138 LANG=$LC_MDWSSHLANG
139 ;;
140 ,t)
74a53e28
MW
141 __mdw_setconf LANG x-ctype POSIX
142 ;;
143 *)
144 : LANG=${LC_CTYPE-${LC_ALL-$(mdw-conf console-ctype POSIX)}}
145 case "$TERM,$(tty)" in
146 linux,/dev/tty*)
147 if { vt-is-UTF8 || kbd_mode | grep UTF-8; } >/dev/null 2>&1; then
2f27026a 148 ctype=.UTF-8
74a53e28
MW
149 else
150 ctype=
151 fi
152 LANG=${LANG%.*}$ctype
153 ;;
154 esac
155 ;;
156esac
157unset LC_ALL
158export LANG
159
160LC_COLLATE=POSIX; export LC_COLLATE
161
2c44f386
MW
162case ${LANG+t} in
163 t) LC_MDWSSHLANG=$LANG; export LC_MDWSSHLANG ;;
164esac
165
74a53e28
MW
166###--------------------------------------------------------------------------
167### Pagers.
168
169## Choose a sensible pager.
170MDW_PAGER=more
171for pg in less more; do
172 if __mdw_programp "$pg"; then MDW_PAGER=$(command -v "$pg"); break; fi
173done
174PAGER=mdw-pager METAMAIL_PAGER=mdw-pager
175export MDW_PAGER PAGER METAMAIL_PAGER
176unset pg
177
178## Configure `less'.
74a53e28
MW
179case ${LC_CTYPE-$LANG} in
180 *utf8 | *utf-8 | *UTF8 | *UTF-8) LESSCHARSET=utf-8 ;;
181 *) LESSCHARSET=latin1 ;;
182esac
183export LESSCHARSET
184if __mdw_programp global; then
185 LESSGLOBALTAGS=global
186 export LESSGLOBALTAGS
187fi
188
189###--------------------------------------------------------------------------
190### Miscellaneous things.
191
192## Mail and general identification.
193__mdw_setconf MAIL mailbox /var/mail/mdw
194__mdw_setconf EMAIL email mdw@distorted.org.uk
195NAME="Mark Wooding"; export NAME
196
197## News server.
198__mdw_setconf NNTPSERVER nntp-server
199
200## Some programs want to know the hostname.
201case ${HOST+t} in t) ;; *) HOST=$(hostname); export HOST; esac
202
203## HTTP and FTP proxies.
204http=$(mdw-conf http-proxy none)
205case "${http_proxy-none},$http" in
206 *,none) ;;
207 none,*) http_proxy=http://$http/; export http_proxy ;;
208esac
442bc88b
MW
209https=$(mdw-conf https-proxy none)
210case "${https_proxy-none},$https,${http_proxy-none}" in
211 *,none,none) ;;
212 none,none,*) https_proxy=$http_proxy; export https_proxy ;;
213 none,*,*) https_proxy=http://$https/; export ftp_proxy ;;
214esac
74a53e28
MW
215ftp=$(mdw-conf ftp-proxy none)
216case "${ftp_proxy-none},$ftp,${http_proxy-none}" in
217 *,none,none) ;;
218 none,none,*) ftp_proxy=$http_proxy; export ftp_proxy ;;
219 none,*,*) ftp_proxy=http://$ftp/; export ftp_proxy ;;
220esac
442bc88b 221unset http https ftp
74a53e28
MW
222
223## Ncurses programs should use the Unicode box-drawing characters because the
224## alternative character set stuff isn't supported well.
225NCURSES_NO_UTF8_ACS=1; export NCURSES_NO_UTF8_ACS
226
227## Shut up Perl's readline machinery.
228PERL_READLINE_NOWARN=yes; export PERL_READLINE_NOWARN
229
230## If we have `distcc' then tell `ccache' to use it.
231if __mdw_programp distcc; then CCACHE_PREFIX=distcc; export CCACHE_PREFIX; fi
232
233## Choose a sensible web browser. If we have a display, try to pick a
234## graphical one.
235set -- elinks w3m lynx
236case ${DISPLAY+t} in
94526c3f 237 t) set -- mdw-iceweasel mdw-chrome iceweasel firefox "$@" ;;
74a53e28
MW
238esac
239for b in "$@"; do
240 if __mdw_programp $b; then BROWSER=$b; export BROWSER; break; fi
241done
242unset b
243
244## Acquiring root privileges. This is mainly the job of `bashrc', but we
245## cache the mechanism here.
246__mdw_setconf __MDW_ROOTLY rootly
247BECOME="--preserve-environment"; export BECOME
248
249## It's useful to see the little sigils in `ls'.
250case ${LS_OPTIONS+t} in t) ;; *) LS_OPTIONS="-F"; export LS_OPTIONS; esac
251
252## Settings for BBC BASIC listing.
253export BASCAT="-l +n"
254
255## Version control hacking.
256CVS_RSH=ssh; export CVS_RSH
257__mdw_setconf CVSROOT cvs-root
258__mdw_setconf SVNROOT svn-root
259P4CONFIG=.p4; export P4CONFIG
260
261## Help X programs find their resources.
262XUSERFILESEARCHPATH="$HOME/.Xapps/%N:/usr/lib/X11/%T/%N%S"
263export XUSERFILESEARCHPATH
264
265## Make OpenOffice.org do its thing properly.
266OOO_FORCE_DESKTOP=gnome; export OOO_FORCE_DESKTOP
267
268## Hack Qt-ish things to be unstoatly.
269QT_STYLE_OVERRIDE=gtk2; export QT_STYLE_OVERRIDE
270
eb174df8
MW
271## Use X11 input method (including compose key sequences) everywhere.
272GTK_IM_MODULE=xim; export GTK_IM_MODULE
273QT_IM_MODULE=xim; export QT_IM_MODULE
274
74a53e28
MW
275## Configure `ps'.
276PS_PERSONALITY=gnu; export PS_PERSONALITY
277
278## Disable core dumps.
279ulimit -S -c 0
280
281###--------------------------------------------------------------------------
282### Authentication and SSH hacking.
283
284## Start an authentication agent. This is unnecessarily fiddly. If there's
285## a Gnome keyring server then we should use that; unfortunately, it may not
286## yet have had a chance to populate the environment with its settings, so we
287## go off and fetch them.
288if { { [ "$GNOME_KEYRING_CONTROL" ] &&
289 [ -s "$GNOME_KEYRING_CONTROL" ]; } ||
290 { [ "$DBUS_SESSION_BUS_ADDRESS" ] &&
291 __mdw_programp gnome-keyring-daemon; }; } &&
292 stuff=$(gnome-keyring-daemon -s -c gpg 2>/dev/null)
293then
294 eval "$stuff"
295 export SSH_AUTH_SOCK GPG_AGENT_INFO
296fi
297
298## If we still don't have an agent then start one with a stable name.
299eval $(start-ssh-agent -b)
300
301## Decide whether this session should be considered `secure'. A session is
302## secure if it's on a secure TTY, but there are lots of ways of finding out
303## which TTYs are secure.
304if [ -z "$__mdw_bashrc" ] && [ "$__mdw_force_secure_session" = "yes" ] ||
305 ( tty="`tty`" devtty="(/dev/)?${tty#/dev/}"
306 { { { [ -e /etc/securetty ] && sectty=/etc/securetty; } ||
307 { [ -e /etc/securettys ] && sectty=/etc/securettys; }; } &&
308 egrep "$devtty" $sectty >/dev/null; } ||
309 { [ -e /etc/default/login ] &&
310 egrep "^CONSOLE=$devtty" /etc/default/login >/dev/null; } ||
311 case "${tty#/dev/}" in
312 console|systty|tty[0-9]) true ;;
313 *) false ;;
314 esac )
315then
316 __mdw_sechost=$HOST; export __mdw_sechost
317fi
318
319## Start a passphrase pixie if there is one and it's not already running.
320if pixie --version >/dev/null 2>&1; then
321 mkdir -p "$HOME/.catacomb"
322 pixie=${CATACOMB_PIXIE-$HOME/.catacomb/pixie}
323 if [ -S "$pixie" ] && pixie -C help >/dev/null 2>&1; then
324 :
325 else
326 pixie -d 2>>"$HOME/.catacomb/pixie.log"
327 __mdw_started_pixie=yes
328 fi
329fi
330
331###--------------------------------------------------------------------------
332### Finishing touches.
333
334## For old-fashioned Bourne-ish shells, set up per-shell definitions.
335ENV=$HOME/.shrc; export ENV
336
337## If there's a local hook then run it.
338if [ -f "$HOME/.profile-local" ]; then . "$HOME/.profile-local"; fi
339
340###----- That's all, folks --------------------------------------------------