-# Set colors for ls (and zsh completions). This colors files normal (fi),
-# directories blue bold (di), symbolic links cyan (ln), named pipes normal
-# (pi), sockets normal (so), block devices normal (bd), character devices
-# normal (cd) and executables bold red (ex).
-# See `dircolors --print-database` for possible colors.
-LS_COLORS='no=00:fi=00:di=34;01:ln=36:pi=00:so=00:bd=00:cd=00:ex=31;01'
-export LS_COLORS
+escape=`printf '\033'`
+# Color man pages viewed with less, thanks to [1].
+#
+# [1]: http://nion.modprobe.de/blog/archives/572-less-colors-for-man-pages.html
+#
+# Color bold strings in bold blue.
+LESS_TERMCAP_md="${escape}[01;34m"
+LESS_TERMCAP_me="${escape}[0m"
+export LESS_TERMCAP_md LESS_TERMCAP_me
+# Color underlined strings in bold yellow and underlined.
+LESS_TERMCAP_us="${escape}[01;4;33m"
+LESS_TERMCAP_ue="${escape}[0m"
+export LESS_TERMCAP_us LESS_TERMCAP_ue
+# Color standout mode in bold black with yellow background.
+LESS_TERMCAP_so="${escape}[01;30;43m"
+LESS_TERMCAP_se="${escape}[0m"
+export LESS_TERMCAP_so LESS_TERMCAP_se
+
+# Use ~/.tmp as directory for temporary files if available to reduce security
+# problems on multi-user systems.
+if test -O "$HOME/.tmp" && test -d "$HOME/.tmp"; then
+ TMP=$HOME/.tmp
+ TEMP=$TMP
+ TMPDIR=$TMP
+ export TMP TEMP TMPDIR
+# Also try ~/tmp as fallback.
+elif test -O "$HOME/tmp" && test -d "$HOME/tmp"; then
+ TMP=$HOME/tmp
+ TEMP=$TMP
+ TMPDIR=$TMP
+ export TMP TEMP TMPDIR
+fi
+
+# Change rlwrap's home directory to prevent cluttering ~/.
+RLWRAP_HOME="$HOME/.shell/rlwrap"
+export RLWRAP_HOME
+
+# Set colors for GNU ls (and Zsh completions).
+if test -f "$HOME/.shell/dircolors"; then
+ . "$HOME/.shell/dircolors"
+fi
+# Set the same colors for non GNU ls, except for special cases which aren't
+# supported.
+LSCOLORS='ExgxxxxxBxxxxxBdBdExEb'
+# ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
+# | | | | | | | | | | |
+# | | | | | | | | | | *- directory writable to others, without sticky bit
+# | | | | | | | | | *--- directory writable to others, with sticky bit
+# | | | | | | | | *----- executable with setgid bit set
+# | | | | | | | *------- executable with setuid bit set
+# | | | | | | *--------- character special
+# | | | | | *----------- block special
+# | | | | *------------- executable
+# | | | *--------------- pipe
+# | | *----------------- socket
+# | *------------------- symbolic link
+# *--------------------- directory
+export LSCOLORS
+
+
+source_debug ". ~/.shell/env (done)"
+
+# vim: ft=sh