initial
[zsh.git] / .zsh / zshenv
1 # -*- mode: sh;-*-
2 ############
3 #
4 # .zshenv
5 # Written by Joerg Jaspert <joerg@debian.org>
6 #
7 ############
8
9 # We (may) use those variables wherever, so fill them now.
10 # Avoids calling the processes all the time we need em.
11 OSNAME=`uname -s`
12 USER=${USER:-`whoami`}
13 UID=${UID:-`id -u`}
14 # :r strips "extension" (a . followed by 0 or more characters)
15 HOST=$HOST:r:r
16 HOST=${HOST:-$(hostname -s)}
17 DOMAIN=${DOMAIN:-$(hostname -d 2>&-)}
18 [ "$DOMAIN" = "" -o "$DOMAIN" = "localdomain" -o "$DOMAIN" = "(none)" ] && DOMAIN=$(grep "^search " /etc/resolv.conf | cut -d' ' -f2)
19
20 [ -f /etc/debian_version ] && DISTRI="Debian"
21
22 DEBUG=${DEBUG:-no}
23
24 # Path to search for autoloadable functions.
25 fpath=( $HOME/.zsh/functions $HOME/zsh "$fpath[@]" )
26 # Only unique entries please.
27 typeset -U fpath
28 export fpath
29
30 # Include function path in script path so that we can run them even
31 # though a subshell may not know about functions.
32 # PATH should already be exported, but in case not. . .
33 path=(
34 lala
35 "$HOME/bin"
36 /usr/local/bin
37 /bin
38 /usr/bin
39 /srv/qa.debian.org/mia
40 /usr/X11/bin
41 /usr/bin/X11
42 /usr/local/X11/bin
43 /usr/local/games
44 /usr/games
45 /usr/lib/nagios/plugins
46 "$fpath[@]"
47 "$path[@]"
48 "$PATH[@]"
49 )
50 if [ "`id -u`" = "0" ] || ! [ -x /usr/bin/id ]; then
51 path=(
52 "$path[@]"
53 /usr/local/sbin
54 /usr/sbin
55 /sbin
56 )
57 fi
58
59 # Only unique entries please.
60 typeset -U path
61 # Remove entries that don't exist on this system. Just for sanity's
62 # sake more than anything.
63 path=( ${^path}(N-/) )
64
65 export PATH USER HOST DOMAIN UID
66
67 # Now that FPATH is set correctly, do autoloaded functions.
68 # autoload all functions in $FPATH - that is, all files in
69 # each component of the array $fpath. If there are none, feed the list
70 # it prints into /dev/null.
71 for paths in "$fpath[@]"; do
72 autoload -U "$paths"/*(N:t) >/dev/null
73 done
74 unset paths
75
76 # Command to use when redirecting from/to a null command.
77 # READNULLCMD is redefined in .zshrc for interactive shells.
78 READNULLCMD=cat
79 NULLCMD=cat
80
81 # Unix groups: remember the original group ID. (For prompts.)
82 if [[ ${+ORIGGID} -eq 0 ]]; then
83 export ORIGGID="$GID"
84 fi
85