Skip to content

Instantly share code, notes, and snippets.

@larsyencken
Last active August 29, 2015 14:07
Show Gist options
  • Save larsyencken/caaf38ee651dd1ea6537 to your computer and use it in GitHub Desktop.
Save larsyencken/caaf38ee651dd1ea6537 to your computer and use it in GitHub Desktop.
Bootstrap a new Mac just as I like it
#!/bin/bash
#
# bootstrap.sh
#
# Bootstrap a new Mac.
#
set -e
declare -a BREWS
BREWS=(
autojump
boot2docker
docker
gcc
go
mercurial
nmap
trash
)
declare -a CASKS
CASKS=(
alfred
dropbox
google-chrome
iterm2
juliastudio
moom
onepassword
rstudio
spotify
things
transmission
vagrant
vlc
xquartz
)
function has_exec() {
/usr/bin/which -s "$1"
}
function install_homebrew() {
echo 'Installing homebrew'
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
}
function has_brew_cask() {
test -d /usr/local/Library/Taps/caskroom/homebrew-cask
}
function install_brew_cask() {
echo 'Installing Cask'
brew install caskroom/cask/brew-cask
}
function has_cask() {
brew cask list | fgrep -q "$1"
}
function install_cask() {
brew cask install "$1"
}
function has_dotfiles() {
test -d ~/.dotfiles && test -f ~/.myname
}
function install_dotfiles() {
echo 'Installing dotfiles'
git clone [email protected]:larsyencken/dotfiles ~/.dotfiles
(cd ~/.dotfiles && ./init_config.py)
}
function has_vim() {
test -x /usr/local/bin/vim
}
function install_vim() {
echo 'Installing vim'
brew install vim --with-lua --with-luajit
}
function has_dotvim() {
test -d ~/.vim
}
function install_dotvim() {
echo 'Installing dotvim'
git clone --recursive https://github.com/larsyencken/dotvim ~/.vim
ln -s ~/.vim/vimrc ~/.vimrc
}
function install_pyenv() {
brew install pyenv
pyenv install 2.7.8
pyenv install 3.4.1
pyenv global 3.4.1 2.7.8
}
function has_brew() {
brew list | fgrep -q "$1"
}
function install_brews() {
for pkg in ${BREWS[*]}; do
if ! has_brew $pkg; then
echo "Installing $pkg"
brew install $pkg
fi
done
}
function install_casks() {
has_brew_cask || install_brew_cask
for pkg in ${CASKS[*]}; do
if ! has_cask $pkg; then
echo "Installing $pkg"
install_cask $pkg
fi
done
}
function has_ssh_key() {
test -f ~/.ssh/id_rsa.pub
}
function gen_ssh_key() {
ssh-keygen -f ~/.ssh/id_rsa
}
has_exec brew || install_homebrew
has_exec git || brew install git
has_ssh_key || gen_ssh_key
has_dotfiles || install_dotfiles
has_vim || install_vim
has_dotvim || install_dotvim
has_exec pyenv || install_pyenv
install_brews
install_casks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment