Skip to content

Instantly share code, notes, and snippets.

@drochetti
Forked from codeinthehole/osx_bootstrap.sh
Last active February 26, 2021 07:45
Show Gist options
  • Save drochetti/01509330cd25eb68febd79ec4646abbb to your computer and use it in GitHub Desktop.
Save drochetti/01509330cd25eb68febd79ec4646abbb to your computer and use it in GitHub Desktop.
Script to install/upgrade stuff an 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.
#
# 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/
echo "Starting bootstrapping"
# Start with a oh-my-zsh
echo "Installing/updating oh-my-zsh"
if [[ -d ~/.oh-my-zsh ]]; then
omz update
else
chsh -s /bin/zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
fi
# Before starting, make sure xcode command line tools is installed
xcode-select --install
# RVM install/update
if test ! $(which rvm); then
echo "Installing RVM and the most recent stable Ruby..."
curl -sSL https://get.rvm.io | bash -s stable --ruby
else
rvm get stable
rvm use ruby --install --default
fi
echo "Installing/updating NVM..."
# Unfortunately NVM doesn't provide a way to install the 'latest' version
# https://github.com/creationix/nvm/issues/1547
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
nvm install node && nvm use node
# Check for Homebrew, install if we don't have it
if test ! $(which brew); then
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Update homebrew recipes
brew update
# Install GNU core utilities (those that come with OS X are outdated)
echo "Installing up-to-date GNU core utilities"
brew install coreutils
GNU_LIBS=(
gnu-sed
gnu-tar
gnu-indent
gnu-which
gnu-grep
)
for gnu_lib in ${GNU_LIBS[@]}; do
brew install ${gnu_lib}
done
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
brew install findutils
# Install latest Bash
brew install bash
echo "Installing brew packages..."
PACKAGES=(
ack
autoconf
automake
carthage
ffmpeg
gettext
gifsicle
git
git-flow
graphviz
hub
imagemagick
jq
libjpeg
libmemcached
lynx
markdown
mercurial
pkg-config
python
python3
pypy
rename
ssh-copy-id
terminal-notifier
the_silver_searcher
tmux
tree
vim
wget
)
echo "Installing packages..."
brew install ${PACKAGES[@]}
echo "Installing Yarn..."
brew install yarn
echo "Cleaning up..."
brew cleanup
echo "Installing cask..."
brew tap homebrew/cask
CASKS=(
visual-studio-code
discord
firefox
flux
github
google-chrome
gpg-suite
insomnia
spectacle
spotify
vagrant
vlc
java
intellij-idea-ce
android-sdk
android-platform-tools
android-studio
)
echo "Installing cask apps..."
for cask in ${CASKS[@]}; do
brew install ${cask}
done
echo "Installing fonts..."
brew tap homebrew/cask-fonts
FONTS=(
font-inconsolidata
font-roboto
font-clear-sans
)
for font in ${FONTS[@]}; do
brew install ${font}
done
echo "Installing Python packages..."
PYTHON_PACKAGES=(
ipython
virtualenv
virtualenvwrapper
)
sudo pip install ${PYTHON_PACKAGES[@]}
echo "Installing Ruby gems"
RUBY_GEMS=(
bundler
filewatcher
cocoapods
)
sudo gem install ${RUBY_GEMS[@]}
git_current_user="$(git config --global --get user.email)"
if [[ -z $git_current_user ]]; then
echo "Configuring Git..."
echo "Name:" && read git_name
echo "E-mail:" && read git_email
git config --global user.name "${git_name}"
git config --global user.email ${git_email}
fi
git config --global core.editor code
echo "Configuring OSX defaults..."
# Show filename extensions by default
defaults write NSGlobalDomain AppleShowAllExtensions -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
# Make hidden apps translucent
defaults write com.apple.Dock showhidden -bool true
# Show hidden files in Finder
defaults write com.apple.finder AppleShowAllFiles -bool true
# Hide desktop icons
defaults write com.apple.finder CreateDesktop -bool false
# Screenshot location and quality
defaults write com.apple.screencapture location ~/Pictures/Screenshots
defaults write com.apple.screencapture type jpg
echo "Creating folder structure..."
if [[ ! -d ~/dev ]]; then
mkdir -p ~/dev/workplace
mkdir -p ~/dev/resources
mkdir -p ~/dev/resources/icons
mkdir -p ~/dev/resources/fonts
fi
echo "Bootstrapping complete"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment