-
Notifications
You must be signed in to change notification settings - Fork 12
/
brewed-bash.sh
29 lines (21 loc) · 897 Bytes
/
brewed-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
28
29
#!/usr/bin/env bash
# Install command-line tools using Homebrew.
# Ask for the administrator password upfront.
sudo -v
# Keep-alive: update existing `sudo` time stamp until the script has finished.
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# Install Homebrew.
if [[ ! "$(type -P brew)" ]]; then
true | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Exit if, for some reason, Homebrew is not installed.
[[ ! "$(type -P brew)" ]] && e_error "Homebrew failed to install." && return 1
brew tap homebrew/versions
brew install bash
# Switch to using brew-installed bash as default shell
if ! fgrep -q "$(brew --prefix)/bin/bash" /etc/shells; then
echo "$(brew --prefix)/bin/bash" | sudo tee -a /etc/shells;
chsh -s $(brew --prefix)/bin/bash;
fi;
# Remove outdated versions from the cellar.
brew cleanup