]> arthur.barton.de Git - ConfigScripts.git/blob - sys/profile
Make locale setting much more smarter
[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-2011 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 # Indicates LC_CTYPE an UTF-8 terminal?
17 [ -n "$LC_CTYPE" ] \
18         && LC_encoding="${LC_CTYPE#*.}" || LC_encoding="ISO8859-1"
19 # Set locale if it is not set or doesn't contain a dot:
20 [ "$LANG" = "${LANG#*.}" -a "$LANG" != "C" ] \
21         && export LANG="${LANG:-de_DE}.${LC_encoding}"
22 # All system messages should still be in "native" ("C") language:
23 export LC_MESSAGES="C"
24 # Clean up ...
25 unset LC_CTYPE LC_encoding
26
27 # Initialize PATH variable
28 if [ -x /usr/libexec/path_helper ]; then
29         eval `/usr/libexec/path_helper -s`
30 else
31         PATH="/usr/local/bin:/usr/bin:/bin"
32         [ "$UID" -eq 0 ] && PATH="/usr/local/sbin:/usr/sbin:/sbin:$PATH"
33         export PATH
34 fi
35 # prepend optional directories to PATH ...
36 path=""
37 for d in /Developer/usr/bin /usr/pkg/bin /usr/lib/ccache /opt/*/bin; do
38         [ -d "$d" -o -h "$d" ] && path="$path$d:"
39 done
40 [ -n "$path" ] && PATH="$path$PATH"
41 if [ "$UID" -eq 0 ]; then
42         path=""
43         for d in /usr/pkg/sbin /opt/*/sbin; do
44                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
45         done
46         [ -n "$path" ] && PATH="$path$PATH"
47 fi
48 # append optional directories to PATH ...
49 for d in /usr/bin/X11 /usr/games; do
50         [ -d "$d" -o -h "$d" ] && PATH="$PATH:$d"
51 done
52 # set PATH so it includes user's private executables
53 [ -d ~/Applications ] && PATH=~/Applications:"${PATH}"
54 [ -d ~/bin ] && PATH=~/bin:"${PATH}"
55 [ -d ~/sbin ] && PATH=~/sbin:"${PATH}"
56
57 # Setup MANPATH, if manpath(1) isn't available
58 if [ ! "$(type manpath 2>/dev/null)" ]; then
59         [ -z "$MANPATH" ] \
60                 && MANPATH="/usr/local/share/man:/usr/share/man:/usr/man"
61         path=""
62         for d in /usr/pkg/share/man /usr/pkg/man /opt/*/share/man /opt/*/man; do
63                 [ -d "$d" -o -h "$d" ] && path="$path$d:"
64         done
65         [ -n "$path" ] && MANPATH="$path$MANPATH"
66         [ -d ~/share/man ] && MANPATH=~/share/man:"${MANPATH}"
67         [ -d ~/man ] && MANPATH=~/man:"${MANPATH}"
68 fi
69
70 # set variable identifying the chroot you work in
71 [ -r /etc/debian_chroot ] && chroot_name=$(cat /etc/debian_chroot)
72 [ -r /etc/chroot_name ] && chroot_name=$(cat /etc/chroot_name)
73
74 # validate terminal definition
75 [ -z "$TERM" ] && eval `tset -s -Q`
76
77 # make sure $UID and $USER is set
78 [ -z "$UID" ] && UID=`id -u`
79 [ -z "$USER" ] && USER=`id -un`
80 export UID USER
81
82 # get my own hostname
83 ME=`hostname 2>/dev/null`
84 export ME
85
86 # Move Xauthority file to local storage, so that sudo et all work
87 if [ -z "$XAUTHORITY" -a -r ~/.Xauthority ]; then
88         cp ~/.Xauthority /tmp/Xauthority-$USER
89         chmod 600 /tmp/Xauthority-$USER
90         export XAUTHORITY="/tmp/Xauthority-$USER"
91 fi
92
93 # read profile additions
94 if [ -d /etc/profile.d ]; then
95         for f in /etc/profile.d/*; do
96                 [ -r "$f" ] || continue
97                 case "$f" in
98                         *.csh)
99                                 ;;
100                         *)
101                                 [ -e ~/.ConfigScripts.debug ] \
102                                         && echo " >> $f ..."
103                                 . "$f"
104                 esac
105         done
106 fi
107
108 # read local profile, if available
109 [ -r "/var/lib/${ME}/profile" ] && . /var/lib/${ME}/profile
110
111 # Setup some directories to use local storage (no NFS)
112 [ -d "/usr/local/home/$USER" ] \
113         || mkdir -p "/usr/local/home/$USER" >/dev/null 2>&1
114 if [ -w "/usr/local/home/$USER" ]; then
115         export LOCAL_HOME="/usr/local/home/$USER"
116         export CCACHE_DIR="$LOCAL_HOME/.ccache"
117         export XDG_CACHE_HOME="$LOCAL_HOME/.cache"
118 fi
119
120 # interactive shell?
121 [ "$PS1" ] || return
122
123 # generic shell prompt
124 [ "$UID" -eq 0 ] \
125         && PS1="<$ME> # " \
126         || PS1="<$ME> \$ "
127
128 # icalBuddy(1)
129 type -p icalBuddy >/dev/null 2>&1
130 if [ $? -eq 0 -a "$UID" -ne 0 ]; then
131         case "$LANG" in
132                 *.UTF*) BUL="•"; SEP="»"; ;;
133                 *)      BUL="*"; SEP=">"; ;;
134         esac
135         icalBuddy -f -n -npn -nc -b " $BUL " -ps "/ $SEP /" -eep "url,notes" \
136                 eventsToday+1 | grep "$BUL"
137         [ $? -eq 0 ] && echo
138 else
139         # remind(1)
140         type -p remind >/dev/null 2>&1
141         if [ $? -eq 0 -a -r ~/.remind ]; then
142                 remind -h -g -t5 .remind | grep "^[0-9]"
143                 [ $? -eq 0 ] && echo
144         fi
145 fi
146
147 # bash-specific initialization
148 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bash.bashrc ] \
149         && source /etc/bash.bashrc
150 [ "$BASH" -a -z "$BASHRCREAD" -a -r /etc/bashrc ] \
151         && source /etc/bashrc
152
153 # ksh-specific initialization
154 [ "$KSH_VERSION" -a -z "$KSHRCREAD" -a -r /etc/ksh.kshrc ] \
155         && . /etc/ksh.kshrc
156
157 # Check filesystem quotas
158 mount 2>/dev/null | grep quota >/dev/null 2>&1
159 if [ $? -eq 0 ]; then
160         which quota >/dev/null 2>&1
161         [ $? -eq 0 ] && quota -q
162 fi
163
164 # -eof-