]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
Use local variables to customize icalBuddy
[ConfigScripts.git] / sys / profile
1 #
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)
5 #
6
7 [ -e ~/.ConfigScripts.debug ] && echo " >> /etc/profile ..."
8
9 PROFILEREAD="true"
10 export PROFILEREAD
11
12 # Make sure UID is set
13 [ -n "$UID" ] || UID=`id -u`
14 export UID
15
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\""
21 fi
22 # Does LC_CTYPE or LANG indicate an UTF-8 terminal?
23 LC_encoding=""
24 if [ -n "$LC_CTYPE" ]; then
25         LC_encoding="${LC_CTYPE#*.}"
26 elif [ -n "$LANG" ]; then
27         LC_encoding="${LANG#*.}"
28 fi
29 if [ -z "$LC_encoding" ]; then
30         case "$TERM" in
31                 "xterm-"*)
32                         LC_encoding="UTF-8"; ;;
33                 *)
34                         LC_encoding="ISO8859-1"
35         esac
36 fi
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)"
42 # Clean up ...
43 unset LC_CTYPE LC_encoding 2>/dev/null
44
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"
52 else
53         PATH="/usr/local/bin:/usr/bin:/bin"
54         [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
55         export PATH
56 fi
57 # prepend optional directories to PATH ...
58 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:"
62         fi
63 done
64 [ -n "$path" ] && PATH="$path$PATH"
65 if [ "$UID" -eq 0 ]; then
66         path=""
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:"
70                 fi
71         done
72         [ -n "$path" ] && PATH="$path$PATH"
73 fi
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"
78         fi
79 done
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}"
87
88 # Setup MANPATH, if manpath(1) isn't available
89 if [ ! "$(type manpath 2>/dev/null)" ]; then
90         [ -z "$MANPATH" ] \
91                 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
92         path=""
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:"
95         done
96         [ -n "$path" ] && MANPATH="$path$MANPATH"
97         [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
98         [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
99 fi
100
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)
104
105 # make sure $UID and $USER is set
106 [ -z "$UID" ] && UID=`id -u`
107 [ -z "$USER" ] && USER=`id -un`
108 export UID USER
109
110 # get my own hostname
111 ME=`hostname 2>/dev/null`
112 export ME
113
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"
119 fi
120
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
125                 case "$f" in
126                         *.csh)
127                                 ;;
128                         *)
129                                 [ -e ~/.ConfigScripts.debug ] \
130                                         && echo " >> $f ..."
131                                 . "$f"
132                 esac
133         done
134 fi
135
136 # read local profile, if available
137 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
138
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"
146 fi
147
148 # interactive shell?
149 [ "$PS1" ] || return
150
151 # validate terminal definition
152 type -p tset >/dev/null 2>&1
153 [ $? -eq 0 ] && eval `tset -s -Q`
154
155 # generic shell prompt
156 [ "$UID" -eq 0 ] \
157         && PS1="<$ME> # " \
158         || PS1="<$ME> \$ "
159
160 # icalBuddy(1)
161 type -p icalBuddy >/dev/null 2>&1
162 if [ $? -eq 0 -a "$UID" -ne 0 ]; then
163         case "$LANG" in
164                 *.UTF*) bul="•"; bul_imp="!"; sep="»"; ;;
165                 *)      bul="*"; bul_imp="!"; sep=">"; ;;
166         esac
167         icalBuddy -f -n -npn -nc -b " $BUL " -ps "/ $SEP /" -eep "url,notes" \
168                 eventsToday+1 2>/dev/null | grep "$BUL"
169         [ $? -eq 0 ] && echo
170         unset bul bul_imp sep
171 else
172         # remind(1)
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 '^$'
177                 [ $? -eq 0 ] && echo
178         fi
179 fi
180
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
186
187 # ksh-specific initialization
188 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
189         && . /etc/ksh.kshrc
190
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
196 fi
197
198 # -eof-