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-2015 by Alexander Barton (alex@barton.de)
7 [ -e ~/.ConfigScripts.debug ] && echo " .. /etc/profile ..."
12 [ -e ~/.ConfigScripts.debug ] && echo " >> /etc/profile ..."
14 # Source "~/.profile.user-1st", when available
15 [ -r ~/.profile.user-1st ] && . ~/.profile.user-1st
17 # Setup locale and encoding
18 if [ -e ~/.ConfigScripts.debug ]; then
19 echo " - TERM=\"$TERM\""
20 echo " - LANG=\"$LANG\""
21 echo " - LC_CTYPE=\"$LC_CTYPE\""
23 # Does LC_CTYPE or LANG indicate an UTF-8 terminal?
25 if [ -n "$LC_CTYPE" ]; then
26 LC_encoding=`echo "$LC_CTYPE" | cut -d. -f2- -s`
27 elif [ -n "$LANG" ]; then
28 LC_encoding=`echo "$LANG" | cut -d. -f2- -s`
30 if [ -z "$LC_encoding" ]; then
33 LC_encoding="UTF-8"; ;;
35 LC_encoding="ISO8859-1"
38 [ -e ~/.ConfigScripts.debug ] && echo " - LC_encoding=\"$LC_encoding\" (temp)"
39 # Set locale if it is not set or doesn't contain a dot:
40 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
41 && export LANG="${LANG:-de_DE}.${LC_encoding}"
42 [ -e ~/.ConfigScripts.debug ] && echo " - LANG=\"$LANG\" (new)"
44 unset LC_CTYPE LC_encoding 2>/dev/null
46 # Initialize PATH variable
47 if [ -x /usr/libexec/path_helper ]; then
48 eval `/usr/libexec/path_helper -s \
49 | sed "s|:/usr/local/bin||" | sed "s|:/usr/local/sbin||"`
50 [[ "$PATH" == *sbin* ]] \
51 && PATH="/usr/local/bin:/usr/local/sbin:$PATH" \
52 || PATH="/usr/local/bin:$PATH"
54 PATH="/usr/local/bin:/usr/bin:/bin"
55 [ "$LOGNAME" = "root" ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
58 # prepend optional directories to PATH ...
60 for d in /Developer/usr/bin /usr/pkg/bin /usr/ucb /usr/lib/ccache /opt/*/bin; do
61 if [ -d "$d" -o -h "$d" ]; then
62 [ -e "$d/.not_in_path" ] || path="$path$d:"
65 [ -n "$path" ] && PATH="$path$PATH"
67 if [ "$LOGNAME" = "root" ]; then
68 for d in /usr/pkg/sbin /opt/*/sbin; do
69 if [ -d "$d" -o -h "$d" ]; then
70 [ -e "$d/.not_in_path" ] || path="$path$d:"
73 [ -n "$path" ] && PATH="$path$PATH"
76 # append optional directories to PATH ...
77 for d in /usr/bin/X11 /usr/games /usr/share/php/bin; do
78 if [ -d "$d" -o -h "$d" ]; then
79 [ -e "$d/.not_in_path" ] || PATH="$PATH:$d"
83 # set PATH so it includes user's private executables
84 [ -d ~/Applications -a ! -e ~/Applications/.not_in_path ] \
85 && PATH=~/Applications:"${PATH}"
86 [ -d ~/bin -a ! -e ~/bin/.not_in_path ] \
87 && PATH=~/bin:"${PATH}"
88 [ -d ~/sbin -a ! -e ~/sbin/.not_in_path ] \
89 && PATH=~/sbin:"${PATH}"
91 # Setup MANPATH, if manpath(1) isn't available
92 if [ ! "$(type -t manpath 2>/dev/null)" ]; then
94 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
96 for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
97 [ -d "$d" -o -h "$d" ] && path="$path$d:"
99 [ -n "$path" ] && MANPATH="$path$MANPATH"
100 [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
101 [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
105 # set variable identifying the chroot you work in
106 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
107 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
109 # get my own hostname
110 [ -n "$HOSTNAME" ] || HOSTNAME=`hostname 2>/dev/null`
113 # Setup local home directory, when available
114 [ -d "/usr/local/home" -a ! -d "/usr/local/home/$LOGNAME" ] \
115 && mkdir "/usr/local/home/$LOGNAME" >/dev/null 2>&1
116 [ -w "/usr/local/home/$LOGNAME" ] \
117 && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
118 || export LOCAL_HOME="$HOME"
120 # Setup environment to use local storage (no NFS, if possible!)
121 export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
123 # Setup environment for ccache, if installed
124 type -t ccache >/dev/null && export CCACHE_DIR="$XDG_CACHE_HOME/ccache"
126 # Setup environment for Python "pip", if installed
127 if [ "$(type -t pip 2>/dev/null)" ]; then
128 export PIP_REQUIRE_VIRTUALENV=true
129 export PIP_DOWNLOAD_CACHE="$XDG_CACHE_HOME/pip"
132 # Move Xauthority file to local storage, so that sudo et all work
133 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
134 cp ~/.Xauthority /tmp/Xauthority-$LOGNAME
135 chmod 600 /tmp/Xauthority-$LOGNAME
136 export XAUTHORITY="/tmp/Xauthority-$LOGNAME"
139 # read profile additions
140 if [ -d /etc/profile.d -o -d /usr/local/etc/profile.d ]; then
141 for f in /etc/profile.d/* /usr/local/etc/profile.d/*; do
142 [ -r "$f" ] || continue
147 [ -e ~/.ConfigScripts.debug ] \
155 # read local profile, if available
156 [ -r "/var/lib/${HOSTNAME}/profile" ] && . /var/lib/${HOSTNAME}/profile
164 # validate terminal definition
165 type -t tset >/dev/null && eval `tset -s -Q`
167 # generic shell prompt
168 [ "$LOGNAME" = "root" ] \
169 && PS1="<$HOSTNAME> # " \
170 || PS1="<$HOSTNAME> \$ "
172 # Reminders (once every 60 minutes)
173 if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
174 [ -e ~/.ConfigScripts.debug ] && echo " - Reminders ..."
175 if [ "$(type -t icalBuddy >/dev/null)" -a "$LOGNAME" != "root" ]; then
178 *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
179 *) bul="*"; bul_imp="!"; sep=">"; ;;
181 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
182 -nc -npn -iep "title,due" -stda \
183 tasksDueBefore:today 2>/dev/null
184 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
185 -nc -npn -iep "title,datetime" \
186 eventsToday+1 2>/dev/null
188 unset bul bul_imp sep
191 if [ "$(type -t remind >/dev/null)" -a -r ~/.remind ]; then
192 remind -h -g -t5 ~/.remind | \
193 grep -v '^Reminders for ' | grep -v '^$'
197 [ -w ~/ ] && touch ~/.last_reminder
200 # bash-specific initialization
201 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
202 && source /etc/bash.bashrc
203 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
204 && source /etc/bashrc
206 # ksh-specific initialization
207 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
210 # Check filesystem quotas
211 mount 2>/dev/null | grep quota >/dev/null 2>&1
212 if [ $? -eq 0 ]; then
213 type -t quota >/dev/null && quota -q