Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Narayon
Forked from codeinthehole/osx_bootstrap.sh
Last active September 4, 2022 21:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Narayon/d595a2ed5e2e10da8e53ed98b6c70f4f to your computer and use it in GitHub Desktop.
Save Narayon/d595a2ed5e2e10da8e53ed98b6c70f4f to your computer and use it in GitHub Desktop.
Script to install stuff I want on a new OSX machine
#!/usr/bin/env bash
#
# Bootstrap script for setting up a new OSX machine
#
# This should be idempotent so it can be run multiple times.
#
# Some apps don't have a cask and so still need to be installed by hand. These
# include:
#
# - Newton (app store)
# - ClipMenu
# - Asana
#
# Notes:
#
# - If you already have any of the casks apps installed,
# the script will throw an error and won't install any casks apps.
#
# Reading:
#
# - http://lapwinglabs.com/blog/hacker-guide-to-setting-up-your-mac
# - https://gist.github.com/MatthewMueller/e22d9840f9ea2fee4716
# - https://news.ycombinator.com/item?id=8402079
# - http://notes.jerzygangi.com/the-best-pgp-tutorial-for-mac-os-x-ever/
#
# TO DO:
#
# Try to install AppleStore apps with `mas`
# Think about mackup to restore configs
log_header() {
echo ""
echo "--- $1 ---"
echo "---------------------------------------------"
}
log_line() {
echo "### $1 #"
}
log_line "Starting bootstrapping"
log_header "Installing XCode command line tools"
xcode-select --install
# Check for Homebrew, install if we don't have it
if test ! $(which xcode-select); then
log_header "Installing XCode command line tools"
xcode-select --install
else
log_header "XCode command line tools already installed, moving on"
fi
log_header "Update brew recipes"
brew update
log_header "Install GNU core utilities" #(those that come with OS X are outdated)
brew install coreutils
brew install gnu-sed --with-default-names
brew install gnu-tar --with-default-names
brew install gnu-indent --with-default-names
brew install gnu-which --with-default-names
brew install grep --with-default-names
log_header "Install GNU find, locate, updatedb, and xargs, g-prefixed"
brew install findutils
PACKAGES=(
ack
ffmpeg
git
graphviz
imagemagick
libjpeg
node
nvm
python
terminal-notifier
tree
wget
z
zsh-completions
)
log_header "Installing brew packages..."
brew install ${PACKAGES[@]}
log_line "Cleaning up brew..."
brew cleanup
log_line "Installing cask..."
brew tap caskroom/cask
CASKS=(
alfred
appcleaner
audacity
balenaetcher
bitwarden
brave-browser
docker
dropbox
ferdi
firefox
insomnia
iterm2
itsycal
kap
kitematic
libreoffice
notion
rectangle
spotify
stats
stremio
the-unarchiver
todometer
visual-studio-code
vlc
)
log_header "Installing cask apps..."
brew cask install ${CASKS[@]}
log_line "Cleaning up cask..."
brew cask cleanup
log_header "Installing fonts..."
brew tap caskroom/fonts
FONTS=(
font-clear-sans
font-inconsolata
font-lato
font-roboto
font-source-code-pro
font-source-code-pro-for-powerline
)
brew cask install ${FONTS[@]}
log_header "Install rvm"
mkdir -p ~/.rvm/src && cd ~/.rvm/src && rm -rf ./rvm && \
git clone --depth 1 https://github.com/rvm/rvm.git && \
cd rvm && ./install
log_header "Installing Ruby gems"
RUBY_GEMS=(
sass
)
sudo gem install ${RUBY_GEMS[@]}
# log_text "Installing global npm packages..."
# npm install marked -g
log_header "Configuring OSX..."
# Set fast key repeat rate
defaults write NSGlobalDomain KeyRepeat -int 2
# Require password as soon as screensaver or sleep mode starts
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Show filename extensions by default
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Set dock preferences
defaults write com.apple.dock tilesize -int 32
defaults write com.apple.dock magnification -bool true
defaults write com.apple.dock mineffect -string 'scale'
# Show full path and status in finder title
defaults write com.apple.finder ShowPathbar -bool true
defaults write com.apple.finder ShowStatusBar -bool true
# Kill affected apps
for app in "Dock" "Finder"; do
killall "${app}" > /dev/null 2>&1
done
log_header "Creating folder structure..."
[[ ! -d ~/sites ]] && mkdir ~/sites
log_header "Installing oh-my-zsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
log_line "Bootstrapping complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment