Automating New Mac Setup

Automating New Mac Setup

Tags
ITmacOS
💡
This file could be contained in a Gist or bash file that could auto-run when provisioning a new Mac in Jamf Pro, Apple Business Manager or any other MDM.

Install Rosetta 2 (Silicon Macs Only)

/usr/sbin/softwareupdate --install-rosetta --agree-to-license

Script to Programmatically install on Silicon Macs.

Tools

Homebrew

Install Homebrew (includes Xcode Tools, will prompt for software update)

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Disable Brew Analytics

brew analytics off

Update Brew

brew update

Update Brew Formulas

brew upgrade

Install Brew Forumlas

brew install $(<packages.txt)

go
mas
node
ffmpeg
imagemagick
php
python
deno
terminal-notifier
wscat
mitmproxy
mpv
nmap
photorec
streamlink
git
git-filter-repo
docker
colima
kubectl

Install Quick Look plugin for Provision Profiles

brew cask install provisionql

Install macOS Menu Bar Stats

brew install --cask stats

Personal Preference

Disable Reopen Windows on Shutdown

Make the file owned by root (otherwise the OS will just replace it)

sudo chown root ~/Library/Preferences/ByHost/com.apple.loginwindow*

Remove all permissions, so it can't be read or written to sudo chmod 000 ~/Library/Preferences/ByHost/com.apple.loginwindow*

Show Volume In Menubar

defaults write com.apple.systemuiserver menuExtras -array "/System/Library/CoreServices/Menu Extras/Volume.menu"

Then restart the SystemUIServer with killall SystemUIServer

💡
If you want to enable additional items, look in ~/Library/Preferences/com.apple.systemuiserver.plist to find the specific name of the menu extra you are seeking.

Disable Dictation Keyboard Shortcut

defaults write com.apple.HIToolbox AppleDictationAutoEnable -int 1

Limit Ad Tracking

defaults write com.apple.AdLib forceLimitAdTracking -bool yes

defaults write com.apple.AdLib AD_DEVICE_IDFA -string '00000000-0000-0000-0000-000000000000'

Set ZSH as terminal default

chsh -s /bin/zsh

Disable Recent Items in macOS Dock

defaults write com.apple.dock show-recents -bool FALSE

Show File Extensions by Default

defaults write NSGlobalDomain AppleShowAllExtensions -bool true

Enable tap to click for this user and 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 Right-Click for Apple Magic Mouse

defaults write com.apple.driver.AppleBluetoothMultitouch.mouse MouseButtonMode TwoButton

Disable Safari opening safe files

defaults write com.apple.Safari AutoOpenSafeDownloads 0

Hide All Desktop Icons

defaults write com.apple.finder CreateDesktop false

Show Full Path in Finder Title

defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

Show invisible and .dot files in Finder

defaults write com.apple.finder AppleShowAllFiles -boolean true

Save Documents to local disk (not iCloud) by default

defaults write -g NSDocumentSaveNewDocumentsToCloud -bool false

Disable Creation of Metadata Files on Network Volumes

Avoids creation of .DS_Store and AppleDouble files.

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true

Disable Creation of Metadata Files on USB Volumes

Avoids creation of .DS_Store and AppleDouble files.

defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true

Get SF Mono Fonts

cp -v /System/Applications/Utilities/Terminal.app/Contents/Resources/Fonts/SFMono-* ~/Library/Fonts

Show Expanded Print Panel by Default

defaults write -g PMPrintingExpandedStateForPrint -bool true && \ defaults write -g PMPrintingExpandedStateForPrint2 -bool true

Quit Print Queue when Finished

defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

Enable AirDrop over Ethernet and on Unsupported Macs

defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true

Disable "Ask Siri"

defaults write com.apple.assistant.support "Assistant Enabled" -bool false

Remove Siri icon from status menu

defaults write com.apple.Siri StatusMenuVisible -bool false defaults write com.apple.Siri UserHasDeclinedEnable -bool true

Disable AutoCorrect

defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false

Turn off System Preferences notification badge

defaults write com.apple.systempreferences AttentionPrefBundleIDs 0

Followed by killall Dock

Enable Inspecting WebViews in macOS

defaults write NSGlobalDomain WebKitDeveloperExtras -bool true

defaults write -g WebKitDeveloperExtras -bool YES

References

Awesome macOS Command Line