Last active
January 10, 2024 20:59
-
-
Save trustin/ce71fcc797af3669604a7c524e909301 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
echo_and_run() { | |
echo "> $*" | |
"$@" | |
} | |
setup_sudo() { | |
# 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 & | |
} | |
OS="$(uname)" | |
OS="${OS,,}" | |
if [[ "$OS" = 'linux' ]]; then | |
setup_sudo | |
pamac install --upgrade --no-confirm \ | |
base-devel \ | |
bat \ | |
bandwhich \ | |
bind \ | |
btop \ | |
clang \ | |
cmake \ | |
convmv \ | |
curl \ | |
difftastic \ | |
docker \ | |
docker-compose \ | |
dog \ | |
dos2unix \ | |
dust \ | |
eza \ | |
fd \ | |
fzf \ | |
gnu-netcat \ | |
hexyl \ | |
inetutils \ | |
jq \ | |
libpamac-flatpak-plugin \ | |
logrotate \ | |
p7zip \ | |
perf \ | |
pigz \ | |
renameutils \ | |
ripgrep \ | |
rrdtool \ | |
sd \ | |
starship \ | |
strace \ | |
sysstat \ | |
tcpdump \ | |
tmux \ | |
traceroute \ | |
trash-cli \ | |
tree \ | |
unrar \ | |
unzip \ | |
vim \ | |
vivaldi \ | |
wget \ | |
xh \ | |
xz \ | |
zoxide \ | |
zstd | |
pamac build --no-confirm \ | |
shellcheck-bin \ | |
visual-studio-code-bin | |
if [[ "$(uname -m)" != 'aarch64' ]]; then | |
pamac install --no-confirm \ | |
vivaldi-ffmpeg-codecs | |
pamac build --no-confirm \ | |
ncurses5-compat-libs | |
fi | |
exit 0 | |
fi | |
if [[ "$OS" = 'darwin' ]]; then | |
BREW='/opt/homebrew/bin/brew' | |
if [[ ! -x "$BREW" ]]; then | |
echo 'Install Homebrew first:' | |
echo | |
echo ' /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' | |
echo | |
exit 1 | |
fi | |
setup_sudo | |
# TODO: Use Homebrew Bundle (https://github.com/Homebrew/homebrew-bundle) | |
"$BREW" install \ | |
bash \ | |
bat \ | |
bandwhich \ | |
bind \ | |
binutils \ | |
btop \ | |
cmake \ | |
convmv \ | |
coreutils \ | |
curl \ | |
difftastic \ | |
diffutils \ | |
dog \ | |
dos2unix \ | |
dust \ | |
eza \ | |
fd \ | |
findutils \ | |
fzf \ | |
git \ | |
gnu-tar \ | |
gnupg \ | |
grep \ | |
hexyl \ | |
inetutils \ | |
jq \ | |
mas \ | |
netcat \ | |
nmap \ | |
p7zip \ | |
pigz \ | |
psutils \ | |
rar \ | |
renameutils \ | |
ripgrep \ | |
rsync \ | |
sd \ | |
shellcheck \ | |
starship \ | |
tcpdump \ | |
tmux \ | |
trash-cli \ | |
tree \ | |
unzip \ | |
vim \ | |
watch \ | |
wget \ | |
xh \ | |
xz \ | |
zoxide \ | |
zstd \ | |
zx | |
"$BREW" install --cask \ | |
1password \ | |
alfred \ | |
bartender \ | |
betterdisplay \ | |
contexts \ | |
gimp \ | |
google-chrome \ | |
iina \ | |
istat-menus \ | |
iterm2 \ | |
jetbrains-toolbox \ | |
microsoft-office \ | |
meetingbar \ | |
moom \ | |
plex-htpc \ | |
rambox \ | |
rocket \ | |
soundsource \ | |
visual-studio-code \ | |
vivaldi \ | |
wireshark | |
# Sometimes fails due to GitHub's ratelimit. | |
"$BREW" install --cask \ | |
th-ch/youtube-music/youtube-music || true | |
mas install 497799835 # Xcode | |
mas install 539883307 # LINE | |
mas install 869223134 # KakaoTalk | |
mas install 1099454186 # Coffee Buzz | |
mas install 1542778639 # MeetInOne | |
# Sources: | |
# - https://github.com/mathiasbynens/dotfiles/blob/main/.macos | |
# - https://github.com/mathiasbynens/dotfiles/issues/701 | |
# - https://github.com/todd-dsm/mac-ops/blob/main/bootstrap.sh | |
# - https://www.nuridol.net/command/mac-setting/ | |
# 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' | |
############################################################################### | |
# General UI/UX # | |
############################################################################### | |
# Set computer name (as done via System Preferences → Sharing) | |
#sudo scutil --set ComputerName "0x6D746873" | |
#sudo scutil --set HostName "0x6D746873" | |
#sudo scutil --set LocalHostName "0x6D746873" | |
#sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "0x6D746873" | |
# Disable the sound effects on boot | |
# Source: https://apple.stackexchange.com/questions/409521/how-to-stop-startup-chime-on-boot-up | |
echo_and_run sudo nvram 'StartupMute=%01' | |
echo_and_run sudo nvram 'SystemAudioVolume=%80' | |
# Set sidebar icon size to medium | |
echo_and_run defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2 | |
# Adjust toolbar title rollover delay | |
echo_and_run defaults write NSGlobalDomain NSToolbarTitleViewRolloverDelay -float 0 | |
# Increase window resize speed for Cocoa applications | |
echo_and_run defaults write NSGlobalDomain NSWindowResizeTime -float 0.001 | |
# Expand save panel by default | |
echo_and_run defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true | |
echo_and_run defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true | |
# Expand print panel by default | |
echo_and_run defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true | |
echo_and_run defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true | |
# Save to disk (not to iCloud) by default | |
echo_and_run defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false | |
# Automatically quit printer app once the print jobs complete | |
echo_and_run defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true | |
# Remove duplicates in the “Open With” menu (also see `lscleanup` alias) | |
echo_and_run /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user | |
# Display ASCII control characters using caret notation in standard text views | |
# Try e.g. `cd /tmp; unidecode "\x{0000}" > cc.txt; open -e cc.txt` | |
echo_and_run defaults write NSGlobalDomain NSTextShowsControlCharacters -bool true | |
# Disable Resume system-wide | |
echo_and_run defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false | |
# Disable automatic termination of inactive apps | |
echo_and_run defaults write NSGlobalDomain NSDisableAutomaticTermination -bool true | |
# Disable the crash reporter | |
echo_and_run defaults write com.apple.CrashReporter DialogType -string "none" | |
# Set Help Viewer windows to non-floating mode | |
echo_and_run defaults write com.apple.helpviewer DevMode -bool true | |
# Reveal IP address, hostname, OS version, etc. when clicking the clock | |
# in the login window | |
echo_and_run sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName | |
# Disable automatic capitalization as it’s annoying when typing code | |
echo_and_run defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false | |
# Disable smart dashes as they’re annoying when typing code | |
echo_and_run defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false | |
# Disable automatic period substitution as it’s annoying when typing code | |
echo_and_run defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false | |
# Disable smart quotes as they’re annoying when typing code | |
echo_and_run defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false | |
# Disable auto-correct | |
echo_and_run defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false | |
# Set a custom wallpaper image. `DefaultDesktop.jpg` is already a symlink, and | |
# all wallpapers are in `/Library/Desktop Pictures/`. The default is `Wave.jpg`. | |
#echo_and_run rm -rf ~/Library/Application Support/Dock/desktoppicture.db | |
#echo_and_run sudo rm -rf /System/Library/CoreServices/DefaultDesktop.jpg | |
#echo_and_run sudo ln -s /path/to/your/image /System/Library/CoreServices/DefaultDesktop.jpg | |
############################################################################### | |
# Trackpad, mouse, keyboard, Bluetooth accessories, and input # | |
############################################################################### | |
# Trackpad: enable tap to click for this user and for the login screen | |
echo_and_run defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true | |
echo_and_run defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 | |
echo_and_run defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 | |
# Trackpad: map bottom right corner to right-click | |
echo_and_run defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadCornerSecondaryClick -int 2 | |
echo_and_run defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightClick -bool true | |
echo_and_run defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1 | |
echo_and_run defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true | |
# Increase sound quality for Bluetooth headphones/headsets | |
echo_and_run defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 | |
# Enable full keyboard access for all controls | |
# (e.g. enable Tab in modal dialogs) | |
echo_and_run defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 | |
# Disable press-and-hold for keys in favor of key repeat | |
echo_and_run defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false | |
# Set a blazingly fast keyboard repeat rate | |
echo_and_run defaults write NSGlobalDomain KeyRepeat -int 2 | |
echo_and_run defaults write NSGlobalDomain InitialKeyRepeat -int 25 | |
# Set language and text formats | |
# Note: if you’re in the US, replace `EUR` with `USD`, `Centimeters` with | |
# `Inches`, `en_GB` with `en_US`, and `true` with `false`. | |
echo_and_run defaults write NSGlobalDomain AppleLanguages -array "en-KR" "ko-KR" | |
echo_and_run defaults write NSGlobalDomain AppleLocale -string "en_KR" | |
echo_and_run defaults write NSGlobalDomain AppleMeasurementUnits -string "Centimeters" | |
echo_and_run defaults write NSGlobalDomain AppleMetricUnits -bool true | |
# Show language menu in the top right corner of the boot screen | |
echo_and_run sudo defaults write /Library/Preferences/com.apple.loginwindow showInputMenu -bool true | |
# Set the timezone; see `sudo systemsetup -listtimezones` for other values | |
echo_and_run sudo systemsetup -settimezone "Asia/Seoul" > /dev/null | |
# Stop iTunes from responding to the keyboard media keys | |
echo_and_run launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null | |
############################################################################### | |
# Energy saving # | |
############################################################################### | |
# Enable lid wakeup | |
echo_and_run sudo pmset -a lidwake 1 | |
# Restart automatically on power loss | |
echo_and_run sudo pmset -a autorestart 1 | |
# Restart automatically if the computer freezes | |
echo_and_run sudo systemsetup -setrestartfreeze on | |
############################################################################### | |
# Screen # | |
############################################################################### | |
# Require password immediately after sleep or screen saver begins | |
echo_and_run defaults write com.apple.screensaver askForPassword -int 1 | |
echo_and_run defaults write com.apple.screensaver askForPasswordDelay -int 0 | |
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) | |
echo_and_run defaults write com.apple.screencapture type -string "png" | |
# Disable shadow in screenshots | |
echo_and_run defaults write com.apple.screencapture disable-shadow -bool true | |
# Enable subpixel font rendering on non-Apple LCDs | |
# Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501 | |
echo_and_run defaults write NSGlobalDomain AppleFontSmoothing -int 1 | |
# Enable HiDPI display modes (requires restart) | |
echo_and_run sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true | |
############################################################################### | |
# Finder # | |
############################################################################### | |
# Set user home as the default location for new Finder windows | |
echo_and_run defaults write com.apple.finder NewWindowTarget -string "PfLo" | |
echo_and_run defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/" | |
# Show icons for hard drives, servers, and removable media on the desktop | |
echo_and_run defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true | |
echo_and_run defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true | |
echo_and_run defaults write com.apple.finder ShowMountedServersOnDesktop -bool true | |
echo_and_run defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true | |
# Finder: show hidden files by default | |
echo_and_run defaults write com.apple.finder AppleShowAllFiles -bool true | |
# Finder: show all filename extensions | |
echo_and_run defaults write NSGlobalDomain AppleShowAllExtensions -bool true | |
# Finder: show status bar | |
echo_and_run defaults write com.apple.finder ShowStatusBar -bool true | |
# Finder: show path bar | |
echo_and_run defaults write com.apple.finder ShowPathbar -bool true | |
# Display full POSIX path as Finder window title | |
echo_and_run defaults write com.apple.finder _FXShowPosixPathInTitle -bool true | |
# Keep folders on top when sorting by name | |
echo_and_run defaults write com.apple.finder _FXSortFoldersFirst -bool true | |
# When performing a search, search the current folder by default | |
echo_and_run defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" | |
# Enable spring loading for directories | |
echo_and_run defaults write NSGlobalDomain com.apple.springing.enabled -bool true | |
# Remove the spring loading delay for directories | |
echo_and_run defaults write NSGlobalDomain com.apple.springing.delay -float 0 | |
# Avoid creating .DS_Store files on network or USB volumes | |
echo_and_run defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true | |
echo_and_run defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true | |
# Disable disk image verification | |
echo_and_run defaults write com.apple.frameworks.diskimages skip-verify -bool true | |
echo_and_run defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true | |
echo_and_run defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true | |
# Automatically open a new Finder window when a volume is mounted | |
echo_and_run defaults write com.apple.frameworks.diskimages auto-open-ro-root -bool true | |
echo_and_run defaults write com.apple.frameworks.diskimages auto-open-rw-root -bool true | |
echo_and_run defaults write com.apple.finder OpenWindowForNewRemovableDisk -bool true | |
# Enable snap-to-grid for icons on the desktop and in other icon views | |
echo_and_run /usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
echo_and_run /usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
echo_and_run /usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist | |
# Use list view in all Finder windows by default | |
# Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv` | |
echo_and_run defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv" | |
# Enable AirDrop over Ethernet and on unsupported Macs running Lion | |
echo_and_run defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true | |
# Show the ~/Library folder | |
echo_and_run chflags nohidden ~/Library | |
# Show the /Volumes folder | |
echo_and_run sudo chflags nohidden /Volumes | |
# Expand the following File Info panes: | |
# “General”, “Open with”, and “Sharing & Permissions” | |
echo_and_run defaults write com.apple.finder FXInfoPanesExpanded -dict \ | |
General -bool true \ | |
OpenWith -bool true \ | |
Privileges -bool true | |
############################################################################### | |
# Dock, Dashboard, and hot corners # | |
############################################################################### | |
# Magnify app icons in Dock | |
echo_and_run defaults write com.apple.dock magnification -int 1 | |
echo_and_run defaults write com.apple.dock largesize -int 128 | |
# Change minimize/maximize window effect | |
echo_and_run defaults write com.apple.dock mineffect -string "scale" | |
# Minimize windows into their application’s icon | |
echo_and_run defaults write com.apple.dock minimize-to-application -bool true | |
# Enable spring loading for all Dock items | |
echo_and_run defaults write com.apple.dock enable-spring-load-actions-on-all-items -bool true | |
# Show indicator lights for open applications in the Dock | |
echo_and_run defaults write com.apple.dock show-process-indicators -bool true | |
# Disable Dashboard | |
echo_and_run defaults write com.apple.dashboard mcx-disabled -bool true | |
# Don’t show Dashboard as a Space | |
echo_and_run defaults write com.apple.dock dashboard-in-overlay -bool true | |
# Don’t automatically rearrange Spaces based on most recent use | |
echo_and_run defaults write com.apple.dock mru-spaces -bool false | |
# Remove the auto-hiding Dock delay | |
echo_and_run defaults write com.apple.dock autohide-delay -float 0 | |
# Accelerate the animation when hiding/showing the Dock | |
defaults write com.apple.dock autohide-time-modifier -float 0.5 | |
# Automatically hide and show the Dock | |
echo_and_run defaults write com.apple.dock autohide -bool true | |
# Make Dock icons of hidden applications translucent | |
echo_and_run defaults write com.apple.dock showhidden -bool true | |
# Don’t show recent applications in Dock | |
echo_and_run defaults write com.apple.dock show-recents -bool false | |
# Disable the Launchpad gesture (pinch with thumb and three fingers) | |
echo_and_run defaults write com.apple.dock showLaunchpadGestureEnabled -int 0 | |
# Add iOS & Watch Simulator to Launchpad | |
if [[ -a '/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app' ]]; then | |
sudo ln -sf '/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app' '/Applications/Simulator.app' | |
fi | |
if [[ -a '/Applications/Xcode.app/Contents/Developer/Applications/Simulator (Watch).app' ]]; then | |
sudo ln -sf '/Applications/Xcode.app/Contents/Developer/Applications/Simulator (Watch).app' '/Applications/Simulator (Watch).app' | |
fi | |
# Reset Launchpad, but keep the desktop wallpaper intact | |
echo_and_run find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete | |
# 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 | |
echo_and_run defaults write com.apple.dock wvous-tl-corner -int 0 | |
echo_and_run defaults write com.apple.dock wvous-tl-modifier -int 0 | |
echo_and_run defaults write com.apple.dock wvous-tr-corner -int 0 | |
echo_and_run defaults write com.apple.dock wvous-tr-modifier -int 0 | |
echo_and_run defaults write com.apple.dock wvous-bl-corner -int 0 | |
echo_and_run defaults write com.apple.dock wvous-bl-modifier -int 0 | |
echo_and_run defaults write com.apple.dock wvous-br-corner -int 0 | |
echo_and_run defaults write com.apple.dock wvous-br-modifier -int 0 | |
############################################################################### | |
# Safari & WebKit # | |
############################################################################### | |
# Press Tab to highlight each item on a web page | |
echo_and_run defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true | |
echo_and_run defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true | |
# Show the full URL in the address bar (note: this still hides the scheme) | |
echo_and_run defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true | |
# Set Safari’s home page to `about:blank` for faster loading | |
echo_and_run defaults write com.apple.Safari HomePage -string "about:blank" | |
# Prevent Safari from opening ‘safe’ files automatically after downloading | |
echo_and_run defaults write com.apple.Safari AutoOpenSafeDownloads -bool false | |
# Allow hitting the Backspace key to go to the previous page in history | |
echo_and_run defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true | |
# Enable the Develop menu and the Web Inspector in Safari | |
echo_and_run defaults write com.apple.Safari IncludeDevelopMenu -bool true | |
echo_and_run defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true | |
echo_and_run defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true | |
# Add a context menu item for showing the Web Inspector in web views | |
echo_and_run defaults write NSGlobalDomain WebKitDeveloperExtras -bool true | |
# Disable auto-correct | |
echo_and_run defaults write com.apple.Safari WebAutomaticSpellingCorrectionEnabled -bool false | |
# Disable AutoFill | |
echo_and_run defaults write com.apple.Safari AutoFillFromAddressBook -bool false | |
echo_and_run defaults write com.apple.Safari AutoFillPasswords -bool false | |
echo_and_run defaults write com.apple.Safari AutoFillCreditCardData -bool false | |
echo_and_run defaults write com.apple.Safari AutoFillMiscellaneousForms -bool false | |
# Warn about fraudulent websites | |
echo_and_run defaults write com.apple.Safari WarnAboutFraudulentWebsites -bool true | |
# Update extensions automatically | |
echo_and_run defaults write com.apple.Safari InstallExtensionUpdatesAutomatically -bool true | |
# Disable back/forward gesture in web browsers: | |
echo_and_run defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool false | |
echo_and_run defaults write org.mozilla.firefox AppleEnableSwipeNavigateWithScrolls -bool false | |
echo_and_run defaults write com.vivaldi.Vivaldi AppleEnableSwipeNavigateWithScrolls -bool false | |
# Change indexing order and disable some search results | |
# Yosemite-specific search results (remove them if you are using macOS 10.9 or older): | |
# MENU_DEFINITION | |
# MENU_CONVERSION | |
# MENU_EXPRESSION | |
# MENU_SPOTLIGHT_SUGGESTIONS (send search queries to Apple) | |
# MENU_WEBSEARCH (send search queries to Apple) | |
# MENU_OTHER | |
echo_and_run defaults write com.apple.spotlight orderedItems -array \ | |
'{"enabled" = 1;"name" = "APPLICATIONS";}' \ | |
'{"enabled" = 1;"name" = "SYSTEM_PREFS";}' \ | |
'{"enabled" = 0;"name" = "DIRECTORIES";}' \ | |
'{"enabled" = 0;"name" = "PDF";}' \ | |
'{"enabled" = 0;"name" = "FONTS";}' \ | |
'{"enabled" = 0;"name" = "DOCUMENTS";}' \ | |
'{"enabled" = 0;"name" = "MESSAGES";}' \ | |
'{"enabled" = 0;"name" = "CONTACT";}' \ | |
'{"enabled" = 0;"name" = "EVENT_TODO";}' \ | |
'{"enabled" = 0;"name" = "IMAGES";}' \ | |
'{"enabled" = 0;"name" = "BOOKMARKS";}' \ | |
'{"enabled" = 0;"name" = "MUSIC";}' \ | |
'{"enabled" = 0;"name" = "MOVIES";}' \ | |
'{"enabled" = 0;"name" = "PRESENTATIONS";}' \ | |
'{"enabled" = 0;"name" = "SPREADSHEETS";}' \ | |
'{"enabled" = 0;"name" = "SOURCE";}' \ | |
'{"enabled" = 0;"name" = "MENU_DEFINITION";}' \ | |
'{"enabled" = 0;"name" = "MENU_OTHER";}' \ | |
'{"enabled" = 0;"name" = "MENU_CONVERSION";}' \ | |
'{"enabled" = 0;"name" = "MENU_EXPRESSION";}' \ | |
'{"enabled" = 0;"name" = "MENU_WEBSEARCH";}' \ | |
'{"enabled" = 0;"name" = "MENU_SPOTLIGHT_SUGGESTIONS";}' | |
# Load new settings before rebuilding the index | |
killall mds > /dev/null 2>&1 || true | |
# Make sure indexing is enabled for the main volume | |
sudo mdutil -i on / > /dev/null | |
# Rebuild the index from scratch | |
sudo mdutil -E / > /dev/null | |
############################################################################### | |
# Terminal & iTerm 2 # | |
############################################################################### | |
# Only use UTF-8 in Terminal.app | |
echo_and_run defaults write com.apple.terminal StringEncodings -array 4 | |
# Don’t display the annoying prompt when quitting iTerm | |
echo_and_run defaults write com.googlecode.iterm2 PromptOnQuit -bool false | |
############################################################################### | |
# Activity Monitor # | |
############################################################################### | |
# Show the main window when launching Activity Monitor | |
echo_and_run defaults write com.apple.ActivityMonitor OpenMainWindow -bool true | |
# Show all processes in Activity Monitor | |
echo_and_run defaults write com.apple.ActivityMonitor ShowCategory -int 0 | |
# Sort Activity Monitor results by CPU usage | |
echo_and_run defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" | |
echo_and_run defaults write com.apple.ActivityMonitor SortDirection -int 0 | |
############################################################################### | |
# TextEdit and Disk Utility # | |
############################################################################### | |
# Use plain text mode for new TextEdit documents | |
echo_and_run defaults write com.apple.TextEdit RichText -int 0 | |
# Open and save files as UTF-8 in TextEdit | |
echo_and_run defaults write com.apple.TextEdit PlainTextEncoding -int 4 | |
echo_and_run defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4 | |
# Disable smart dashes and quotes | |
echo_and_run defaults write com.apple.TextEdit SmartDashes -int 0 | |
echo_and_run defaults write com.apple.TextEdit SmartQuotes -int 0 | |
# Enable the debug menu in Disk Utility | |
echo_and_run defaults write com.apple.DiskUtility DUDebugMenuEnabled -bool true | |
echo_and_run defaults write com.apple.DiskUtility advanced-image-options -bool true | |
# Auto-play videos when opened with QuickTime Player | |
echo_and_run defaults write com.apple.QuickTimePlayerX MGPlayMovieOnOpen -bool true | |
############################################################################### | |
# Mac App Store # | |
############################################################################### | |
# Enable the WebKit Developer Tools in the Mac App Store | |
echo_and_run defaults write com.apple.appstore WebKitDeveloperExtras -bool true | |
# Enable the automatic update check | |
echo_and_run defaults write com.apple.SoftwareUpdate AutomaticCheckEnabled -bool true | |
# Check for software updates daily, not just once per week | |
echo_and_run defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 | |
# Download newly available updates in background | |
echo_and_run defaults write com.apple.SoftwareUpdate AutomaticDownload -int 1 | |
# Install System data files & security updates | |
echo_and_run defaults write com.apple.SoftwareUpdate CriticalUpdateInstall -int 1 | |
# Automatically download apps purchased on other Macs | |
echo_and_run defaults write com.apple.SoftwareUpdate ConfigDataInstall -int 1 | |
# Turn on app auto-update | |
echo_and_run defaults write com.apple.commerce AutoUpdate -bool true | |
# Allow the App Store to reboot machine on macOS updates | |
echo_and_run defaults write com.apple.commerce AutoUpdateRestartRequired -bool true | |
############################################################################### | |
# Photos # | |
############################################################################### | |
# Prevent Photos from opening automatically when devices are plugged in | |
echo_and_run defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true | |
############################################################################### | |
# Messages # | |
############################################################################### | |
# Disable automatic emoji substitution (i.e. use plain text smileys) | |
echo_and_run defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticEmojiSubstitutionEnablediMessage" -bool false | |
# Disable smart quotes as it’s annoying for messages that contain code | |
echo_and_run defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false | |
# Disable continuous spell checking | |
echo_and_run defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false | |
############################################################################### | |
# Miscellaneous # | |
############################################################################### | |
# Show battery percentage. | |
echo_and_run defaults write com.apple.menuextra.battery ShowPercent -string "YES" | |
echo_and_run defaults -currentHost write com.apple.controlcenter.plist BatteryShowPercentage -bool true | |
# Disable AFP guest access. | |
echo_and_run defaults write com.apple.AppleFileServer.plist AllowGuestAccess -int 0 | |
# Enable subpixel font rendering on non-Apple LCDs | |
# Reference: https://github.com/kevinSuttle/macOS-Defaults/issues/17#issuecomment-266633501 | |
echo_and_run defaults write NSGlobalDomain AppleFontSmoothing -int 1 | |
# Stop iTunes from responding to the keyboard media keys | |
echo_and_run launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null | |
echo | |
echo 'Bootstrapping finished. Remaining manual steps:' | |
echo '- Configure iTerm, e.g. bulk-copy or import your profile into the default one.' | |
exit 0 | |
fi | |
echo "Unsupported OS: $OS" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment