155 lines
6.2 KiB
Bash
Executable File
155 lines
6.2 KiB
Bash
Executable File
#!/usr/bin/env sh
|
||
# Inspired by https://github.com/mathiasbynens/dotfiles/blob/master/.macos from Mathias Bynens
|
||
|
||
MAC_HOSTNAME="leia"
|
||
|
||
# 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 &
|
||
|
||
# Set hostname
|
||
sudo scutil --set ComputerName "$MAC_HOSTNAME"
|
||
sudo scutil --set HostName "$MAC_HOSTNAME"
|
||
sudo scutil --set LocalHostName "$MAC_HOSTNAME"
|
||
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$MAC_HOSTNAME"
|
||
|
||
# Always show scrollbars
|
||
defaults write NSGlobalDomain AppleShowScrollBars -string "Always"
|
||
|
||
# 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
|
||
|
||
# Save to disk (not to iCloud) by default
|
||
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
|
||
|
||
# Automatically quit printer app once the print jobs complete
|
||
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
|
||
|
||
# Disable the “Are you sure you want to open this application?” dialog
|
||
defaults write com.apple.LaunchServices LSQuarantine -bool false
|
||
|
||
# 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
|
||
|
||
# Reveal IP address, hostname, OS version, etc. when clicking the clock
|
||
# in the login window
|
||
sudo defaults write /Library/Preferences/com.apple.loginwindow AdminHostInfo HostName
|
||
|
||
# Disable automatic capitalization as it’s annoying when typing code
|
||
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -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`.
|
||
#rm -rf ~/Library/Application Support/Dock/desktoppicture.db
|
||
#sudo rm -rf /System/Library/CoreServices/DefaultDesktop.jpg
|
||
#sudo ln -s /path/to/your/image /System/Library/CoreServices/DefaultDesktop.jpg
|
||
|
||
# Save screenshots to the desktop
|
||
defaults write com.apple.screencapture location -string "${HOME}/Desktop"
|
||
|
||
# Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF)
|
||
defaults write com.apple.screencapture type -string "png"
|
||
|
||
# Disable shadow in screenshots
|
||
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
|
||
defaults write NSGlobalDomain AppleFontSmoothing -int 1
|
||
|
||
# Enable HiDPI display modes (requires restart)
|
||
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
|
||
|
||
# Set $HOME as the default location for new Finder windows
|
||
# For other paths, use `PfLo` and `file:///full/path/here/`
|
||
defaults write com.apple.finder NewWindowTarget -string "PfLO"
|
||
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}"
|
||
|
||
# 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: show all filename extensions
|
||
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
|
||
|
||
# Finder: show status bar
|
||
defaults write com.apple.finder ShowStatusBar -bool true
|
||
|
||
# Finder: show path bar
|
||
defaults write com.apple.finder ShowPathbar -bool true
|
||
|
||
# Display full POSIX path as Finder window title
|
||
defaults write com.apple.finder _FXShowPosixPathInTitle -bool true
|
||
|
||
# Keep folders on top when sorting by name
|
||
defaults write com.apple.finder _FXSortFoldersFirst -bool true
|
||
|
||
# When performing a search, search the current folder by default
|
||
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
|
||
|
||
# Disable the 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
|
||
|
||
# Use list view in all Finder windows by default
|
||
# Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv`
|
||
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
|
||
|
||
#Enable AirDrop over Ethernet and on unsupported Macs running Lion
|
||
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
|
||
|
||
# Show the /Volumes folder
|
||
sudo chflags nohidden /Volumes
|
||
|
||
# Expand the following File Info panes:
|
||
# “General”, “Open with”, and “Sharing & Permissions”
|
||
defaults write com.apple.finder FXInfoPanesExpanded -dict \
|
||
General -bool true \
|
||
OpenWith -bool true \
|
||
Privileges -bool true
|
||
|
||
# Don’t group windows by application in Mission Control
|
||
# (i.e. use the old Exposé behavior instead)
|
||
defaults write com.apple.dock expose-group-by-app -bool false
|
||
|
||
# Don’t automatically rearrange Spaces based on most recent use
|
||
defaults write com.apple.dock mru-spaces -bool false
|
||
|
||
# Hot corners
|
||
# Bottom left screen corner → Desktop
|
||
defaults write com.apple.dock wvous-bl-corner -int 4
|
||
defaults write com.apple.dock wvous-bl-modifier -int 0
|
||
|
||
# Check for software updates daily, not just once per week
|
||
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
|
||
|
||
# Kill affected apps
|
||
for app in "Activity Monitor" \
|
||
"cfprefsd" \
|
||
"Finder" \
|
||
"SystemUIServer"; do
|
||
killall "${app}" &> /dev/null
|
||
done
|
||
|
||
# Install homebrew
|
||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
|
||
|
||
# Install apps from Brewfile
|
||
brew bundle
|