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 # Setup locale and encoding
15 if [ -e ~/.ConfigScripts.debug ]; then
16 echo " - TERM=\"$TERM\""
17 echo " - LANG=\"$LANG\""
18 echo " - LC_CTYPE=\"$LC_CTYPE\""
20 # Does LC_CTYPE or LANG indicate an UTF-8 terminal?
22 if [ -n "$LC_CTYPE" ]; then
23 LC_encoding=`echo "$LC_CTYPE" | cut -d. -f2- -s`
24 elif [ -n "$LANG" ]; then
25 LC_encoding=`echo "$LANG" | cut -d. -f2- -s`
27 if [ -z "$LC_encoding" ]; then
30 LC_encoding="UTF-8"; ;;
32 LC_encoding="ISO8859-1"
35 [ -e ~/.ConfigScripts.debug ] && echo " - LC_encoding=\"$LC_encoding\" (temp)"
36 # Set locale if it is not set or doesn't contain a dot:
37 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
38 && export LANG="${LANG:-de_DE}.${LC_encoding}"
39 [ -e ~/.ConfigScripts.debug ] && echo " - LANG=\"$LANG\" (new)"
41 unset LC_CTYPE LC_encoding 2>/dev/null
44 # Use "xterm-256color" for xterm's (and the like) when it is available
45 [ "$TERM" = "xterm" -a -r "/usr/share/terminfo/x/xterm+256color" ] \
46 && export TERM="xterm-256color"
47 # Don't use "xterm-256color" when it is not available
48 [ "$TERM" = "xterm-256color" -a -r "/usr/share/terminfo/x/xterm+256color" ] \
49 || export TERM="xterm"
51 # Initialize PATH variable
52 if [ -x /usr/libexec/path_helper ]; then
53 eval `/usr/libexec/path_helper -s \
54 | sed "s|:/usr/local/bin||" | sed "s|:/usr/local/sbin||"`
55 [[ "$PATH" == *sbin* ]] \
56 && PATH="/usr/local/bin:/usr/local/sbin:$PATH" \
57 || PATH="/usr/local/bin:$PATH"
59 PATH="/usr/local/bin:/usr/bin:/bin"
60 [ "$LOGNAME" = "root" ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
63 # prepend optional directories to PATH ...
66 /usr/local/opt/ccache/libexec \
73 if [ -d "$d" -o -h "$d" ]; then
74 [ -e "$d/.not_in_path" ] || path="$path$d:"
77 [ -n "$path" ] && PATH="$path$PATH"
79 if [ "$LOGNAME" = "root" ]; then
84 if [ -d "$d" -o -h "$d" ]; then
85 [ -e "$d/.not_in_path" ] || path="$path$d:"
88 [ -n "$path" ] && PATH="$path$PATH"
91 # append optional directories to PATH ...
97 if [ -d "$d" -o -h "$d" ]; then
98 [ -e "$d/.not_in_path" ] || PATH="$PATH:$d"
102 # set PATH so it includes user's private executables
103 [ -d ~/Applications -a ! -e ~/Applications/.not_in_path ] \
104 && PATH=~/Applications:"${PATH}"
105 [ -d ~/bin -a ! -e ~/bin/.not_in_path ] \
106 && PATH=~/bin:"${PATH}"
107 [ -d ~/sbin -a ! -e ~/sbin/.not_in_path ] \
108 && PATH=~/sbin:"${PATH}"
110 # Setup MANPATH, if manpath(1) isn't available
111 if [ ! "$(type -t manpath 2>/dev/null)" ]; then
113 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
121 [ -d "$d" -o -h "$d" ] && path="$path$d:"
123 [ -n "$path" ] && MANPATH="$path$MANPATH"
124 [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
125 [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
129 # set variable identifying the chroot you work in
130 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
131 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
133 # get my own hostname
134 [ -n "$HOSTNAME" ] || HOSTNAME=`hostname 2>/dev/null`
137 # Setup local home directory, when available
138 [ -d "/usr/local/home" -a ! -d "/usr/local/home/$LOGNAME" ] \
139 && mkdir "/usr/local/home/$LOGNAME" >/dev/null 2>&1
140 [ -w "/usr/local/home/$LOGNAME" ] \
141 && export LOCAL_HOME="/usr/local/home/$LOGNAME" \
142 || export LOCAL_HOME="$HOME"
144 # Source "~/.profile.user-1st", when available
145 [ -r ~/.profile.user-1st ] && . ~/.profile.user-1st
147 # Setup environment to use local storage (no NFS, if possible!)
148 export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
150 # Setup environment for ccache, if installed
151 type -t ccache >/dev/null && export CCACHE_DIR="$XDG_CACHE_HOME/ccache"
153 # Setup environment for Python "pip", if installed
154 if [ "$(type -t pip 2>/dev/null)" ]; then
155 export PIP_REQUIRE_VIRTUALENV=true
156 export PIP_DOWNLOAD_CACHE="$XDG_CACHE_HOME/pip"
159 # Move Xauthority file to local storage, so that sudo et all work
160 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
161 cp ~/.Xauthority /tmp/Xauthority-$LOGNAME
162 chmod 600 /tmp/Xauthority-$LOGNAME
163 export XAUTHORITY="/tmp/Xauthority-$LOGNAME"
166 # read profile additions
167 if [ -d /etc/profile.d -o -d /usr/local/etc/profile.d ]; then
170 /usr/local/etc/profile.d/*
172 [ -r "$f" ] || continue
177 [ -e ~/.ConfigScripts.debug ] \
185 # read local profile, if available
186 [ -r "/var/lib/${HOSTNAME}/profile" ] && . /var/lib/${HOSTNAME}/profile
194 # validate terminal definition
195 type -t tset >/dev/null && eval `tset -s -Q`
197 # generic shell prompt
198 [ "$LOGNAME" = "root" ] \
199 && PS1="<$HOSTNAME> # " \
200 || PS1="<$HOSTNAME> \$ "
202 # Reminders (once every 60 minutes)
203 if [ -z `find ~/.last_reminder -mmin -60 2>/dev/null` ]; then
204 [ -e ~/.ConfigScripts.debug ] && echo " - Reminders ..."
205 if [ "$(type -t icalBuddy >/dev/null)" -a "$LOGNAME" != "root" ]; then
208 *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
209 *) bul="*"; bul_imp="!"; sep=">"; ;;
211 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
212 -nc -npn -iep "title,due" -stda \
213 tasksDueBefore:today 2>/dev/null
214 icalBuddy -f -n -b " $bul " -ab " $bul_imp " -ps "/ $sep /" \
215 -nc -npn -iep "title,datetime" \
216 eventsToday+1 2>/dev/null
218 unset bul bul_imp sep
221 if [ "$(type -t remind >/dev/null)" -a -r ~/.remind ]; then
222 remind -h -g -t5 ~/.remind | \
223 grep -v '^Reminders for ' | grep -v '^$'
227 [ -w ~/ ] && touch ~/.last_reminder
230 # bash-specific initialization
231 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
232 && source /etc/bash.bashrc
233 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
234 && source /etc/bashrc
236 # ksh-specific initialization
237 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
240 # Check filesystem quotas
241 mount 2>/dev/null | grep quota >/dev/null 2>&1
242 if [ $? -eq 0 ]; then
243 type -t quota >/dev/null && quota -q