/
setup-bash.sh
27 lines (20 loc) · 768 Bytes
/
setup-bash.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
#!/bin/sh
echo "Setting up the shell to use bash from Homebrew…"
echo "Current shell is ${SHELL} ($(${SHELL} --version | head -n 1))"
BREW_DIR=$(brew --prefix bash)
BASH="${BREW_DIR}/bin/bash"
if [ ! -x "${BASH}" ]; then
echo "Need to install bash, so doing that now…"
brew install bash
fi
if [ ! -x "${BASH}" ]; then
echo "Homebrew bash in ${BASH} not found even after (re)installing it, do something about it."
exit 1
fi
echo "Adding $BASH to shells as superuser…"
echo "$BASH" | sudo tee -a /etc/shells >/dev/null
echo "Setting $BASH as shell for $(whoami)…"
chsh -s "$BASH"
echo "Now, reopen the terminal or try 'rebash' to reload using the newer bash."
echo "New shell will be ${BASH} ($(${BASH} --version | head -n 1))."
echo "Happy bashing!"