Add support for ${HOME}/.zshenv; set $PATH on Solaris/SunOS
[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 # Latest change: Sam Mai 17 22:52:27 CEST 2008 [mika]
7 ################################################################################
8 # This file is sourced on all invocations of the shell.
9 # It is the 1st file zsh reads; it's read for every shell,
10 # even if started with -f (setopt NO_RCS), all other
11 # initialization files are skipped.
12 #
13 # This file should contain commands to set the command
14 # search path, plus other important environment variables.
15 # This file should not contain commands that produce
16 # output or assume the shell is attached to a tty.
17 #
18 # Notice: .zshenv is the same, execpt that it's not read
19 # if zsh is started with -f
20 #
21 # Global Order: zshenv, zprofile, zshrc, zlogin
22 ################################################################################
23
24 # support ${HOME}/.zshenv:
25 if [[ -z "$ALREADY_SOURCED_ZSHENV" ]] ; then
26    export ALREADY_SOURCED_ZSHENV=1
27 fi
28
29 # language settings (read in /etc/environment before /etc/default/locale as
30 # the latter one is the default on Debian nowadays)
31 # no xsource() here because it's only created in zshrc! (which is good)
32 [[ -r /etc/environment ]] && source /etc/environment
33
34 # set environment variables (important for autologin on tty)
35 export HOSTNAME=${HOSTNAME:-$(hostname)}
36
37 # make sure /usr/bin/id is available
38 if [[ -x /usr/bin/id ]] ; then
39     [[ -z "$USER" ]]          && export USER=$(/usr/bin/id -un)
40     [[ $LOGNAME == LOGIN ]] && LOGNAME=$(/usr/bin/id -un)
41 fi
42
43 # workaround for live-cd mode as $HOME is not set via rungetty
44 if [[ -f /etc/grml_cd ]] ; then
45     if (( EUID == 0 )); then
46         export HOME=/root
47     else
48         export HOME=/home/$USER
49     fi
50 fi
51
52 # set $PATH
53 # gentoo users have to source /etc/profile.env
54 if [[ -r /etc/gentoo-release ]] ; then
55
56     [[ -r /etc/profile.env ]] && source /etc/profile.env
57
58     if (( EUID != 0 )); then
59         PATH="$HOME/bin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/games:/usr/NX/bin:$PATH"
60     else
61         PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/NX/bin:$PATH"
62     fi
63 else
64 # support extra software in special directory outside of squashfs environment in live-cd mode
65     if [[ -f /etc/grml_cd ]] ; then
66        [[ -r /cdrom/addons ]]      && ADDONS=':/cdrom/addons'
67        [[ -r /live/image/addons ]] && ADDONS=':/live/image/addons'
68        [[ -r /etc/grml/my_path ]]  && ADDONS=":$(cat /etc/grml/my_path)"
69     fi
70
71     if (( EUID != 0 )); then
72         PATH="$HOME/bin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/games:/usr/NX/bin$ADDONS"
73     else
74         PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/local/bin:/usr/NX/bin$ADDONS"
75     fi
76 fi
77
78 # Solaris
79 case $(uname 2>/dev/null) in
80   SunOS)
81      PATH="/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/SUNWspro/bin:/usr/ucb:/usr/sfw/bin:/usr/gnu/bin:/usr/openwin/bin:/opt/csw/bin:/opt/swf/bin:/sbin:/usr/sbin:~/bin"
82      # LD_LIBRARY_PATH="/opt/csw/lib:/opt/sfw/lib:/usr/lib:/usr/local/lib:/usr/ccs/lib:/usr/openwin/lib:/usr/ucb/lib"
83      # MANPATH="$MANPATH:/opt/csw/man:/usr/man:/usr/share/man:/usr/local/man:/opt/sfw/man"
84 esac
85
86 # less (:=pager) options:
87 #  export LESS=C
88 if [[ -x /usr/bin/lesspipe.sh ]] ; then
89     export LESSOPEN="|lesspipe.sh %s"
90 elif [[ -x /usr/bin/lesspipe ]] ; then
91     export LESSOPEN="|lesspipe %s"
92 fi
93 export READNULLCMD=${PAGER:-/usr/bin/pager}
94
95 # support termcap colors when using PAGER=less:
96 # TODO: move these to zshrc, they are only relevant in interactive shells
97 export LESS_TERMCAP_mb=$'\E[01;31m'
98 export LESS_TERMCAP_md=$'\E[01;31m'
99 export LESS_TERMCAP_me=$'\E[0m'
100 export LESS_TERMCAP_se=$'\E[0m'
101 export LESS_TERMCAP_so=$'\E[01;44;33m'
102 export LESS_TERMCAP_ue=$'\E[0m'
103 export LESS_TERMCAP_us=$'\E[01;32m'
104
105 # allow zeroconf for distcc
106 export DISTCC_HOSTS="+zeroconf"
107
108 # MAKEDEV should be usable on udev as well by default:
109 export WRITE_ON_UDEV=yes
110
111 ## END OF FILE #################################################################
112 # vim:filetype=zsh foldmethod=marker autoindent expandtab shiftwidth=4