Skip to content

Instantly share code, notes, and snippets.

@tdlm
Last active March 27, 2020 17:22
Show Gist options
  • Save tdlm/704f050e03e59c464ad9a6772bbe78c6 to your computer and use it in GitHub Desktop.
Save tdlm/704f050e03e59c464ad9a6772bbe78c6 to your computer and use it in GitHub Desktop.
New Mac Setup Script
#!/usr/bin/env bash
# ____ __
# /'\_/`\ /\ _`\ /\ \__
# /\ \ __ ___ \ \,\L\_\ __\ \ ,_\ __ __ _____
# \ \ \__\ \ /'__`\ /'___\ \/_\__ \ /'__`\ \ \/ /\ \/\ \/\ '__`\
# \ \ \_/\ \/\ \L\.\_/\ \__/ /\ \L\ \/\ __/\ \ \_\ \ \_\ \ \ \L\ \
# \ \_\\ \_\ \__/.\_\ \____\ \ `\____\ \____\\ \__\\ \____/\ \ ,__/
# \/_/ \/_/\/__/\/_/\/____/ \/_____/\/____/ \/__/ \/___/ \ \ \/
# \ \_\
# \/_/
# Colors available:
# black=$(tput setaf 0)
# red=$(tput setaf 1)
# green=$(tput setaf 2)
# yellow=$(tput setaf 3)
# blue=$(tput setaf 4)
# magenta=$(tput setaf 5)
# cyan=$(tput setaf 6)
# white=$(tput setaf 7)
# dim=$(tput setaf 8)
# normal=$(tput sgr0)
magenta=$(tput setaf 5)
normal=$(tput sgr0)
# =====
# Display a colored "section" header
# =====
section_header() {
printf "%s\n" "" "${magenta}===${normal} $1 ${magenta}===${normal}" ""
}
# =====
# Main installation script
# =====
section_header "Introduction"
echo "Scott's new Mac setup script."
echo "Before we get started. Let's confirm some things..."
read -p "Name? [Scott Weaver] " setup_name
setup_name=${setup_name:-Scott Weaver}
read -p "Email? [[email protected]] " setup_email
setup_email=${setup_email:[email protected]}
read -p "Github user? [tdlm] " setup_github_user
setup_github_user=${setup_github_user:-tdlm}
# SSH Key
section_header "SSH Key"
echo "First, let's create an SSH key for you."
ssh-keygen -t rsa
echo "Please take the above output and add it to your GitHub/GitLab accounts.\n"
echo "https://github.com/settings/keys \n"
read -p "Press [Enter] to continue when you're ready..."
# Install XCode
section_header "XCode Install"
echo "Setting up XCode..."
xcode-select --install
# Install/Update Homebrew
section_header "Homebrew"
echo "Checking to see if we have Homebrew installed..."
if command -v brew; then
echo "Homebrew installed. Skipping installation..."
else
echo "Homebrew not found. Installing..."
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
fi
echo "Updating Homebrew..."
brew update
# Install and configure Git
section_header "Install and configure Git"
brew install git
echo "Set Git default config values..."
git config --global user.name $setup_name
git config --global user.email $setup_email
git config --global alias.logline 'log --graph --pretty=format:'"'"'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'"'"' --abbrev-commit'
git config --global alias.line '!git diff --numstat HEAD~ | awk '"'"'{a+=$1;next;}; END{print a;}'"'"''
echo "Install Brew Git utilities..."
brew install git-extras
brew install git-flow
# Create Required Directories
echo "Create required directories..."
mkdir -p ~/.nvm
# Homebrew extras and clean-up
echo "Install Brew baseline apps..."
brew_extras=(
awscli
awslogs
composer
docker-compose
figlet
jq
node
nvm
php
ruby
svn
tree
wget
zsh
zsh-completions
zsh-syntax-highlighting
zsh-autosuggestions
)
brew install ${brew_extras[@]}
# Dotfiles
# TODO: Implement this section a little more fully
section_header "Install Dotfiles"
cd ~
git clone [email protected]:$setup_github_user/dotfiles.git .dotfiles
cd .dotfiles
# Gulp
section_header "Install Gulp"
npm i -g gulp-cli
# Pure Prompt
section_header "Pure Prompt"
npm i -g pure-prompt
# ColorLS
section_header "ColorLS"
sudo gem install colorls
# ZSH
section_header "Install ZSH (Oh My ZSH)"
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo "Set ZSH as shell..."
chsh -s /bin/zsh
# Applications
section_header "Install Applications"
read -p "Where would you like to install applications? [~/Applications/] " setup_app_dir
setup_app_dir=${setup_app_dir:-~/Applications/}
apps=(
# Browsers
brave-browser
firefox
google-chrome
microsoft-edge
# Communications
discord
skype
skype-for-business
slack
telegram-desktop
zoomus
# Dev
cyberduck # File transfers (FileZilla is evil)
docker
gas-mask
iterm2
kitematic
jetbrains-toolbox
phpstorm
postman
sequel-pro
sourcetree
sublime-text
virtualbox
visual-studio-code
# Productivity
1password
1password-cli
alfred
bartender
blue-jeans
charles
rectangle
tripmode
toggl
# Security
backblaze
malwarebytes
private-internet-access
# Video
vlc
)
brew cask install --appdir=$setup_app_dir ${apps[@]}
brew cask alfred link
# Mac App Store Apps
section_header "Install Mac App Store Applications"
brew install mas
mas_apps=(
918207447 # Annotate - Capture and Share
409789998 # Twitter
)
mas install ${mas_apps[@]}
# Clean up
section_header "Cleanup"
echo "Homebrew cleanup..."
brew cleanup
# Mac Preferences
osascript -e 'tell application "System Events" to set the autohide of the dock preferences to true'
echo "Done"
@tdlm
Copy link
Author

tdlm commented Mar 26, 2020

This is my Mac setup script based on the apps I currently have installed and what is hopefully the shortest path from new to being roughly in the same place.

Inspired from:

There's still a lot to do and test here (putting dotfiles in place, testing the full script from new, adding any extras as I go along), but this is certainly a good starting place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment