Skip to content

Instantly share code, notes, and snippets.

@drazulay
Last active April 2, 2022 08:59
Show Gist options
  • Select an option

  • Save drazulay/918f80a98841cb4959c39e4a6c701ee6 to your computer and use it in GitHub Desktop.

Select an option

Save drazulay/918f80a98841cb4959c39e4a6c701ee6 to your computer and use it in GitHub Desktop.
OS X Developer onboarding script
#! /usr/bin/env bash
################################
# Onboarding script for OS X
# Installs a bunch of software,
# and optionally an extra bunch
# of other software - yay, more
# bytezz! Also does some config-
# foo like a small zsh and os x
# polish.
#
# Copy & tweak this file
################################
EXTRA_APPS=("clion discord gimp keybase ledger-live protonmail-bridge protonvpn pycharm-ce qbittorrent rectangle rustup-init signal skype spotify telegram-desktop")
[[ "$1" == "--extra" ]] && EXTRA=1 || EXTRA=0
STEP=""
# I don't use the 'unofficial bash strict mode' but opt for using
# a trap function on ERR instead
set -o pipefail
function err_handler
{
echo "Something went wrong during step \'${STEP}\', process exited with code "$?".
}
trap 'err_handler' ERR
echo -e "\nStarting..."
sudo -v
################################
# Declare functions
################################
function show_installer_step
{
echo -e "\nExecuting step: ${1}..."
export STEP="${1}"
}
function add_bin_dirs_to_path
{
local p
for ELEM in "$@"; do
export PATH="${ELEM}:${PATH}"
done
}
################################
# Update required Apple software
################################
show_installer_step "Apple: Software Update"
sudo -v
softwareupdate --all --install --force
################################
# Install homebrew
################################
show_installer_step "Install Homebrew"
sudo -v
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
################################
## Install base set of software
################################
show_installer_step "Brew: Install Basic Applications"
sudo -v
brew tap homebrew/cask
brew tap homebrew/cask-versions
brew tap henkrehorst/homebrew-php
brew update
brew upgrade
brew install $FORCE \
composer \
eslint \
hex-fiend \
homebrew/cask-versions/firefox-developer-edition \
iterm2 \
lulu \
macdown \
microsoft-teams \
node \
npm \
phpstorm \
sequel-pro \
tree \
wget \
slack \
yarn \
zsh
# valet-php is problematic -- might even need to have it's formula edited to install 7.4.28
# instead of failing 7.4.16
sudo -v
brew install [email protected]
brew link [email protected] --force --overwrite
################################
# grml.org zshrc's
################################
show_installer_step "Zsh: install rc scripts from grml.org"
sudo -v
cd ~
wget -O .zshrc.local https://git.grml.org/f/grml-etc-core/etc/skel/.zshrc
wget -O .zshrc https://git.grml.org/f/grml-etc-core/etc/zsh/zshrc
touch .zshrc.pre
################################
## Path entries
################################
show_installer_step "Shell: set \$PATH variable"
sudo -v
add_bin_dirs_to_path "${HOME}/.bin" \
"/usr/local/sbin" \
"/Users/daniel/.composer/vendor/bin" \
"/Users/daniel/.cargo/bin"
echo "export PATH=\"${PATH}\"" >> .zshrc.pre
## Composer global requirements
show_installer_step "Composer: install global requirements"
sudo -v
composer global require weprovide/valet-plus
composer global require phpmd/phpmd
composer global require n98/magerun2-dist
################################
# Set sane OS X defaults
################################
show_installer_step "Apple: set OS X defaults"
sudo -v
defaults write NSGlobalDomain AppleShowScrollBars -string "Always" # Always show scrollbar
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true # Show full save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true # Show full print panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false # No more unnatural backwards scrolling
################################
# Install extra apps if requested
################################
if [[ "$EXTRA" == "1" ]]; then
show_installer_step "Homebrew: install extra applications"
sudo -v
brew install $FORCE "${EXTRA_APPS}"
show_installer_step "Yubico: install yubikey-manager"
mkdir -p /tmp/drazulay/software
cd /tmp/drazulay/software
# yubico
sudo -v
wget "https://developers.yubico.com/yubikey-manager-qt/Releases/yubikey-manager-qt-latest-mac.pkg" "yubikey-manager-qt-latest-mac.pkg"
sudo installer -pkg yubikey-manager-qt-latest-mac.pkg -target /
rm -rf /tmp/drazulay/software
fi
################################
# Done, define trap & cleanup
################################
brew cleanup
echo -e "################################\n"
echo "Done."
echo "You should now have a workable system for development in Rust & PHP."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment