]> err.no Git - dotfiles/blob - environment
loosen font specs a bit
[dotfiles] / environment
1 # POSIX -*- sh -*-
2 #
3
4 LS_OPTIONS=
5 for lsopt in -B --color=auto -FN; do
6     ls $lsopt > /dev/null 2>&1 && LS_OPTIONS="$LS_OPTIONS $lsopt"
7 done
8
9 if [ `uname -s` = "FreeBSD" ] && alias | grep -q "ls="; then
10     unalias ls
11 fi
12
13 GREP_OPTIONS=
14 for grepopt in --colour=auto; do
15     grep -q $grepopt . /etc/passwd && GREP_OPTIONS="$GREP_OPTIONS $grepopt"
16 done
17
18 findcommand() {
19     while [ "$#" -ge 1 ]; do
20         P="$PATH"
21         while [ "$P" ]; do 
22             D=${P%%:*}
23             P=${P#*:}
24             if [ "$D" = "$P" ]; then
25                 P=
26             fi
27             if [ -z "$D" ]; then
28                 D=.
29             fi
30             if [ -x "$D/$1" ]; then
31                 echo "$D/$1"
32                 return 0
33             fi
34         done
35         shift
36     done
37     return 1
38 }
39
40 nod () {
41     NOD="$HOME/Desktop/NoD.txt"
42     if ! [ -f "$NOD" ]; then 
43         echo "No ~/Desktop/NoD.txt"
44         exit 1
45     fi
46     if ! grep -q $(date -I) ${NOD}; then
47         printf "\n%s:\n\n- Mail, IRC, etc\n" $(date -I) >> ${NOD}
48     fi
49     printf "- %s" "$@">> ${NOD}
50     vim + ${NOD}
51 }
52
53 meetingdate () {
54     TIME=$1
55     TZMEETING=$2
56     TZ=${TZ:=$3}
57     date -d "$(TZ=$TZMEETING date --rfc-822 -d "$TIME")"
58 }
59
60 blog () {
61     pushd $(pwd)
62     if [ ! -d "$HOME/blog" ]; then
63         echo "You don't have your blog checked out here.  Can't blog."
64         return 1
65     fi
66     if [ "$1" ]; then
67         CAT="$1"
68     else
69         CAT="/"
70     fi
71
72     if [ "$2" ]; then
73         SUBJ="$(echo $2 | tr ' ' '_')"
74     else
75         SUBJ="blank_subject"
76     fi
77     DIR=$HOME/blog/$CAT/
78     FILE=$(date +"%Y-%m-%d-%H-%M")_$SUBJ.txt
79     cd $DIR
80     $EDITOR $FILE
81     if [ "$OFFLINE" != "1" ]; then
82         svn add $FILE
83         svn ci -m"Initial commit" $FILE
84     fi
85     popd
86 }
87
88 apache2Release()
89 {
90     A2ROOT=http://svn.clearairturbulence.org/apache2/trunk
91     if [ "$1" = "release" ]; then
92         DBCMD='debuild';
93     else
94         DBCMD='dpkg-buildpackage -rfakeroot -uc -us';
95     fi
96     pushd > /dev/null;
97     [ ! -d /tmp/debian ] && mkdir -p /tmp/debian
98     svn cat "$A2ROOT/debian/changelog" > /tmp/debian/changelog;
99     cd /tmp && VER=$(dpkg-parsechangelog|grep urgency|sed -e 's/.*(\(.*\)-.*).*/\1/');
100     popd > /dev/null;
101     rm -r apache2-$VER apache2_$VER*diff.gz apache2_$VER*-*;
102     svn export "$A2ROOT" apache2-$VER;
103     if [ ! -f apache2_$VER.orig.tar.gz ]; then
104         cd apache2-$VER && fakeroot debian/rules clean && cd ..;
105         mv apache2-$VER/debian ./debian-$VER;
106         tar czf apache2_$VER.orig.tar.gz apache2-$VER;
107         mv debian-$VER apache2-$VER/debian;
108     fi
109     cd apache2-$VER && $DBCMD && cd ..;
110 }
111
112 is_debian () {
113     if [ -f /etc/debian_version ]; then
114         return 0
115     fi
116     return 1
117 }
118
119 removepathelem () {
120     PATH=$(echo "$PATH" | sed -e "s,:*$1:,:,g" -e "s,::,:,g")
121 }
122
123 setpathifdir () {
124     if [ -d "$1" ]; then
125         removepathelem "$1"
126         PATH="$1:$PATH"
127     fi
128 }
129
130 appendpathifdir () {
131     if [ -d "$1" ]; then
132         removepathelem "$1"
133         PATH="$PATH:$1"
134     fi
135 }
136
137 busstuc () {
138         echo "lang=nor&quest=$@" | \
139         xargs -0 -i wget -q -O - --post-data {} http://www.idi.ntnu.no/~tagore/cgi-bin/busstuc/busq.cgi| \
140         html2text -width 1000| \
141         sed '/[[:alpha:]]/p;d'
142 }
143
144 if is_debian; then
145     appendpathifdir /store/gnu/bin
146     appendpathifdir /store/bin
147 else
148     setpathifdir /store/gnu/bin
149     setpathifdir /store/bin
150 fi
151 setpathifdir /usr/local/bin
152 setpathifdir $HOME/usr/bin
153 setpathifdir $HOME/bin
154 appendpathifdir /usr/sbin
155 appendpathifdir /sbin
156
157 if [ `id -u` = "0" ]; then 
158     setpathifdir /sbin
159     setpathifdir /usr/sbin
160     setpathifdir /usr/local/sbin
161     setpathifdir /local/sbin
162 fi
163
164 CVSROOT=~/data/cvs
165 EDITOR=emacs
166 TZ=CET
167 WWW_HOME=http://localhost/~tfheen/services.html
168 test -x "$HOME/bin/lesspipe.sh" && LESSOPEN="|$HOME/bin/lesspipe.sh '%s'"
169 test -x "$HOME/bin/lesspipe" && LESSOPEN="|$HOME/bin/lesspipe '%s'"
170 LESS="-m"
171 RSYNC_RSH=ssh
172 CVS_RSH=ssh
173 #MAIL=/var/spool/mail/tfheen
174 DEBEMAIL=tfheen@debian.org
175 DEBFULLNAME="Tollef Fog Heen"
176 CVSEDITOR="emacs -nw"
177 SVN_EDITOR="emacs -nw"
178 XTERM=$(findcommand gnome-terminal pterm Eterm xterm)
179 PAGER=less
180 GNUSTEP_USER_ROOT="$HOME/.GNUstep"
181 OOO_DISABLE_RECOVERY=True
182 GTK_IM_MODULE=xim
183
184 CHROOT=""
185 if [ -f /etc/debian_chroot ]; then
186     CHROOT="($(cat /etc/debian_chroot | tr -d '\n'))"
187 fi
188
189 if test `uname -s` = "Linux" && test `uname -m` = i686; then
190     ldlib=ld-linux.so.2
191 fi
192
193 case `uname -s` in
194     *BSD|SunOS)
195         HOSTNAME=`/bin/hostname`
196         DOMAINNAME=`/bin/hostname | cut -d. -f 2-`
197         ;;
198     Linux)
199         HOSTNAME=`/bin/hostname -f`
200         DOMAINNAME=`/bin/hostname -f | cut -d. -f 2-`
201         ;;
202 esac
203
204 if [ -z "$LANG" ] || [ "$LANG" = "C" ]; then
205     if findcommand locale >/dev/null; then
206         if locale -a | grep -q '^nb_NO.utf8$' ; then
207             LANG=nb_NO.UTF-8
208         elif locale -a | grep -q '^en_US.utf8$'; then
209             LANG=en_US.UTF-8
210         fi
211     fi
212 fi
213
214 if [ -z "$LANG" ] || [ "$LANG" = "C" ]; then
215     if findcommand localedef >/dev/null; then
216         localedef --list-archive > /dev/null 2>&1
217         if test "$?" = "0"; then
218             if localedef --list-archive | grep -q '^no_NO$' ; then
219                 LANG=no_NO
220             elif localedef --list-archive | grep -q '^en_US$'; then
221                 LANG=en_US
222             fi
223         fi
224     fi
225 fi
226
227 case "$DOMAINNAME" in
228     samfundet*)
229         mesg y
230         EMAIL=tfheen@samfundet.no
231         ;;
232     *)
233         :
234         ;;
235 esac
236
237 removepathelem "\\."
238
239 export WINDOW_MANAGER=$(findcommand openbox metacity twm)
240
241 export LS_OPTIONS CVSROOT EDITOR TZ WWW_HOME LESSOPEN LESS RSYNC_RSH
242 export CVS_RSH LANG DEBEMAIL CVSEDITOR ldlib HOSTNAME DOMAINNAME PATH 
243 export EMAIL XTERM SVN_EDITOR GNUSTEP_USER_ROOT GREP_OPTIONS 
244 export OOO_DISABLE_RECOVERY GTK_IM_MODULE
245
246 if [ -f "$HOME/.gnupg/gpg-agent-info-$HOSTNAME" ]; then
247     . "$HOME/.gnupg/gpg-agent-info-$HOSTNAME"
248 elif [ -f "$HOME/.gnupg/gpg-agent-info-$(hostname)" ]; then
249     . "$HOME/.gnupg/gpg-agent-info-$(hostname)"
250 fi