Skip to content

Instantly share code, notes, and snippets.

@samuelint
Last active May 27, 2024 20:17
Show Gist options
  • Save samuelint/c6999b74eaed79451bb85714ff88e031 to your computer and use it in GitHub Desktop.
Save samuelint/c6999b74eaed79451bb85714ff88e031 to your computer and use it in GitHub Desktop.
New macOS setup script
#!/bin/bash
set -e
##########################
# New macOS setup script #
##########################
USER_EMAIL="<YOUR EMAIL>"
USER_NAME="<YOUR_NAME>"
# SSH
echo "Creating a new SSH key"
[ -f ~/.ssh/id_rsa ] || ssh-keygen -t rsa -C $USER_EMAIL
[ -f ~/.ssh/id_ed25519 ] || ssh-keygen -t ed25519 -C $USER_EMAIL
###########################
# XCode
echo "Installing XCode"
xcode-select -p > /dev/null 2>&1 || xcode-select --install
# Homebrew
if test ! $(which brew); then
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add brew to PATH
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
echo "Updating homebrew..."
brew update
# Git
brew install git
# Git Utils
brew install git-extras
brew install legit
# Git Config
echo "Git config"
git config --global user.name $USER_NAME
git config --global user.email $USER_EMAIL
# Github
echo "Please add this public key to Github \n"
cat ~/.ssh/id_ed25519.pub | pbcopy
echo -e "\033[34mSSH key has been copied to clipboard.\033[0m"
open "https://github.com/settings/keys"
read -p "Press [Enter] key after this..."
# Reset clipboard
pbcopy < /dev/null
echo -e "\033[34mClipboard cleared.\033[0m"
# Utils
brew install tree
brew install wget
brew install --cask sublime-text
# Node
brew install nvm
# Terraform
brew install warrensbox/tap/tfswitch
# Homebrew Apps
brew_apps=(
docker
sublime-text
notion
visual-studio-code
postman
firefox
google-chrome
sourcetree
warp
)
brew install --cask --appdir="/Applications" ${brew_apps[@]}
# Python
brew install --cask anaconda
brew install poetry
echo 'export PATH=/usr/local/anaconda3/bin:$PATH' >> ~/.zshrc
echo 'export PATH=/opt/homebrew/anaconda3/bin:$PATH' >> ~/.zshrc
source ~/.zshrc
# MacOS Settings
echo "Show Hidden Files"
defaults write com.apple.finder AppleShowAllFiles -bool true
echo "Every files Snap To Grid"
defaults write com.apple.finder FXArrangeGroupViewBy -string "Grid"
echo "Screenshot format default to PNG"
defaults write com.apple.screencapture type -string "png"
echo -e "\033[34mRestart Finder\033[0m"
killall Finder
echo -e "\033[0;32mDone\033[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment