Skip to content

Instantly share code, notes, and snippets.

@jimmygle
Last active June 9, 2021 22:58
Show Gist options
  • Save jimmygle/6a679671fe2aeb9e29555337c57c90d0 to your computer and use it in GitHub Desktop.
Save jimmygle/6a679671fe2aeb9e29555337c57c90d0 to your computer and use it in GitHub Desktop.
Helps automatically setup/configure new OSX box.
#!/usr/bin/env bash
# Setup script for setting up a new macos machine
# Stolen from: https://medium.com/macoclock/automating-your-macos-setup-with-homebrew-and-cask-e2a103b51af1
echo "Starting setup"
# install xcode CLI
xcode-select --install
# Check for Homebrew to be present, install if it's missing
if test ! $(which brew); then
echo "Installing homebrew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
# Update homebrew recipes
brew update
PACKAGES=(
git
tmux
bat
macvim
mysql
fzf
curl
exiftool
composer
youtube-dl
rbenv
coreutils
)
echo "Installing packages..."
brew install ${PACKAGES[@]}
echo "Installing cask..."
CASKS=(
iterm2
slack
spotify
macdown
sublime-text
brave-browser
appcleaner
tableplus
virtualbox
emacs
postman
cyberduck
vlc
firefox
lastpass
visual-studio-code
)
echo "Installing cask apps..."
brew install ${CASKS[@]}
#
# Configure iTerm
#
echo "Configuring iTerm..."
# Install zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install powerline10k
# https://gist.github.com/kevin-smets/8568070
# TODO: Export saved config from p10k setup wizard
# Install iTerm shell integration
# https://iterm2.com/documentation-shell-integration.html
# Menu: iTerm2 > Install Shell Integration (needs to be automated)
# TODO: Export iTerm2 configuration
# Install external zsh plugins
# Colored man pages
# https://github.com/ael-code/zsh-colored-man-pages.git
git clone https://github.com/ael-code/zsh-colored-man-pages.git $ZSH_CUSTOM/plugins/colored-man-pages
# Automatically suggest/complete as typing
# https://github.com/marlonrichert/zsh-autocomplete
# DISABLED - it's too much, but provides really good suggestions
# git clone https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete
# Automatically suggest completions
# https://github.com/zsh-users/zsh-autosuggestions
# Replacement for zsh-autocomplete
https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
# Alias reminder
# https://github.com/MichaelAquilina/zsh-you-should-use
git clone https://github.com/MichaelAquilina/zsh-you-should-use.git $ZSH_CUSTOM/plugins/you-should-use
# Automatic syntax highlighting
# https://github.com/zsh-users/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
##
## Terminal aliases and functions
##
echo "Adding aliases, functions, and other junk to zsh"
# Sets up projects dir and aliases
mkdir -p ~/proj/
cat <<'EOT' >> ~/.zshrc
# Creates dynamic project aliases
# 1. Creates alias for the ~/proj/ dir at `proj`
# 2. Dynamically creates aliases for each top level dir in ~/proj/
function create_proj_aliases {
alias proj="pushd $1"
for dir in $1*/; do alias `basename $dir`="pushd $dir"; done
}
create_proj_aliases ~/proj/
EOT
echo "Configuring OS..."
# Set fast key repeat rate
# NOTE: This doesn't work anymore (System Preferences -> Keyboard -> Key Repeat & Delay Until Repeat)
# sudo defaults write NSGlobalDomain KeyRepeat -int 0
# 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
# Enable tap-to-click
# NOTE: This doesn't work anymore (System Preferences -> Trackpad -> Tap to Click)
# defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
# defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Enable three finger drag/drop
# NOTE: This doesn't work anymore (System Preferences -> Accessibility -> Pointer Control -> Trackpad Options -> Enable Dragging)
# defaults -currentHost write NSGlobalDomain com.apple.trackpad.threeFingerSwipeGesture -int 1
echo "Macbook setup completed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment