Last active
October 26, 2022 07:33
-
-
Save srpouyet/8f47fc26ad37deb3b4da8b624ee34217 to your computer and use it in GitHub Desktop.
Script to bootstrap osx for development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Bootstrap script for setting up a new OSX machine | |
# Adapted from a github gist by mrichman | |
# https://gist.github.com/mrichman/f5c0c6f0c0873392c719265dfd209e12 | |
# | |
# This should be idempotent so it can be run multiple times. | |
# helpers | |
function echo_ok() { echo -e '\033[1;32m'"$1"'\033[0m'; } | |
function echo_warn() { echo -e '\033[1;33m'"$1"'\033[0m'; } | |
function echo_error() { echo -e '\033[1;31mERROR: '"$1"'\033[0m'; } | |
echo_ok "Bootstrapping..." | |
# Install xcode if needed (will display an error if already installed) | |
xcode-select --install | |
# Check for homebrew installation | |
if command -v /opt/homebrew/bin/brew &>/dev/null; then | |
# Check for brew command | |
if hash brew &>/dev/null; then | |
echo_ok "Homebrew already installed ..." | |
else | |
eval "$(/opt/homebrew/bin/brew shellenv)" | |
fi | |
else | |
echo_warn "Installing homebrew..." | |
eval "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
# TODO: add homebrew to user shell? | |
# echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/sebastiaan/.zprofile | |
eval "$(/opt/homebrew/bin/brew shellenv)" | |
fi | |
echo_ok "Installing brew packages..." | |
PACKAGES=( | |
asdf | |
brew-cask-completion | |
cask | |
chezmoi | |
csview | |
curl | |
fish | |
git | |
lazydocker | |
lazygit | |
jq | |
openssl | |
starship | |
) | |
for package in ${PACKAGES[@]}; do | |
echo_ok "Installing ${package}..." | |
if brew ls --versions $package >/dev/null; then | |
echo "${package} is already installed, skipping..." | |
else | |
brew install $package | |
fi | |
done | |
echo_ok "Cleaning up brew..." | |
brew cleanup | |
echo_ok "Installing cask apps..." | |
CASKS=( | |
docker | |
insomnia | |
iterm2 | |
macvim | |
postico | |
spotify | |
visual-studio-code | |
) | |
for cask in ${CASKS[@]}; do | |
echo_ok "Installing ${cask}..." | |
app=$(brew info --cask $cask | grep ".app (App)" | sed -r "s/ \(App\)//") | |
# If brew info fails with status 1, just run install command | |
if [[ "$?" -eq 0 && -d "/Applications/${app}" ]]; then | |
echo "${app} already installed, skipping..." | |
else | |
brew install --cask $cask | |
fi | |
done | |
echo_ok "Installing fonts..." | |
brew tap homebrew/cask-fonts | |
FONTS=( | |
font-fira-mono-nerd-font | |
font-fira-code-nerd-font | |
) | |
brew install --cask "${FONTS[@]}" | |
echo_ok "Configuring OSX..." | |
# Show filename extensions by default | |
defaults write NSGlobalDomain AppleShowAllExtensions -bool true | |
# Expanded Save menu | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true | |
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true | |
# Expanded Print menu | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true | |
# Enable tap-to-click | |
defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true | |
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 | |
echo_ok "Creating ~/Development..." | |
mkdir -p "$HOME/Development" | |
ASDF_PLUGINS=( | |
bundler | |
nodejs | |
python | |
ruby | |
yarn | |
) | |
for asdf_plugin in ${ASDF_PLUGINS[@]}; do | |
echo_ok "Installing asdf plugin ${asdf_plugin}..." | |
asdf plugin add "${asdf_plugin}" | |
done | |
echo_ok "Install latest ruby..." | |
asdf install ruby latest | |
echo_ok "Set latest ruby as global default..." | |
asdf global ruby latest | |
# SSH Key stuff | |
# ssh-keygen -t ed25519 -a 100 -C "[email protected]" | |
# https://apple.stackexchange.com/a/250572 | |
# ssh-add -K ~/.ssh/id_ed25519 | |
# Add to ~/.ssh/config: | |
# | |
# Host * | |
# UseKeychain yes | |
# AddKeysToAgent yes | |
# IdentityFile ~/.ssh/id_ed25519 | |
# Set fish as shell | |
# https://stackoverflow.com/a/20506404 | |
# sudo echo /opt/homebrew/bin/fish >> /etc/shells | |
# chsh -s /opt/homebrew/bin/fish | |
echo_ok "Bootstrapping complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment