Skip to content

Instantly share code, notes, and snippets.

@talentdeficit
Created February 19, 2017 03:13
Show Gist options
  • Save talentdeficit/253fd1eaf25cb41e5c24a467f4c8f914 to your computer and use it in GitHub Desktop.
Save talentdeficit/253fd1eaf25cb41e5c24a467f4c8f914 to your computer and use it in GitHub Desktop.
new macbook setup script
#!/bin/bash
set -e
# changes color of info and then resets back to default
function info {
tput setaf 6; echo $1; tput sgr0
}
# install from brew if not already installed
function binstall {
if [[ -z $(brew list | grep $1) ]]; then brew install $1; fi
}
# install from brew cask if not already installed
function binstallc {
if [[ -z $(brew cask list | grep $1) ]]; then brew cask install $1; fi
}
# create ~/.bash_profile that points to ~/.bashrc
if ! [[ -f ~/.bash_profile ]]; then
echo "if [ -f ~/.bashrc ]; then" >> ~/.bash_profile
echo " source ~/.bashrc" >> ~/.bash_profile
echo "fi" >> ~/.bash_profile
fi
# install xcode command line tools
if [[ -z $(which xcodebuild) ]]; then xcode-select --install; fi
# install and update brew
if [[ -z $(which brew) ]]; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
info "updating brew..."
brew update
binstall gpg
# install and setup git with user, email and gpg key
binstall git
if ! [[ -z "$GIT_USER" ]]; then
info "setting git user name to ${GIT_USER}..."
git config --global --replace-all user.name "$GIT_USER"
fi
if ! [[ -z "$GIT_EMAIL" ]]; then
info "setting git email to ${GIT_EMAIL}..."
git config --global --replace-all user.email "$GIT_EMAIL"
fi
if [[ -z $(gpg --list-secret-keys) ]]; then
info "generating a gpg key to sign git commits and tags"
gpg --gen-key
KEYSIG="$(gpg --list-secret-keys | grep 'sec ' | sed 's|sec[a-zA-Z0-9 ]*/||; s| [][ -:a-zA-Z0-9]*$||')"
git config --global user.signingkey $KEYSIG
fi
# create an ssh key if none exist
if ! [[ -f ~/.ssh/id_rsa ]]; then
info "generating an ssh key"
ssh-keygen
ssh-add ~/.ssh/id_rsa
fi
binstallc java
binstall scala
binstall sbt
binstall erlang
binstall elixir
binstall node
binstall yarn
binstall typescript
binstall elm
binstall python
# clojure
binstall leiningen
binstall jq
binstall awscli
binstall wget
binstall flyway
binstall sshuttle
binstall packer
binstallc firefox
binstallc docker
binstallc intellij-idea
binstallc postgres
binstallc visual-studio-code
binstallc 1password
binstallc slack
binstallc skype
binstallc spotify
# remove downloaded archives
brew cask cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment