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 # Setup locale and encoding
13 if [ -e ~/.ConfigScripts.debug ]; then
14 echo " - TERM=\"$TERM\""
15 echo " - LANG=\"$LANG\""
16 echo " - LC_CTYPE=\"$LC_CTYPE\""
18 # Does LC_CTYPE or LANG indicate an UTF-8 terminal?
20 if [ -n "$LC_CTYPE" ]; then
21 LC_encoding=`echo "$LC_CTYPE" | cut -d. -f2- -s`
22 elif [ -n "$LANG" ]; then
23 LC_encoding=`echo "$LANG" | cut -d. -f2- -s`
25 if [ -z "$LC_encoding" ]; then
28 LC_encoding="UTF-8"; ;;
30 LC_encoding="ISO8859-1"
33 [ -e ~/.ConfigScripts.debug ] && echo " - LC_encoding=\"$LC_encoding\" (temp)"
34 # Set locale if it is not set or doesn't contain a dot:
35 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
36 && export LANG="${LANG:-de_DE}.${LC_encoding}"
37 [ -e ~/.ConfigScripts.debug ] && echo " - LANG=\"$LANG\" (new)"
39 unset LC_CTYPE LC_encoding 2>/dev/null
41 # Initialize PATH variable
42 if [ -x /usr/libexec/path_helper ]; then
43 eval `/usr/libexec/path_helper -s \
44 | sed "s|:/usr/local/bin||" | sed "s|:/usr/local/sbin||"`
45 [[ "$PATH" == *sbin* ]] \
46 && PATH="/usr/local/bin:/usr/local/sbin:$PATH" \
47 || PATH="/usr/local/bin:$PATH"
49 PATH="/usr/local/bin:/usr/bin:/bin"
50 [ "$LOGNAME" = "root" ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
53 # prepend optional directories to PATH ...
55 for d in /Developer/usr/bin /usr/pkg/bin /usr/ucb /usr/lib/ccache /opt/*/bin; do
56 if [ -d "$d" -o -h "$d" ]; then
57 [ -e "$d/.not_in_path" ] || path="$path$d:"
60 [ -n "$path" ] && PATH="$path$PATH"
62 if [ "$LOGNAME" = "root" ]; then
63 for d in /usr/pkg/sbin /opt/*/sbin; do
64 if [ -d "$d" -o -h "$d" ]; then
65 [ -e "$d/.not_in_path" ] || path="$path$d:"
68 [ -n "$path" ] && PATH="$path$PATH"
71 # append optional directories to PATH ...
72 for d in /usr/bin/X11 /usr/games /usr/share/php/bin; do
73 if [ -d "$d" -o -h "$d" ]; then
74 [ -e "$d/.not_in_path" ] || PATH="$PATH:$d"
78 # set PATH so it includes user's private executables
79 [ -d ~/Applications -a ! -e ~/Applications/.not_in_path ] \
80 && PATH=~/Applications:"${PATH}"
81 [ -d ~/bin -a ! -e ~/bin/.not_in_path ] \
82 && PATH=~/bin:"${PATH}"
83 [ -d ~/sbin -a ! -e ~/sbin/.not_in_path ] \
84 && PATH=~/sbin:"${PATH}"
86 # Setup MANPATH, if manpath(1) isn't available
87 if [ ! "$(type -t manpath 2>/dev/null)" ]; then
89 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
91 for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
92 [ -d "$d" -o -h "$d" ] && path="$path$d:"
94 [ -n "$path" ] && MANPATH="$path$MANPATH"
95 [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
96 [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
100 # set variable identifying the chroot you work in
101 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
102 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
104 # get my own hostname
105 [ -n "$HOSTNAME" ] || HOSTNAME=`hostname 2>/dev/null`
108 # Setup local home directory, when available
109 [ -d "/usr/local/home" -a ! -d "/usr/local/home/$LOGNAME" ] \
110 && mkdir "/usr/local/home/$LOGNAME" >/dev/null 2>&1
111 [ -w "/usr/local/home/$LOGNAME" ] \
112 && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
113 || export LOCAL_HOME="$HOME"
115 # Setup environment to use local storage (no NFS, if possible!)
116 export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
118 # Setup environment for ccache, if installed
119 type -t ccache >/dev/null && export CCACHE_DIR="$XDG_CACHE_HOME/ccache"
121 # Setup environment for Python "pip", if installed
122 if [ "$(type -t pip 2>/dev/null)" ]; then
123 export PIP_REQUIRE_VIRTUALENV=true
124 export PIP_DOWNLOAD_CACHE="$XDG_CACHE_HOME/pip"
127 # Move Xauthority file to local storage, so that sudo et all work
128 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
129 cp ~/.Xauthority /tmp/Xauthority-$LOGNAME
130 chmod 600 /tmp/Xauthority-$LOGNAME
131 export XAUTHORITY="/tmp/Xauthority-$LOGNAME"
134 # read profile additions
135 if [ -d /etc/profile.d -o -d /usr/local/etc/profile.d ]; then
136 for f in /etc/profile.d/* /usr/local/etc/profile.d/*; do
137 [ -r "$f" ] || continue
142 [ -e ~/.ConfigScripts.debug ] \
150 # read local profile, if available
151 [ -r "/var/lib/${HOSTNAME}/profile" ] && . /var/lib/${HOSTNAME}/profile
156 # validate terminal definition
157 type -t tset >/dev/null && eval `tset -s -Q`
159 # generic shell prompt
160 [ "$LOGNAME" = "root" ] \
161 && PS1="<$HOSTNAME> # " \
162 || PS1="<$HOSTNAME> \$ "
164 # Reminders (once every 60 minutes)
165 if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
166 [ -e ~/.ConfigScripts.debug ] && echo " - Reminders ..."
167 if [ "$(type -t icalBuddy >/dev/null)" -a "$LOGNAME" != "root" ]; then
170 *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
171 *) bul="*"; bul_imp="!"; sep=">"; ;;
173 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
174 -nc -npn -iep "title,due" -stda \
175 tasksDueBefore:today 2>/dev/null
176 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
177 -nc -npn -iep "title,datetime" \
178 eventsToday+1 2>/dev/null
180 unset bul bul_imp sep
183 if [ "$(type -t remind >/dev/null)" -a -r ~/.remind ]; then
184 remind -h -g -t5 ~/.remind | \
185 grep -v '^Reminders for ' | grep -v '^$'
189 touch ~/.last_reminder
192 # bash-specific initialization
193 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
194 && source /etc/bash.bashrc
195 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
196 && source /etc/bashrc
198 # ksh-specific initialization
199 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
202 # Check filesystem quotas
203 mount 2>/dev/null | grep quota >/dev/null 2>&1
204 if [ $? -eq 0 ]; then
205 type -t quota >/dev/null && quota -q