forked from MikeMcQuaid/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbash_paths.sh
43 lines (36 loc) · 1.01 KB
/
bash_paths.sh
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
#!/bin/bash
# bash_paths
# Directories to be prepended to PATH
declare -a dirs_to_prepend=(
"/usr/local/bin" # Ensure that this bin always takes precedence over `/usr/bin`
"/usr/local/sbin"
"/opt/homebrew/bin"
"/opt/homebrew/sbin"
"$HOME/Homebrew/bin"
"$HOME/Homebrew/sbin"
)
# Directories to be appended to PATH
declare -a dirs_to_append=(
"/usr/bin"
"$HOME/bin"
"$HOME/src/android-sdk-macosx/platform-tools"
"$HOME/src/android-sdk-macosx/tools"
)
# Prepend directories to PATH
for index in ${!dirs_to_prepend[*]}
do
if [ -d ${dirs_to_prepend[$index]} ]; then
# If these directories exist, then prepend them to existing PATH
PATH="${dirs_to_prepend[$index]}:$PATH"
fi
done
# Append directories to PATH
for index in ${!dirs_to_append[*]}
do
if [ -d ${dirs_to_append[$index]} ]; then
# If these bins exist, then append them to existing PATH
PATH="$PATH:${dirs_to_append[$index]}"
fi
done
unset dirs_to_prepend dirs_to_append
export PATH