Skip to content

Instantly share code, notes, and snippets.

Last active October 22, 2023 12:09
  • Star 42 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nickytonline/729fc106a0146345c0b90f3356a41e4d to your computer and use it in GitHub Desktop.
Mac Setup Scripts
# More Mac setup at
# Log file
timestamp=$(date +%s)
# if true is passed in, things will reinstall
beginInstallation() {
echo "Starting installation for $1..." | tee -a $logFile
installComplete() {
echo "Installation complete for $1.\n\n\n" | tee -a $logFile
# List of applications to install via brew
declare -a brewApps=("git" "github/gh/gh" "gpg" "nvm" "postgresql" "pyenv" "rbenv" "rustup" "wget" "zsh" "zplug", "startship")
# List of applications to install via brew cask
declare -a brewCaskApps=("alfred" "bettertouchtool" "brave-browser" "docker" "dropbox" "firefox-developer-edition" "figma" "flux" "font-fira-code" "fork" "google-chrome" "google-chrome-canary" "iterm2" "licecap" "keybase" "ngrok" "nordvpn" "now" "onyx" "microsoft-office" "postgres" "postman" "sketch" "slack" "spotify" "the-unarchiver" "vanilla" "visual-studio-code-insiders" "vlc")
# Global node packages to install
declare -a globalNodePackages=("npm@latest" "yarn" "yo" "fkill" "alfred-fkill")
# List of applications to start right away
declare -a appsToStartRightAway=("Alfred 3" "Dropbox" "Flux" "Spectacle" "Vanilla")
# Make the auto-hide time to reveal the doc a very large number.
echo "removal of the Mac dock." | tee -a $logFile
#defaults write autohide-time-modifier -int 300; # Pre Big Sur
defaults write autohide-delay -float 0 && killall Dock
killall Dock;
echo "Removing font smoothing on Big Sur" | tee -a $logFile
#defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
echo "Putting back setting Subpixel antialiasing for text in MacOS Mojave" | tee -a $logFile
defaults -currentHost write -g AppleFontSmoothing -int 0
echo "Installing command line tools" | tee -a $logFile
xcode-select --install
echo "Setting correct permissions on folders that brew needs acccess to."
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
# Install applications
echo "Installing applications. You may be prompted at certain points to provide your password." | tee -a $logFile
command -v brew >/dev/null 2>&1 || {
beginInstallation "Homebrew"
/usr/bin/ruby -e "$(curl -fsSL"
installComplete "Homebrew"
beginInstallation "Homebrew Cask"
brew tap caskroom/cask
installComplete "Homebrew Cask"
} | tee -a $logFile
echo "Setting GitHub CLI protocol to SSH" | tee -a $logFile
gh config set git_protocol ssh
echo "Setting up some brew tap stuff for fonts and some applications" | tee -a $logFile
brew tap caskroom/versions | tee -a $logFile
brew tap caskroom/fonts | tee -a $logFile
echo "Finished setting up some brew tap stuff for fonts and some applications" | tee -a $logFile
for appName in "${brewApps[@]}"
beginInstallation $appName | tee -a $logFile
if [ $reinstall=true ]; then
brew reinstall $appName | tee -a $logFile
brew install $appName | tee -a $logFile
installComplete $appName | tee -a $logFile
for appName in "${brewCaskApps[@]}"
beginInstallation $appName | tee -a $logFile
if [ $reinstall=true ]; then
brew cask reinstall $appName | tee -a $logFile
brew cask install $appName | tee -a $logFile
installComplete $appName | tee -a $logFile
beginInstallation "Setting up node.js" | tee -a $logFile
export NVM_DIR="$HOME/.nvm"
mkdir $NVM_DIR
[ -s "/usr/local/opt/nvm/" ] && . "/usr/local/opt/nvm/" # This loads nvm
echo "Installing LTS version of node."
nvm install --lts
nvm alias default "lts/*"
nvm use default
installComplete "Finished installing node.js." | tee -a $logFile
beginInstallation "Installing global node packages" | tee -a $logFile
npm i -g "${globalNodePackages[@]}" | tee -a $logFile
installComplete "Finished installing global node packages." | tee -a $logFile
echo "Done installing applications" | tee -a $logFile
echo "\n\n\n" | tee -a $logFile
echo "Just a few final touches..." | tee -a $logFile
# Make zsh the default shell
echo "Making zsh the default shell" | tee -a $logFile
sudo dscl . -create /Users/$USER UserShell /usr/local/bin/zsh | tee -a $logFile
echo which zsh | tee -a $logFile
dscl . -read /Users/$USER UserShell | tee -a $logFile
echo $SHELL | tee -a $logFile
chsh -s $(which zsh) | tee -a $logFile
echo "Installing oh-my-zsh" | tee -a $logFile
sh -c "$(curl -fsSL" | tee -a $logFile
echo "Installing some plugins for zsh" | tee -a $logFile
git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions | tee -a $logFile
echo "Creating .zshrc file" | tee -a $logFile
touch ~/.zshrc | tee -a $logFile
echo "export ZPLUG_HOME=/usr/local/opt/zplug
export ZPLUG_HOME=/usr/local/opt/zplug
export GEM_HOME=$HOME/.gem
export NVM_LAZY_LOAD=true
export PATH=$HOME/.rbenv/shims:$GEM_HOME/bin:$HOME/.cargo/bin:$PATH
export ZSH=$HOME/.oh-my-zsh
export NVM_DIR=\"$HOME/.nvm\"
[ -s \"/usr/local/opt/nvm/\" ] && . \"/usr/local/opt/nvm/\" # This loads nvm
[ -s \"/usr/local/opt/nvm/etc/bash_completion\" ] && . \"/usr/local/opt/nvm/etc/bash_completion\" # This loads nvm bash_completion
source $ZSH/
source $ZPLUG_HOME/init.zsh
alias rimraf='rm -rf'
alias flushdns='sudo killall -HUP mDNSResponder'" > ~/.zshrc | tee -a $logFile
echo "Testing zsh prompt" | tee -a $logFile
zsh | tee -a $logFile
echo "Starting applications that are used for the Desktop" | tee -a $logFile
for appName in "${appsToStartRightAway[@]}"
echo "Starting $appName..." | tee -a $logFile
open -a "$appName" | tee -a $logFile
echo "A setup log is available at $logFile."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment