2 # /etc/profile: system-wide profile for the Bourne shell (sh(1)) and
3 # Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
4 # Written 2003-2014 by Alexander Barton (alex@barton.de)
7 [ -e ~/.ConfigScripts.debug ] && echo " >> /etc/profile ..."
12 # Make sure UID is set
13 [ -n "$UID" ] || UID=`id -u`
16 # Setup locale and encoding
17 if [ -e ~/.ConfigScripts.debug ]; then
18 echo " - TERM=\"$TERM\""
19 echo " - LANG=\"$LANG\""
20 echo " - LC_CTYPE=\"$LC_CTYPE\""
22 # Does LC_CTYPE or LANG indicate an UTF-8 terminal?
24 if [ -n "$LC_CTYPE" ]; then
25 LC_encoding="${LC_CTYPE#*.}"
26 elif [ -n "$LANG" ]; then
27 LC_encoding="${LANG#*.}"
29 if [ -z "$LC_encoding" ]; then
32 LC_encoding="UTF-8"; ;;
34 LC_encoding="ISO8859-1"
37 [ -e ~/.ConfigScripts.debug ] && echo " - LC_encoding=\"$LC_encoding\" (temp)"
38 # Set locale if it is not set or doesn't contain a dot:
39 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
40 && export LANG="${LANG:-de_DE}.${LC_encoding}"
41 [ -e ~/.ConfigScripts.debug ] && echo " - LANG=\"$LANG\" (new)"
43 unset LC_CTYPE LC_encoding 2>/dev/null
45 # Initialize PATH variable
46 if [ -x /usr/libexec/path_helper ]; then
47 eval `/usr/libexec/path_helper -s \
48 | sed "s|:/usr/local/bin||" | sed "s|:/usr/local/sbin||"`
49 [[ "$PATH" == *sbin* ]] \
50 && PATH="/usr/local/bin:/usr/local/sbin:$PATH" \
51 || PATH="/usr/local/bin:$PATH"
53 PATH="/usr/local/bin:/usr/bin:/bin"
54 [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
57 # prepend optional directories to PATH ...
59 for d in /Developer/usr/bin /usr/pkg/bin /usr/ucb /usr/lib/ccache /opt/*/bin; do
60 if [ -d "$d" -o -h "$d" ]; then
61 [ -e "$d/.not_in_path" ] || path="$path$d:"
64 [ -n "$path" ] && PATH="$path$PATH"
65 if [ "$UID" -eq 0 ]; then
67 for d in /usr/pkg/sbin /opt/*/sbin; do
68 if [ -d "$d" -o -h "$d" ]; then
69 [ -e "$d/.not_in_path" ] || path="$path$d:"
72 [ -n "$path" ] && PATH="$path$PATH"
74 # append optional directories to PATH ...
75 for d in /usr/bin/X11 /usr/games /usr/share/php/bin; do
76 if [ -d "$d" -o -h "$d" ]; then
77 [ -e "$d/.not_in_path" ] || PATH="$PATH:$d"
80 # set PATH so it includes user's private executables
81 [ -d ~/Applications -a ! -e ~/Applications/.not_in_path ] \
82 && PATH=~/Applications:"${PATH}"
83 [ -d ~/bin -a ! -e ~/bin/.not_in_path ] \
84 && PATH=~/bin:"${PATH}"
85 [ -d ~/sbin -a ! -e ~/sbin/.not_in_path ] \
86 && PATH=~/sbin:"${PATH}"
88 # Setup MANPATH, if manpath(1) isn't available
89 if [ ! "$(type manpath 2>/dev/null)" ]; then
91 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
93 for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
94 [ -d "$d" -o -h "$d" ] && path="$path$d:"
96 [ -n "$path" ] && MANPATH="$path$MANPATH"
97 [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
98 [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
101 # set variable identifying the chroot you work in
102 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
103 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
105 # make sure $UID and $USER is set
106 [ -z "$UID" ] && UID=`id -u`
107 [ -z "$USER" ] && USER=`id -un`
110 # get my own hostname
111 ME=`hostname 2>/dev/null`
114 # Move Xauthority file to local storage, so that sudo et all work
115 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
116 cp ~/.Xauthority /tmp/Xauthority-$USER
117 chmod 600 /tmp/Xauthority-$USER
118 export XAUTHORITY="/tmp/Xauthority-$USER"
121 # read profile additions
122 if [ -d /etc/profile.d -o -d /usr/local/etc/profile.d ]; then
123 for f in /etc/profile.d/* /usr/local/etc/profile.d/*; do
124 [ -r "$f" ] || continue
129 [ -e ~/.ConfigScripts.debug ] \
136 # read local profile, if available
137 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
139 # Setup some directories to use local storage (no NFS)
140 [ -d "/usr/local/home/$USER" ] \
141 || ( mkdir /usr/local/home; mkdir "/usr/local/home/$USER" ) >/dev/null 2>&1
142 if [ -w "/usr/local/home/$USER" ]; then
143 export LOCAL_HOME="/usr/local/home/$USER"
144 export CCACHE_DIR="$LOCAL_HOME/.ccache"
145 export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
151 # validate terminal definition
152 type -p tset >/dev/null 2>&1
153 [ $? -eq 0 ] && eval `tset -s -Q`
155 # generic shell prompt
161 type -p icalBuddy >/dev/null 2>&1
162 if [ $? -eq 0 -a "$UID" -ne 0 ]; then
164 *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
165 *) bul="*"; bul_imp="!"; sep=">"; ;;
167 icalBuddy -f -n -npn -nc -b " $BUL " -ps "/ $SEP /" -eep "url,notes" \
168 eventsToday+1 2>/dev/null | grep "$BUL"
170 unset bul bul_imp sep
173 type -p remind >/dev/null 2>&1
174 if [ $? -eq 0 -a -r ~/.remind ]; then
175 remind -h -g -t5 ~/.remind | \
176 grep -v '^Reminders for ' | grep -v '^$'
181 # bash-specific initialization
182 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
183 && source /etc/bash.bashrc
184 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
185 && source /etc/bashrc
187 # ksh-specific initialization
188 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
191 # Check filesystem quotas
192 mount 2>/dev/null | grep quota >/dev/null 2>&1
193 if [ $? -eq 0 ]; then
194 which quota >/dev/null 2>&1
195 [ $? -eq 0 ] && quota -q