-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.env
67 lines (55 loc) · 1.6 KB
/
.env
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
#! /bin/bash
# NOTE: pyenv gets only loaded once on a login shell (~/.zprofile)
# and because of its, gets its PATH consistently behind everything else
# I want to keep pyenv on the login shell only because it is slow to load
# This reorders the path and puts any folder with 'pyenv' in it
# towards the font
function reorder_path_pyenv_front() {
# To keep this compatible between both bash and zsh
if [ -n "$ZSH_VERSION" ]; then
array_option="-A"
else
array_option="-a"
fi
IFS=':' read -r "${array_option?}" directories <<< "$PATH"
pyenv_dirs=()
other_dirs=()
for dir in "${directories[@]}"; do
if [[ "$dir" == *"pyenv"* ]]; then
pyenv_dirs+=("$dir")
else
other_dirs+=("$dir")
fi
done
reordered_dirs=("${pyenv_dirs[@]}" "${other_dirs[@]}")
export PATH="$(IFS=':'; echo "${reordered_dirs[*]}")"
}
# precedence: bottom to top
_path_to_append=(
"$HOME/Library/Python/3.11/bin"
"/usr/local/opt/coreutils/libexec/gnubin"
"/opt/homebrew/opt/coreutils/libexec/gnubin"
"$HOME/.local/bin"
"$HOME/go/bin/"
"/usr/local/bin"
"/opt/homebrew/bin"
"${CARGO_HOME:-$HOME/.cargo}/bin"
"$HOME/bin"
)
if [ "$SHLVL" = 1 ] || [ "$SHLVL" = 2 ]; then
for p in "${_path_to_append[@]}"; do
PATH="${p}:$PATH"
done
export PATH
fi
reorder_path_pyenv_front
if [[ $(uname) == "Darwin" ]]; then
export FPATH="$HOMEBREW_PREFIX/share/zsh/site-functions:$FPATH"
fi
if type nvim &> /dev/null; then
export EDITOR=nvim
elif type vim &> /dev/null; then
export EDITOR=vim
else
export EDITOR=vi
fi