zshrc: rely only on `uname -n` for $HOSTNAME handling
[grml-etc-core.git] / etc / zsh / zshenv
1 # Filename:      zshenv
2 # Purpose:       system-wide .zshenv file for zsh(1)
3 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
4 # Bug-Reports:   see http://grml.org/bugs/
5 # License:       This file is licensed under the GPL v2.
6 ################################################################################
7 # This file is sourced on all invocations of the shell.
8 # It is the 1st file zsh reads; it's read for every shell,
9 # even if started with -f (setopt NO_RCS), all other
10 # initialization files are skipped.
11 #
12 # This file should contain commands to set the command
13 # search path, plus other important environment variables.
14 # This file should not contain commands that produce
15 # output or assume the shell is attached to a tty.
16 #
17 # Notice: .zshenv is the same, execpt that it's not read
18 # if zsh is started with -f
19 #
20 # Global Order: zshenv, zprofile, zshrc, zlogin
21 ################################################################################
22
23 # language settings (read in /etc/environment before /etc/default/locale as
24 # the latter one is the default on Debian nowadays)
25 # no xsource() here because it's only created in zshrc! (which is good)
26 [[ -r /etc/environment ]] && source /etc/environment
27
28 # set environment variables (important for autologin on tty)
29 if [ -n "${HOSTNAME}" ] ; then
30     export HOSTNAME="${HOSTNAME}"
31 else
32     export HOSTNAME="$(uname -n)"
33 fi
34
35 # make sure /usr/bin/id is available
36 if [[ -x /usr/bin/id ]] ; then
37     [[ -z "$USER" ]]          && export USER=$(/usr/bin/id -un)
38     [[ $LOGNAME == LOGIN ]] && LOGNAME=$(/usr/bin/id -un)
39 fi
40
41 # workaround for live-cd mode as $HOME is not set via rungetty
42 if [[ -f /etc/grml_cd ]] ; then
43     if (( EUID == 0 )); then
44         export HOME=/root
45     else
46         export HOME=/home/$USER
47     fi
48 fi
49
50 ## set $PATH
51 # gentoo users have to source /etc/profile.env
52 if [[ -r /etc/gentoo-release ]] ; then
53     [[ -r /etc/profile.env ]] && source /etc/profile.env
54 fi
55
56 # support extra scripts/software in special directory outside of squashfs environment in live mode
57 if [[ -f /etc/grml_cd ]] ; then
58   [[ -r /run/live/medium/scripts ]] && ADDONS='/run/live/medium/scripts'
59   [[ -r /etc/grml/my_path ]] && ADDONS="$(cat /etc/grml/my_path)"
60 fi
61
62 # Solaris
63 case $(uname 2>/dev/null) in
64   SunOS)
65     path=(
66       /usr/bin
67       /usr/sbin
68       /usr/ccs/bin
69       /opt/SUNWspro/bin
70       /usr/ucb
71       /usr/sfw/bin
72       /usr/gnu/bin
73       /usr/openwin/bin
74       /opt/csw/bin
75       /sbin
76       ~/bin
77     )
78 esac
79
80 # generic $PATH handling
81 if (( EUID != 0 )); then
82   path=(
83     $HOME/bin
84     /usr/local/bin
85     /usr/bin
86     /bin
87     /usr/local/sbin
88     /usr/sbin
89     /sbin
90     /usr/local/games
91     /usr/games
92     "${ADDONS}"
93     "${path[@]}"
94   )
95 else
96   path=(
97     $HOME/bin
98     /usr/local/sbin
99     /usr/local/bin
100     /sbin
101     /bin
102     /usr/sbin
103     /usr/bin
104     "${ADDONS}"
105     "${path[@]}"
106   )
107 fi
108
109 # remove empty components to avoid '::' ending up + resulting in './' being in $PATH
110 path=( "${path[@]:#}" )
111
112 typeset -U path
113
114 # less (:=pager) options:
115 #  export LESS=C
116 typeset -a lp; lp=( ${^path}/lesspipe(N) )
117 if (( $#lp > 0 )) && [[ -x $lp[1] ]] ; then
118     export LESSOPEN="|lesspipe %s"
119 elif [[ -x /usr/bin/lesspipe.sh ]] ; then
120     export LESSOPEN="|lesspipe.sh %s"
121 fi
122 unset lp
123
124 export READNULLCMD=${PAGER:-/usr/bin/pager}
125
126 # allow zeroconf for distcc
127 export DISTCC_HOSTS="+zeroconf"
128
129 # MAKEDEV should be usable on udev as well by default:
130 export WRITE_ON_UDEV=yes
131
132 ## END OF FILE #################################################################
133 # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4