lotharschulz
Published in

lotharschulz

MacOS setup automation with Homebrew

Homebrew Setup Automation

Prelude

set -euo pipefail 
IFS=$'\n\t'
xcode-select --install
SUDO_USER=$(whoami)

Package Manager Homebrew

if test ! $(which brew); then 
/bin/bash -c \ "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
brew upgrade

CLI Tools

PROD=$(softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n') || true if [[ ! -z "$PROD" ]]; then 
softwareupdate -i "$PROD" --verbose
fi

GNU utilities and tools

brew install coreutils 
brew install gnu-sed
brew install gnu-tar
brew install gnu-indent
brew install gnu-which
brew install findutils
export PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"
$ brew info findutils findutils: stable 4.8.0 (bottled) 
Collection of GNU find, xargs, and locate https://www.gnu.org/software/findutils/ /usr/local/Cellar/findutils/4.8.0_1 (31 files, 1.8MB) *
Poured from bottle on 2021-03-06 at 08:58:14
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/findutils.rb
License: GPL-3.0-or-later ==> Caveats All commands have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH" ==> Analytics
install: 14,333 (30 days), 55,191 (90 days), 125,336 (365 days)
install-on-request: 14,145 (30 days), 54,422 (90 days), 123,262 (365 days)
build-error: 0 (30 days)
$ find --version 
find (GNU findutils) 4.8.0
Packaged by Homebrew
Copyright (C) 2021 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later https://gnu.org/licenses/gpl.html.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Written by Eric B. Decker, James Youngman, and Kevin Dalley. Features enabled: D_TYPE O_NOFOLLOW(enabled)
LEAF_OPTIMISATION FTS(FTS_CWDFD) CBO(level=2)
$ which find
/usr/local/opt/findutils/libexec/gnubin/find

JDK installation

brew tap AdoptOpenJDK/openjdk 
brew install --cask adoptopenjdk
brew install --cask adoptopenjdk8
brew install --cask adoptopenjdk11
brew install --cask adoptopenjdk14
brew install --cask adoptopenjdk15

Formulae and Casks

PACKAGES=(
alfred
...
)
brew install ${PACKAGES[@]}
CASKS=(
atom
...
)
sudo -u $SUDO_USER brew install --cask ${CASKS[@]}

More Formulae and Casks

sudo -u $SUDO_USER pip3 install --upgrade pip 
sudo -u $SUDO_USER pip3 install --upgrade setuptools
PYTHON_PACKAGES=(
ipython
virtualenv
virtualenvwrapper
)
sudo -u $SUDO_USER pip3 install ${PYTHON_PACKAGES[@]}

Scripts

osx_bootstrap.sh

osx_bootstrap_uninstall.sh

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store