-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshenv
189 lines (151 loc) · 4.08 KB
/
.zshenv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# ~/.zshenv - Z shell environment
# NOTE: This file is source before everything else and anytime
# Profiler
# Run time ZPROF=1 zsh -i -c exit
if [ -n "${ZPROF+1}" ]; then
zmodload zsh/zprof
fi
# Don't source systemwide config
unsetopt GLOBAL_RCS
# Don't run compinit on Debian/Ubuntu
skip_global_compinit=1
# Function path (~/.zsh_local, ~/.zsh) and autoload functions
# NOTE $fpath isn't inherited between shells but is needed in .zprofile
# NOTE ~/.zsh_local overrides ~/.zsh
for p in ~/.zsh ~/.zsh_local; do
local_fpath=($p/**/*(N/) $p)
for d in $local_fpath; do
[ -d $d ] || continue
fpath=($d $fpath)
for f in $d/*(N-.x:t); autoload -Uz -- $f
done
done
builtin unset -v p local_fpath d f
# Environment
# This used to be .zshprofile but that does not load with non-login shells
# (e.g. sudo -u USER /usr/bin/zsh).
# ~/.zprofile - Z shell profile
# NOTE: This file is sourced only for login shells
# {{{ Hostname
[ -z $HOST ] && HOST=$(hostname)
[ -z $HOSTNAME ] && HOSTNAME=$HOST
export HOST HOSTNAME
HOSTNICK=${HOST%%.*}
# Host status (0-good, 1-bad, unset don't show)
HOSTOK=
export HOSTNICK HOSTOK
# }}}
# {{{ OS
# Sets $OS and $OSARCH variables
OS=$OSTYPE
case "$OS" in
linux*) OS=linux ;;
linux-android) OS=android ;;
darwin*) OS=mac ;;
freebsd*|netbsd*|openbsd*|dragonfly*) OS=bsd ;;
win32) OS=win ;;
msys*|cygwin*) OS=win ;;
esac
OSARCH=$OS-$(uname -m)
# Set $WSL to non-zero (WSL version 1 or 2); use WSL exported variables for
# detection rather than kernel string in uname.
WSL=
if [ ! -z "$WSL_DISTRO_NAME" ]; then
[ ! -z "$WSL_INTEROP" ] && WSL=2 || WSL=1
fi
# If WSL is non-zero set some useful variables
if [ -z "$WSL" ]; then
# TODO:
WSLUSER=
WSLHOME=
fi
unset _uname
export OS OSARCH WSL
# }}}
# {{{ Umask
# Set umask 002 for uids >=1000 and having their own group
[ $UID -ge 1000 ] && [ $UID -eq $GID ] && umask 002 || umask 022
# }}}
# {{{ Super-user
# If user is not root set $SUDO to 'sudo'
[ $EUID != 0 ] && SUDO=sudo || SUDO=
export SUDO
# }}}
# {{{ Temporary directory
# NOTE: This is for systems without TMPDIR set from PAM (or without PAM)
if [ -z "$TMPDIR" ]; then
# TODO: create safe /tmp/user/$UID if possible?
TMPDIR=/tmp
fi
TMP=$TMPDIR
export TMP TMPDIR
# }}}
# {{{ Kerberos directory
[ ! -d $HOME/.krb5 ] && mkdir -p $HOME/.krb5
chmod 700 $HOME/.krb5
KRB5CCNAME=FILE:$HOME/.krb5/cc
export KRB5CCNAME
# }}}
# {{{ Misc environment
EDITOR=vim
VISUAL=$EDITOR
PAGER=less
LESSHISTFILE=-
export EDITOR VISUAL BROWSER PAGER LESSHISTFILE
# Irssi variables
IRCNICK='blami'
IRCUSER='blami'
export IRCNICK IRCUSER
# User (override in ~/.zprofile_local|$HOST)
MYFULLNAME='Ondrej Balaz'
MYEMAIL='blami@blami.net'
export MYFULLNAME MYEMAIL
# Debian development environment
DEBFULLNAME='Ondrej Balaz'
DEBEMAIL='blami@blami.net'
export DEBFULLNAME DEBEMAIL
# CPU cores (useful with make -j)
CPUS=1
case "$OS" in
linux)
CPUS=$(grep '^core id' /proc/cpuinfo | sort -u | wc -l)
;;
esac
export CPUS
# Color output on MacOS X
CLICOLOR=1
export CLICOLOR
# Screen reader mode (no fancy prompt, per-app settings in nvim, tmux, etc.)
SCREENREADER=0
export SCREENREADER
# libvirt (qemu) default connect URI (to see root domains)
LIBVIRT_DEFAULT_URI=qemu:///system
export LIBVIRT_DEFAULT_URI
# }}}
# {{{ PATH cleaning and profile
autoload -Uz pathmunge
# In WSL remove native Windows paths from PATH first
if [ ! -z "$WSL" ]; then
PATH=$(echo $PATH | tr ':' '\n' | grep -v '/mnt/[a-z]/' | paste -s -d:)
fi
# Source snippets in ~/.profile.d
for s in ~/.profile.d/*.sh(N) ; source $s
builtin unset -v s
# }}}
# {{{ Includes
# Local configuration
[ -r ~/.zshenv_local ] && . ~/.zshenv_local || builtin true
[ -r ~/.zshenv_$HOST ] && . ~/.zshenv_$HOST || builtin true
# }}}
# {{{ Custom PATH
# NOTE: This goes here so it is always in front and not overriden by _local
# Setup PATH in ~/local
pathmunge $HOME/local/bin
# Setup PATH in ~ always as last component
pathmunge $HOME/bin/$HOSTNICK
pathmunge $HOME/bin/$OSARCH
pathmunge $HOME/bin/$OS
pathmunge $HOME/bin
export PATH
# }}}
# vim:set ft=zsh: