Skip to content

Commit a8df89f

Browse files
authored
Add Homebrew to path (#27)
Required if running this on a brand new Mac that doesn't have homebrew installed
1 parent 80bba0d commit a8df89f

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

install.sh

+29-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ should_install_homebrew() {
1616
! [[ -e "${HOMEBREW_PREFIX}/bin/brew" ]]
1717
}
1818

19+
should_add_homebrew_to_path() {
20+
! [[ ":${PATH}:" = *":${HOMEBREW_PREFIX}/bin:"* ]]
21+
}
22+
1923
no_python3() {
2024
! [[ -e "/usr/local/bin/2to3" ]]
2125
}
@@ -59,16 +63,39 @@ system_setup() {
5963
else
6064
if [[ "$(/usr/bin/uname -m)" == "arm64" ]]
6165
then
62-
export HOMEBREW_PREFIX="/opt/homebrew"
66+
HOMEBREW_PREFIX="/opt/homebrew"
6367
else
64-
export HOMEBREW_PREFIX="/usr/local"
68+
HOMEBREW_PREFIX="/usr/local"
6569
fi
6670
fi
6771

6872
if should_install_homebrew
6973
then
7074
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
7175
fi
76+
77+
if should_add_homebrew_to_path
78+
then
79+
case "${SHELL}" in
80+
*/bash*)
81+
if [[ -r "${HOME}/.bash_profile" ]]
82+
then
83+
shell_profile="${HOME}/.bash_profile"
84+
else
85+
shell_profile="${HOME}/.profile"
86+
fi
87+
;;
88+
*/zsh*)
89+
shell_profile="${HOME}/.zprofile"
90+
;;
91+
*)
92+
shell_profile="${HOME}/.profile"
93+
;;
94+
esac
95+
96+
(echo; echo 'eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"') >> ${shell_profile}
97+
eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)"
98+
fi
7299

73100
if should_install_ansible
74101
then

0 commit comments

Comments
 (0)