Skip to content

Instantly share code, notes, and snippets.

@ashhitch
Forked from bradp/setup.sh
Last active November 9, 2024 22:15
Show Gist options
  • Save ashhitch/d19afdc980121be4e92fc14d5e5380be to your computer and use it in GitHub Desktop.
Save ashhitch/d19afdc980121be4e92fc14d5e5380be to your computer and use it in GitHub Desktop.
New Mac Setup Script
# Get the current hour
current_hour=$(date +"%H")
# Determine the greeting based on the current hour
if [ "$current_hour" -lt 12 ]; then
greeting="Good morning"
elif [ "$current_hour" -lt 18 ]; then
greeting="Good afternoon"
else
greeting="Good evening"
fi
echo "$greeting!"
echo "We are about to setup your Mac..."
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
echo "Creating an SSH key for you..."
if [ ! -f ~/.ssh/id_rsa ]; then
ssh-keygen -t rsa -N ""
else
echo "SSH key already exists."
fi
echo "Please add this public key to GitHub \n"
echo "https://github.com/settings/keys \n"
read -p "Press [Enter] key after this..."
echo "Installing Xcode Command Line Tools..."
if ! xcode-select -p &> /dev/null; then
xcode-select --install
else
echo "Xcode Command Line Tools already installed."
fi
# Check for Homebrew,
# Install if we don't have it
if ! command -v brew &> /dev/null; then
echo "Installing homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Update homebrew recipes
echo "Updating homebrew..."
brew update
echo "Installing Git..."
brew install git
echo "Git config"
git config --global user.name "Ash Hitchcock"
git config --global user.email "[email protected]"
git config --global pull.merge true
PACKAGES=(
git-extras
git-flow
tree
wget
trash
nvm
yarn
pnpm
pyenv
youtube-dl
z
zsh
zsh-completions
zsh-autosuggestions
zsh-syntax-highlighting
)
brew install "${PACKAGES[@]}"
echo "Cleaning up brew"
brew cleanup
echo "Installing homebrew cask"
brew install caskroom/cask/brew-cask
#Install Zsh & Oh My Zsh
echo "Installing Oh My ZSH..."
curl -L http://install.ohmyz.sh | sh
echo "Setting up Zsh plugins..."
cd ~/.oh-my-zsh/custom/plugins
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
echo "Setting ZSH as shell..."
chsh -s /bin/zsh
# Apps
apps=(
affinity-designer
affinity-photo
altair-graphql-client
backblaze
bartender
bettertouchtool
chatgpt
dbngin
diffmerge
docker
firefox@developer-edition
forklift
github
google-chrome
imageoptim
notion
onepassword
postman
proxyman
raycast
rocket
setapp
spotify
telegram
transmission
transmit
ultimaker-cura
virtualbox
visual-studio-code@insiders
vlc
warp
whatsapp
)
# Install apps to /Applications
# Default is: /Users/$user/Applications
echo "installing apps with Cask..."
brew cask install --appdir="/Applications" ${apps[@]}
brew cask cleanup
brew cleanup
echo "Setting some Mac settings..."
# Allow text selection in Quick Look
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
# Disabling OS X Gate Keeper
# (You'll be able to install any app you want from here on, not just Mac App Store apps)"
sudo spctl --master-disable
sudo defaults write /var/db/SystemPolicy-prefs.plist enabled -string no
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Expand save panel by default
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
# Saving to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Enabling subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
# Showing all filename extensions in Finder by default
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
# Disabling the warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Avoiding the creation of .DS_Store files on network volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
# Position dock on the right side of the screen
defaults write com.apple.dock orientation -string "right"
# Setting email addresses to copy as '[email protected]' instead of 'Foo Bar <[email protected]>' in Mail.app
defaults write com.apple.mail AddressesIncludeNameOnPasteboard -bool false
# Preventing Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
# Disable annoying backswipe in Chrome
defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false
# Hiding Safari's bookmarks bar by default
defaults write com.apple.Safari ShowFavoritesBar -bool false
# Hiding Safari's sidebar in Top Sites
defaults write com.apple.Safari ShowSidebarInTopSites -bool false
# Enabling Safari's debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
# Allow hitting the Backspace key to go to the previous page in history
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true
# Enabling the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true
# Adding a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
# Use `~/Downloads/Incomplete` to store incomplete downloads
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
defaults write org.m0k.transmission IncompleteDownloadFolder -string "${HOME}/Downloads/Incomplete"
# Don't prompt for confirmation before downloading
defaults write org.m0k.transmission DownloadAsk -bool false
# Trash original torrent files
defaults write org.m0k.transmission DeleteOriginalTorrent -bool true
# Hide the donate message
defaults write org.m0k.transmission WarningDonate -bool false
# Hide the legal disclaimer
defaults write org.m0k.transmission WarningLegal -bool false
# Restart Finder if it is running
if pgrep -x "Finder" > /dev/null; then
killall Finder
fi
echo "Summary of tasks completed:"
echo "- SSH key created or already exists"
echo "- Xcode Command Line Tools installed or already installed"
echo "- Git installed"
echo "- Git configured"
echo "- Homebrew installed or already installed"
echo "- Homebrew updated"
echo "- Homebrew cask installed"
echo "- Oh My Zsh installed"
echo "- Zsh plugins installed"
echo "- Zsh set as shell"
echo "- Apps installed"
echo "- Mac settings updated"
echo "Setup complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment