-
Notifications
You must be signed in to change notification settings - Fork 1
/
.zshenv
59 lines (53 loc) · 1.37 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
# Zprof
[[ ! -z "${ZPROF}" ]] && zmodload zsh/zprof
# Useful functions
function try_prepend_if_dir_exists() {
local var="$1"
local dir="$2"
if [ -d "$dir" ]; then
eval "export $var=\"\$dir\${$var:+:\$$var}\""
fi
}
function try_append_if_dir_exists() {
local var="$1"
local dir="$2"
if [ -d "$dir" ]; then
eval "export $var=\"\${$var:+\$$var:}\$dir\""
fi
}
function update_export() {
local p="$1"
local name="${p%%=*}"
local value="${p#*=}"
if [[ -v "$name" ]]; then
if [ ${(P)name} != $value ]; then
echo "Updating "$name" to "$value" from "${(P)name}""
export $name="$value"
fi
else
export $name=$value
fi
}
# Content of environment
SHELL_PLATFORM="$(uname 2>/dev/null)"
[[ "$SHELL_PLATFORM" == *NT* ]] && SHELL_PLATFORM="MSYS"
if [ $SHELL_PLATFORM = "Linux" ] && [ ! -z ${WSL_DISTRO_NAME} ]; then
if [[ "$(cat /proc/interrupts)" ]]; then
SHELL_PLATFORM="WSL2"
else
SHELL_PLATFORM="WSL1"
fi
export WSL_ROOT_PATH="\\\\wsl.localhost\\${WSL_DISTRO_NAME}"
fi
export SHELL_PLATFORM
export SSH_KEY_PATH="~/.ssh/id_rsa"
# environment profiles
if [ -d $HOME/.config/env.d ]; then
for i in $HOME/.config/env.d/*.sh; do
if [ -r $i ]; then
source $i
fi
done
unset i
fi
[[ -f $(which nvim) ]] && export EDITOR="nvim"