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