-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.shell-path
116 lines (96 loc) · 3.34 KB
/
.shell-path
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
# --------------------------------------------------------------------------
_safe_add_to_path() {
local _dir="$1"
PATH="${PATH#$_dir:}"
PATH="${PATH/:$_dir/}"
[[ -d "$_dir" ]] && PATH="${_dir}:$PATH"
export PATH
}
# --------------------------------------------------------------------------
_clean_path() {
local -a _found=()
while read -d: -r _dir ; do
if [[ -d "$_dir" ]] ; then
local _dupe=0
for _check in ${_found[@]} ; do
[[ "$_check" == "$_dir" ]] && _dupe=1
done
[[ "$_dupe" -eq 1 ]] && continue
_found+=("$_dir")
fi
done < <(echo "$PATH")
echo "$(IFS=:; echo "${_found[*]}")"
}
# --------------------------------------------------------------------------
# This adds systems paths, my list of sane paths, private/work paths in my preferred order.
# find /etc/paths /etc/paths.d "$HOME/.shell-paths" "$HOME/.shell-prv-path" -type f -print0 2>/dev/null | xargs -0 cat | while read dir ; do
find /etc/paths /etc/paths.d -type f -print0 2>/dev/null | xargs -0 cat | while read dir ; do
_safe_add_to_path "${dir}"
done
for dir in \
/Applications/VMware\ Fusion.app/Contents/Library \
/Applications/VirtualBox.app/Contents/MacOS \
/Applications/Postgres.app/Contents/Versions/latest/bin \
/opt/homebrew/opt/postgresql@16/bin \
/Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin \
/usr/local/opt/openssl/bin \
/usr/local/opt/sqlite/bin \
/usr/local/sbin \
/{bin,sbin} \
/{usr,opt}/{bin,sbin} \
/{usr,opt,Apps}/{local,X11,opt}/{bin,sbin} \
/{usr,opt}/local/heroku/bin \
/usr/local/opt/ncurses/bin \
/opt/homebrew/{bin,sbin} \
/opt/homebrew/opt/ruby/bin \
/opt/homebrew/lib/ruby/gems/3.0.0/bin \
/usr/local/opt/python@3.10/libexec/bin \
$HOME/.npm-global/bin \
$HOME/.yarn/bin \
$HOME/.config/yarn/global/node_modules/.bin \
$HOME/gopath/bin \
$HOME/.cargo/bin \
$HOME/bin \
$HOME/local_bin \
$HOME/.mix/escripts \
$HOME/work/sball-scripts \
$HOME/.elixir-ls
do
_safe_add_to_path "$dir"
done
# --------------------------------------------------------------------------
for _version_manager in rbenv nodenv ; do
_safe_add_to_path "$HOME/.${_version_manager}/bin"
_safe_add_to_path "$HOME/.${_version_manager}/shims"
if declare -f "${_version_manager}" >& /dev/null ; then
continue
fi
_cmd="$(command -v "${_version_manager}")"
if [[ -z "$_cmd" ]] ; then
continue
fi
eval "export __${_version_manager}=${_cmd}"
done
# --------------------------------------------------------------------------
#if command -v pyenv >&/dev/null; then
# eval "$(pyenv virtualenv-init -)"
#fi
# --------------------------------------------------------------------------
if [[ -e "$HOME/.rvm/scripts/rvm" ]]; then
source "$HOME/.rvm/scripts/rvm"
fi
if [[ -e "$HOME/.fnm" ]]; then
_safe_add_to_path "$HOME/.fnm"
fi
if command -v fnm >&/dev/null ; then
eval "$(fnm env --use-on-cd)"
elif [[ -s "$HOME/.nvm" ]] ; then
export NVM_DIR="$HOME/.nvm"
[[ -s "$NVM_DIR/nvm.sh" ]] && source "$NVM_DIR/nvm.sh"
fi
_safe_add_to_path "/usr/local/opt/openjdk/bin"
# --------------------------------------------------------------------------
# This will clean up any duplicate path entries created by sloppy dependencies
export PATH=$(_clean_path)
# --------------------------------------------------------------------------
# vim: set syntax=sh ft=sh sw=2 ts=2 expandtab: