2020-07-25 23:39:09 +00:00
#!/usr/bin/env bash
2020-08-02 18:33:59 +00:00
# This is meant to be called from the main dotfiles install script.
2020-07-25 23:39:09 +00:00
if which tput >/dev/null 2>&1; then
2020-07-26 17:58:29 +00:00
ncolors=$(tput colors)
2020-07-25 23:39:09 +00:00
fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
2020-07-26 17:58:29 +00:00
RED="$(tput setaf 1)"
GREEN="$(tput setaf 2)"
YELLOW="$(tput setaf 3)"
BLUE="$(tput setaf 4)"
MAGENTA="$(tput setaf 5)"
CYAN="$(tput setaf 6)"
BOLD="$(tput bold)"
NORMAL="$(tput sgr0)"
2020-07-25 23:39:09 +00:00
else
2020-07-26 17:58:29 +00:00
RED=""
GREEN=""
YELLOW=""
BLUE=""
MAGENTA=""
CYAN=""
BOLD=""
NORMAL=""
2020-07-25 23:39:09 +00:00
fi
set -e
printf "Installing Homebrew...\n"
# OSX 10.11 and earlier will issue certificate errors when Homebrew attempts to download packages
# with curl. Detect if we're running on 10.11 or earlier and if so use a fork that passes the
# --insecure option to curl.
kernel_major="$(uname -r | sed 's/\..*//')"
case $kernel_major in
15 | 14 | 13) download_patched_homebrew=1 ;;
*) download_patched_homebrew=0 ;;
esac
if [[ $download_patched_homebrew -eq 1 ]]; then
printf "${BOLD}Current MacOS kernel ${NORMAL}${YELLOW}$(uname -r)${NORMAL}${BOLD} requires a patched version of Homebrew...${NORMAL}\n"
bash -c "$(curl -fsSL https://raw.githubusercontent.com/sir-pinecone/brew/master/install.sh)"
else
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
brew tap homebrew/core
printf "\nInstalling bash...\n"
ret=$(brew list | awk /$package/)
if [[ $ret == $package ]]; then
printf "${YELLOW}Already installed!${NORMAL}\n"
else
eval "brew install bash"
printf "\n${YELLOW}Finished installing updated version of bash.\nYou must now enable it. Run:${NORMAL}\n"
printf " ${BOLD}sudo vim /etc/shells${NORMAL}\n"
printf "${YELLOW}And add ${NORMAL}${BOLD}/usr/local/bin/bash${NORMAL}${YELLOW} to the end of the list. After that close your terminal and re-run the dotfiles install script.${NORMAL}\n"
fi