Skip to content

Instantly share code, notes, and snippets.

@s3rgiosan
Last active March 27, 2024 06:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save s3rgiosan/3639d242729f2cf67be51fead9f0350d to your computer and use it in GitHub Desktop.
Save s3rgiosan/3639d242729f2cf67be51fead9f0350d to your computer and use it in GitHub Desktop.
macOS Setup
###############################################################################
# General UI/UX #
###############################################################################
HOSTNAME="s3rgiosan"
# Set computer name
sudo scutil --set ComputerName $HOSTNAME
sudo scutil --set HostName $HOSTNAME
sudo scutil --set LocalHostName $HOSTNAME
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string $HOSTNAME
# Disable guest user account
sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow GuestEnabled -bool NO;
sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO;
sudo /usr/bin/defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO
# Set sidebar icon size to medium
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
# Save to disk (not to iCloud) by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Expand save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true
# Expand print 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
# Disable animations when opening and closing windows
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
# Accelerated playback when adjusting the window size (Cocoa applications)
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
# Disable animations when opening a Quick Look window
defaults write QLPanelAnimationDuration -float 0
# Show battery percentage
defaults write com.apple.menuextra.battery ShowPercent YES
# Disable ReportCrash
launchctl unload -w /System/Library/LaunchAgents/com.apple.ReportCrash.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.ReportCrash.Root.plist
# Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
# Change clock date and time format
defaults write com.apple.menuextra.clock "DateFormat" "EEE MMM dd HH:mm:ss"
###############################################################################
# Trackpad, mouse, keyboard, Bluetooth accessories, and input #
###############################################################################
# Mouse: change tracking speed
defaults write -g com.apple.mouse.scaling 3
# Trackpad: disable natural scroll direction
defaults write NSGlobalDomain com.apple.swipescrolldirection -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 write com.apple.AppleMultitouchTrackpad Clicking -bool true
defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1
# Increase sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
# Stop iTunes from responding to the keyboard media keys
launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null
# Show AirPort, Bluetooth, Clock, Displays and Volume menus in menu bar
defaults write com.apple.systemuiserver menuExtras -array \
"/System/Library/CoreServices/Menu Extras/AirPort.menu" \
"/System/Library/CoreServices/Menu Extras/Bluetooth.menu" \
"/System/Library/CoreServices/Menu Extras/Clock.menu" \
"/System/Library/CoreServices/Menu Extras/Displays.menu" \
"/System/Library/CoreServices/Menu Extras/Volume.menu"
###############################################################################
# Energy saving #
###############################################################################
# Enable lid wakeup
sudo pmset -a lidwake 1
# Restart automatically if the computer freezes
sudo systemsetup -setrestartfreeze on
# Sleep the display after 15 minutes
sudo pmset -a displaysleep 15
# Disable machine sleep while charging
sudo pmset -c sleep 0
# Set machine sleep to 5 minutes on battery
sudo pmset -b sleep 5
###############################################################################
# Screen #
###############################################################################
# Require password immediately after sleep or screen saver begins
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
# Save screenshots to the desktop
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
###############################################################################
# Finder #
###############################################################################
# Finder: show path bar
defaults write com.apple.finder ShowPathbar -bool true
# Finder: show status bar
defaults write com.apple.finder ShowStatusBar -bool true
# Finder: always sort folders above files when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Finder: use list view in all Finder windows by default
sudo find / -name ".DS_Store" -exec rm {} \;
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Keep folders on top when sorting by name
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Finder: when performing a search, search the current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# 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
# Finder: 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
# Finder: set sidebar icon size to medium
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
# Finder: disable animation when opening the Info window in Finder (cmd⌘ + i)
defaults write com.apple.finder DisableAllAnimations -bool true
# Show item info near icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:showItemInfo true" ~/Library/Preferences/com.apple.finder.plist
# Enable snap-to-grid for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
# Increase grid spacing for icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:gridSpacing 30" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:gridSpacing 30" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:gridSpacing 30" ~/Library/Preferences/com.apple.finder.plist
# Increase the size of icons on the desktop and in other icon views
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:iconSize 40" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:iconSize 40" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:iconSize 40" ~/Library/Preferences/com.apple.finder.plist
# Finder: show the ~/Library folder
chflags nohidden ~/Library
# Finder: show the /Volumes folder
sudo chflags nohidden /Volumes
###############################################################################
# Dock, Dashboard, and hot corners #
###############################################################################
# Set the icon size of Dock items
defaults write com.apple.dock tilesize -int 32
# Automatically hide and show the Dock
defaults write com.apple.dock autohide -bool true
# Minimize windows into application icon
defaults write com.apple.dock minimize-to-application -bool true
# Disable automatically rearrange Spaces Based on most recent use
defaults write com.apple.dock mru-spaces -bool false
# Disable animations when you open an application from the Dock
defaults write com.apple.dock launchanim -bool false
# Make all animations faster that are used by Mission Control
defaults write com.apple.dock expose-animation-duration -float 0.1
# Disable the delay when you hide the Dock
defaults write com.apple.Dock autohide-delay -float 0
# Disable icon bounce
defaults write com.apple.dock no-bouncing -bool false
# Disable Dashboard
defaults write com.apple.dashboard mcx-disabled -bool true
# Don’t show Dashboard as a Space
defaults write com.apple.dock dashboard-in-overlay -bool true
# Hot corners
# Possible values:
# 0: no-op
# 2: Mission Control
# 3: Show application windows
# 4: Desktop
# 5: Start screen saver
# 6: Disable screen saver
# 7: Dashboard
# 10: Put display to sleep
# 11: Launchpad
# 12: Notification Center
# 13: Lock Screen
# Top left screen corner → Mission Control
defaults write com.apple.dock wvous-tl-corner -int 5
defaults write com.apple.dock wvous-tl-modifier -int 0
###############################################################################
# Time Machine #
###############################################################################
# Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
###############################################################################
# Address Book, Dashboard, iCal, TextEdit, and Disk Utility #
###############################################################################
# TextEdit: use plain text mode for new documents
defaults write com.apple.TextEdit RichText -int 0
# TextEdit: open and save files as UTF-8
defaults write com.apple.TextEdit PlainTextEncoding -int 4
defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
###############################################################################
# Mac App Store #
###############################################################################
# Disable the automatic update check
defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool false
# Install System data files & security updates
defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1
# Turn on app auto-update
defaults write com.apple.commerce AutoUpdate -bool true
###############################################################################
# Photos #
###############################################################################
# Prevent Photos from opening automatically when devices are plugged in
defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true
###############################################################################
# Google Chrome & Google Chrome Canary #
###############################################################################
# Use the system-native print preview dialog
defaults write com.google.Chrome DisablePrintPreview -bool true
defaults write com.google.Chrome.canary DisablePrintPreview -bool true
# Expand the print dialog by default
defaults write com.google.Chrome PMPrintingExpandedStateForPrint2 -bool true
defaults write com.google.Chrome.canary PMPrintingExpandedStateForPrint2 -bool true
# Restart Dock
killall Dock
# Restart Finder
sudo killall Finder
###############################################################################
# Homebrew & Software #
###############################################################################
# Get Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Update Homebrew
brew tap homebrew/cask
brew tap homebrew/cask-drivers
brew tap homebrew/cask-fonts
brew tap homebrew/cask-versions
# Install apps
brew install composer
brew install git --build-from-source
brew install openjdk --build-from-source
brew install mackup
brew install mkcert --build-from-source
brew install mysql-client
brew install node --build-from-source
brew install nss --build-from-source
brew install nvm
brew install php@7.4 --build-from-source
brew install android-file-transfer
brew install cleanmymac --cask
brew install cyberduck --cask
brew install docker --cask
brew install firefox --cask
brew install flux --cask
brew install font-fira-code --cask
brew install font-jetbrains-mono --cask
brew install fontforge --cask
brew install google-chrome --cask
brew install iterm2 --cask
brew install libreoffice --cask
brew install logitech-options
brew install microsoft-teams --cask
brew install monitorcontrol --cask
brew install poedit --cask
brew install postman --cask
brew install sourcetree --cask
brew install spectacle --cask
brew install spotify --cask
brew install synology-drive --cask
brew install synology-note-station-client --cask
brew install telegram-desktop
brew install the-unarchiver --cask
brew install tunnelblick
brew install visual-studio-code --cask
brew install vlc --cask
brew install wp-cli
brew install zoomus --cask
# Get Mac App Store CLI
brew install https://dl.bintray.com/phatblat/mas-bottles/mas-1.7.0.high_sierra.bottle.tar.gz
# Install apps from App Store
mas install 1176895641 # Spark
###############################################################################
# Terminal & iTerm 2 #
###############################################################################
# Only use UTF-8 in Terminal.app
defaults write com.apple.terminal StringEncodings -array 4
# Don’t display the annoying prompt when quitting iTerm
defaults write com.googlecode.iterm2 PromptOnQuit -bool false
# Enable shell integration
curl -L https://iterm2.com/misc/install_shell_integration.sh | bash
# Get Oh-My-Zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# Get Powerline fonts
git clone https://github.com/powerline/fonts.git ~/.fonts
~/.fonts/install.sh
# Get Oh-My-Zsh extensions and plugins
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-history-substring-search $ZSH_CUSTOM/plugins/zsh-history-substring-search
git clone https://github.com/lukechilds/zsh-nvm $ZSH_CUSTOM/plugins/zsh-nvm
###############################################################################
# Development #
###############################################################################
# WordPress
composer global require "squizlabs/php_codesniffer=*"
composer global require "wp-coding-standards/wpcs"
composer global require 10up/wpsnapshots
composer global require --dev php-stubs/wordpress-stubs
composer global require --dev php-stubs/woocommerce-stubs
composer global require --dev php-stubs/acf-pro-stubs
composer global require --dev php-stubs/wordpress-globals
composer global require --dev php-stubs/wp-cli-stubs
composer global require --dev php-stubs/wordpress-seo-stubs
composer global require --dev wpsyntex/polylang-stubs
composer global require --dev wpsyntex/polylang-wc-stubs
composer global require --dev wpsyntex/the-events-calendar-stubs
phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs,$HOME/.composer/vendor/phpcsstandards/phpcsutils/PHPCSUtils,$HOME/.composer/vendor/10up/phpcs-composer/10up-Default,$HOME/.composer/vendor/automattic/vipwpcs/WordPress-VIP-Go,$HOME/.composer/vendor/automattic/vipwpcs/WordPressVIPMinimum,$HOME/.composer/vendor/pixelalbatross/coding-standards/PixelAlbatross
phpcs --config-set default_standard WordPress-Extra
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment