Skip to content

Instantly share code, notes, and snippets.

@spuder
Forked from markusand/Brewfile
Last active September 18, 2024 21:43
Show Gist options
  • Save spuder/e5f55f11cf4cbb4e4d175b34ff94e202 to your computer and use it in GitHub Desktop.
Save spuder/e5f55f11cf4cbb4e4d175b34ff94e202 to your computer and use it in GitHub Desktop.
macOS auto setup

macOS clean setup

Customise macOS defaults and install software automatically.

Setup

Open macOS Terminal and run the following command

bash <(curl -s https://gist.github.com/markusand/d7fb2b097c7e1efc199b1b44c4f99e6b/raw/cfe7c11a317e1f130110343191ca64f14d69039d/install.sh)

Warning macOS user password and iCloud credentials will be prompted

🎉 That's it! Use this commonly wasted time enjoying a cup of coffee

Customisation

If the options in this configuration are not to your taste, fork this gist and customise as you prefer.

If you miss any important option, let's discuss it and I can add it to this gist.

tap "homebrew/bundle"
# App Store
brew "mas"
brew "coreutils"
mas "Slack", id: 803453959
mas "The Unarchiver", id: 425424353
#mas "Spark", id: 1176895641
mas "Dropover", id: 1355679052
#mas "Bitwarden", id: 1352778147
mas "Hand Mirror", id: 1502839586
mas "Velja", id: 1607635845
mas "Tailscale", id: 1475387142
mas "Microsoft TODO", id: 1274495053
mas "Things 3", id: 904280696
mas "Wireguard", id: 1451685025
mas "Hidden Bar", id: 1452453066
mas "Simple Note", id: 692867256
mas "Forklift", id: 412448059
# HomeBrew
cask "rectangle"
cask "iina"
cask "shottr"
cask "onyx"
cask "appcleaner"
# cask "hiddenbar"
cask "notion"
cask "obsidian"
cask "spotify"
#cask "around"
#cask "cloudmounter"
cask "raycast"
cask "imageoptim"
cask "tempbox"
cask "warp"
cask "1password"
cask "1password-cli"
cask "discord"
cask "aldente"
cask "utm"
cask "nvalt"
# QUICKLOOK PLUGINS
cask 'qlmarkdown'
cask 'quicklook-json'
cask 'quicklook-csv'
cask 'qlstephen'
cask 'qlimagesize'
cask 'qlcolorcode'
# BROWSERS
cask "google-chrome"
cask "firefox"
cask "orion"
cask "brave-browser"
cask "mullvad-browser"
# DEV TOOLS
brew "git"
# cask "node"
cask "orbstack"
cask "visual-studio-code"
#cask "fork"
brew "gh"
brew "jq"
# GIS
#tap "osgeo/osgeo4mac"
#brew "gdal", link: false
#brew "osgeo/osgeo4mac/osgeo-grass"
#cask "qgis"
# Containers
cask "podman-desktop"
#!/usr/bin/env bash
set -x
# Close any open System Preferences panes, to prevent them from overriding
# settings we’re about to change
osascript -e 'tell application "System Preferences" to quit'
# Ask for the administrator password upfront
sudo -v
# Keep-alive: update existing `sudo` time stamp until `.macos` has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
# GENERAL :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Disable the “Are you sure you want to open this application?” dialog
defaults write com.apple.LaunchServices LSQuarantine -bool false
# Use AirDrop over every interface
defaults write com.apple.NetworkBrowser BrowseAllInterfaces 1
# Remove duplicates in the “Open With” menu (also see `lscleanup` alias)
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
# Disable automatic Smart Substitutions
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
# Disable auto-correct. OH YEAH PLEASE!
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Set language and text formats
#defaults write NSGlobalDomain AppleLanguages -array "ca" "en" "es"
#defaults write NSGlobalDomain AppleLocale -string "es_ES@currency=EUR"
#defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters"
#defaults write NSGlobalDomain AppleMetricUnits -bool true
# Set the timezone
#sudo systemsetup -settimezone "Europe/Andorra" > /dev/null
# Hide language menu in the top right corner of the boot screen
#sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool false
# TRACKPAD :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Enable tap to click for this user and for the login screen
#defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true
#defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
#defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Enable 3-finger drag
#defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true
#defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true
# ENERGY SAVING ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Enable lid wakeup
#sudo pmset -a lidwake 1
# Sleep the display after 5 minutes
#sudo pmset -a displaysleep 5
# Disable machine sleep while charging
#sudo pmset -c sleep 0
# Set machine sleep to 10 minutes on battery
#sudo pmset -b sleep 10
# Disable hibernation
#sudo pmset -a hibernatemode 0
# FINDER :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Show icons for hard drives, servers, and removable media on the desktop
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
# Disable window animations
defaults write com.apple.finder DisableAllAnimations -bool true
# Disable warning when changing a file extension
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Avoid creating .DS_Store files on network or USB volumes
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
# Automatically open a new Finder window when a volume is mounted
defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true
defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true
defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true
# Set home as default location for new Finder windows
defaults write com.apple.finder NewWindowTarget -string "PfHm"
# Show status & path bar
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder ShowPathbar -bool true
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Set grid spacing for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 64" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 64" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 64" ~/Library/Preferences/com.apple.finder.plist
# Set icons size on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 48" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 48" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 48" ~/Library/Preferences/com.apple.finder.plist
# Use icon view in all Finder windows by default
# Four-letter codes for the other view modes: 'Nlsv', 'clmv', 'glyv'
defaults write com.apple.finder FXPreferredViewStyle -string "icnv"
# Show the ~/Library folder
chflags nohidden ~/Library
# DOCK ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set the icon size of Dock items
defaults write com.apple.dock tilesize -int 64
# Minimize windows into their application’s icon
defaults write com.apple.dock minimize-to-application -bool true
# Wipe all default app icons from the Dock
defaults write com.apple.dock persistent-apps -array
# Don’t show recent applications in Dock
# defaults write com.apple.dock show-recents -bool false
# Autohide dock
defaults write com.apple.dock autohide -bool true
# NETWORK :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set default Cloudflare DNS (and Google as fallback)
#networksetup -setdnsservers Wi-Fi 1.1.1.1 1.0.0.1 8.8.8.8
# TERMINAL :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Set default Terminal theme to Pro (dark)
#defaults write com.apple.terminal "Default Window Settings" -string "Pro"
#defaults write com.apple.terminal "Startup Window Settings" -string "Pro"
# KEYBOARD :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# Speed up keyboard typing speed
defaults write 'Apple Global Domain' InitialKeyRepeat -int 25
defaults write 'Apple Global Domain' KeyRepeat -int 2
# APPLICATION CONFIG :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
killall Dock
killall Finder
echo 'Set macOS defaults...'
bash <(curl -s https://gist.github.com/markusand/d7fb2b097c7e1efc199b1b44c4f99e6b/raw/c9923d9d9e2c086a89f90022cd5f0e2e32547ff7/defaults.sh)
echo 'Install base macOS software'
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
brew analytics off
export HOMEBREW_NO_ANALYTICS=1
cd ~
curl https://gist.github.com/markusand/d7fb2b097c7e1efc199b1b44c4f99e6b/raw/3620a963ad4f8dd2c79cf3f7ce7791a672b5cb40/Brewfile -o Brewfile
brew bundle
rm Brewfile
echo 'Finished. Some changes require a restart to take effect.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment