diff --git a/bootstrap.sh b/bootstrap.sh index abe1aeeb2..e85be7178 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -10,10 +10,11 @@ function doIt() { source ~/.bash_profile; } -if [ "$1" == "--force" -o "$1" == "-f" ]; then +if [[ "$1" == "--force" || "$1" == "-f" ]]; then doIt; else - read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1; + printf "This may overwrite existing files in your home directory. Are you sure? (y/n) " + read -n 1 REPLY; echo ""; if [[ $REPLY =~ ^[Yy]$ ]]; then doIt; diff --git a/brew.sh b/brew.sh index 2f8a7136f..001c9c0f0 100755 --- a/brew.sh +++ b/brew.sh @@ -19,7 +19,7 @@ fi brew update # Upgrade any already-installed formulae. -brew upgrade --all +brew upgrade # Install GNU core utilities (those that come with OS X are outdated). # Don’t forget to add `$(brew --prefix coreutils)/libexec/gnubin` to `$PATH`. @@ -42,8 +42,8 @@ sudo bash -c 'echo /usr/local/bin/bash >> /etc/shells' # Change to the new shell, prompts for password chsh -s /usr/local/bin/bash -# Install `wget` with IRI support. -brew install wget --with-iri +# Install `wget` (IRI support is now built-in by default) +brew install wget # Install RingoJS and Narwhal. # Note that the order in which these are installed is important; @@ -62,11 +62,12 @@ LINE='eval "$(rbenv init -)"' grep -q "$LINE" ~/.extra || echo "$LINE" >> ~/.extra # Install more recent versions of some OS X tools. -brew install vim --override-system-vi -brew install homebrew/dupes/grep -brew install homebrew/dupes/openssh -brew install homebrew/dupes/screen -brew install homebrew/php/php55 --with-gmp +brew install vim +brew install grep +brew install openssh +brew install screen +# Note: PHP 5.5 is deprecated, consider using a newer version +# brew install php # Install font tools. brew tap bramstein/webfonttools @@ -97,7 +98,7 @@ brew install tcpflow brew install tcpreplay brew install tcptrace brew install ucspi-tcp # `tcpserver` etc. -brew install homebrew/x11/xpdf +brew install xpdf brew install xz # Install other useful binaries. @@ -109,7 +110,7 @@ brew install git-lfs brew install git-flow brew install git-extras brew install hub -brew install imagemagick --with-webp +brew install imagemagick brew install lua brew install lynx brew install p7zip @@ -120,7 +121,8 @@ brew install rhino brew install speedtest_cli brew install ssh-copy-id brew install tree -brew install webkit2png +# Modern web screenshot alternative (replaces deprecated webkit2png) +brew install wkhtmltopdf # Includes wkhtmltoimage for screenshots brew install zopfli brew install pkg-config libffi brew install pandoc @@ -136,38 +138,39 @@ brew install heroku/brew/heroku heroku update # Core casks -brew cask install --appdir="/Applications" alfred -brew cask install --appdir="~/Applications" iterm2 -brew cask install --appdir="~/Applications" java -brew cask install --appdir="~/Applications" xquartz +brew install --cask alfred +brew install --cask iterm2 +brew install --cask java +brew install --cask xquartz # Development tool casks -brew cask install --appdir="/Applications" sublime-text -brew cask install --appdir="/Applications" atom -brew cask install --appdir="/Applications" virtualbox -brew cask install --appdir="/Applications" vagrant -brew cask install --appdir="/Applications" macdown +brew install --cask sublime-text +brew install --cask cursor +brew install --cask cursor-cli +brew install --cask goneovim +brew install --cask zed +brew install --cask docker +brew install --cask obsidian +brew install --cask notion # Misc casks -brew cask install --appdir="/Applications" google-chrome -brew cask install --appdir="/Applications" firefox -brew cask install --appdir="/Applications" skype -brew cask install --appdir="/Applications" slack -brew cask install --appdir="/Applications" dropbox -brew cask install --appdir="/Applications" evernote -brew cask install --appdir="/Applications" 1password -#brew cask install --appdir="/Applications" gimp -#brew cask install --appdir="/Applications" inkscape +brew install --cask google-chrome +brew install --cask firefox +brew install --cask slack +brew install --cask dropbox +brew install --cask 1password +#brew install --cask gimp +#brew install --cask inkscape #Remove comment to install LaTeX distribution MacTeX -#brew cask install --appdir="/Applications" mactex +brew install --cask mactex # Install Docker, which requires virtualbox brew install docker brew install boot2docker # Install developer friendly quick look plugins; see https://github.com/sindresorhus/quick-look-plugins -brew cask install qlcolorcode qlstephen qlmarkdown quicklook-json qlprettypatch quicklook-csv betterzip qlimagesize webpquicklook suspicious-package quicklookase qlvideo +brew install --cask qlcolorcode qlstephen qlmarkdown quicklook-json qlprettypatch quicklook-csv betterzip webpquicklook suspicious-package quicklookase qlvideo # Remove outdated versions from the cellar. brew cleanup diff --git a/osx.sh b/osx.sh index 14cdfba54..1726dca79 100755 --- a/osx.sh +++ b/osx.sh @@ -8,6 +8,34 @@ sudo -v # Keep-alive: update existing `sudo` time stamp until `osx.sh` has finished while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & +# Helper function to ensure Safari preferences can be written +setup_safari_prefs() { + # Ensure Safari has been launched at least once to create its preference files + if [ ! -f ~/Library/Preferences/com.apple.Safari.plist ]; then + echo "Safari preferences not found. Launching Safari briefly to initialize preferences..." + open -a Safari + sleep 2 + killall Safari 2>/dev/null + sleep 1 + fi +} + +# Helper function to safely write defaults with better error handling +safe_defaults_write() { + local domain="$1" + local key="$2" + local type="$3" + local value="$4" + local description="$5" + + if defaults write "$domain" "$key" "$type" "$value" 2>/dev/null; then + return 0 + else + echo "Warning: Could not set $description" + return 1 + fi +} + ############################################################################### # General UI/UX # ############################################################################### @@ -25,7 +53,9 @@ while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & sudo nvram SystemAudioVolume=" " # Disable transparency in the menu bar and elsewhere on Yosemite -defaults write com.apple.universalaccess reduceTransparency -bool true +# Note: This setting may require System Preferences to be closed first +killall "System Preferences" 2>/dev/null +defaults write com.apple.universalaccess reduceTransparency -bool true 2>/dev/null || echo "Warning: Could not set reduceTransparency (requires System Preferences restart)" # Menu bar: hide the Time Machine, Volume, and User icons for domain in ~/Library/Preferences/ByHost/com.apple.systemuiserver.*; do @@ -115,7 +145,8 @@ sudo systemsetup -setcomputersleep Off > /dev/null defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1 # Disable Notification Center and remove the menu bar icon -launchctl unload -w /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null +# Note: Using bootout instead of deprecated unload command +launchctl bootout gui/$(id -u) /System/Library/LaunchAgents/com.apple.notificationcenterui.plist 2> /dev/null # Disable smart quotes as they’re annoying when typing code defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false @@ -135,7 +166,8 @@ defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false ############################################################################### # Disable local Time Machine snapshots -sudo tmutil disablelocal +# Note: disablelocal is deprecated and no longer needed in modern macOS +# sudo tmutil disablelocal # Disable hibernation (speeds up entering sleep mode) sudo pmset -a hibernatemode 0 @@ -165,9 +197,13 @@ defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadRightC defaults -currentHost write NSGlobalDomain com.apple.trackpad.trackpadCornerClickBehavior -int 1 defaults -currentHost write NSGlobalDomain com.apple.trackpad.enableSecondaryClick -bool true -# Disable “natural” (Lion-style) scrolling +# Disable "natural" (Lion-style) scrolling defaults write NSGlobalDomain com.apple.swipescrolldirection -bool false +# Enable 3 finger drag +defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad TrackpadThreeFingerDrag -bool true +defaults write com.apple.AppleMultitouchTrackpad TrackpadThreeFingerDrag -bool true + # Increase sound quality for Bluetooth headphones/headsets defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 @@ -176,10 +212,12 @@ defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int defaults write NSGlobalDomain AppleKeyboardUIMode -int 3 # Use scroll gesture with the Ctrl (^) modifier key to zoom -defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true -defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 +# Note: These accessibility settings may require System Preferences to be closed +killall "System Preferences" 2>/dev/null +defaults write com.apple.universalaccess closeViewScrollWheelToggle -bool true 2>/dev/null || echo "Warning: Could not set closeViewScrollWheelToggle (may require manual accessibility permissions)" +defaults write com.apple.universalaccess HIDScrollZoomModifierMask -int 262144 2>/dev/null || echo "Warning: Could not set HIDScrollZoomModifierMask (may require manual accessibility permissions)" # Follow the keyboard focus while zoomed in -defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true +defaults write com.apple.universalaccess closeViewZoomFollowsFocus -bool true 2>/dev/null || echo "Warning: Could not set closeViewZoomFollowsFocus (may require manual accessibility permissions)" # Disable press-and-hold for keys in favor of key repeat defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false @@ -200,8 +238,10 @@ defaults write NSGlobalDomain InitialKeyRepeat -int 15 # Disable auto-correct defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false -# Stop iTunes from responding to the keyboard media keys -#launchctl unload -w /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null +# Stop Music app (formerly iTunes) from responding to the keyboard media keys +# Note: iTunes was replaced by Music app in macOS Catalina +# The exact plist path may have changed - verify before uncommenting +#launchctl bootout gui/$(id -u) /System/Library/LaunchAgents/com.apple.rcd.plist 2> /dev/null ############################################################################### # Screen # @@ -215,7 +255,7 @@ defaults write com.apple.screensaver askForPasswordDelay -int 0 #defaults write com.apple.screencapture location -string "${HOME}/Desktop" # Save screenshots to the Pictures/Screenshots -mkdir ${HOME}/Pictures/Screenshots +mkdir -p ${HOME}/Pictures/Screenshots 2>/dev/null defaults write com.apple.screencapture location -string "${HOME}/Pictures/Screenshots" # Save screenshots in PNG format (other options: BMP, GIF, JPG, PDF, TIFF) @@ -331,7 +371,8 @@ defaults write com.apple.finder EmptyTrashSecurely -bool true defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true # Enable the MacBook Air SuperDrive on any Mac -sudo nvram boot-args="mbasd=1" +# Note: This may fail on newer Macs with System Integrity Protection (SIP) +sudo nvram boot-args="mbasd=1" 2>/dev/null || echo "Warning: Could not set boot-args (likely due to SIP restrictions)" # Show the ~/Library folder chflags nohidden ~/Library @@ -384,11 +425,11 @@ defaults write com.apple.dock expose-animation-duration -float 0.1 # (i.e. use the old Exposé behavior instead) defaults write com.apple.dock expose-group-by-app -bool false -# Disable Dashboard +# Dashboard was removed in macOS Big Sur - these settings are no longer needed #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 +# Dashboard was removed in macOS Big Sur - this setting is no longer needed +# defaults write com.apple.dock dashboard-in-overlay -bool true # Don’t automatically rearrange Spaces based on most recent use defaults write com.apple.dock mru-spaces -bool false @@ -408,10 +449,19 @@ defaults write com.apple.dock autohide -bool true #defaults write com.apple.dock showLaunchpadGestureEnabled -int 0 # Reset Launchpad, but keep the desktop wallpaper intact +# Create the Dock directory if it doesn't exist +mkdir -p "${HOME}/Library/Application Support/Dock" find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete # Add iOS Simulator to Launchpad -sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app" "/Applications/iOS Simulator.app" +# Note: iOS Simulator path may vary between Xcode versions - verify path before running +# Modern Xcode versions may have the simulator at: +# /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app +if [ -e "/Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app" ]; then + sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app" "/Applications/iOS Simulator.app" +elif [ -e "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" ]; then + sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" "/Applications/iOS Simulator.app" +fi # Add a spacer to the left side of the Dock (where the applications are) #defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}' @@ -444,48 +494,60 @@ defaults write com.apple.dock wvous-bl-modifier -int 0 # Safari & WebKit # ############################################################################### -# Privacy: don’t send search queries to Apple -defaults write com.apple.Safari UniversalSearchEnabled -bool false -defaults write com.apple.Safari SuppressSearchSuggestions -bool true +# Initialize Safari preferences if needed +setup_safari_prefs + +# Privacy: don't send search queries to Apple +# Note: Safari settings may require Safari to be closed first +killall "Safari" 2>/dev/null +# Try writing to both current user and all users domains +defaults write com.apple.Safari UniversalSearchEnabled -bool false 2>/dev/null || { + echo "Warning: Could not set Safari UniversalSearchEnabled (Safari may need to be launched first)" + # Create Safari preferences directory if it doesn't exist + mkdir -p ~/Library/Preferences +} +defaults write com.apple.Safari SuppressSearchSuggestions -bool true 2>/dev/null || { + echo "Warning: Could not set Safari SuppressSearchSuggestions (Safari may need to be launched first)" +} # Press Tab to highlight each item on a web page -defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true -defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true +defaults write com.apple.Safari WebKitTabToLinksPreferenceKey -bool true 2>/dev/null || echo "Warning: Could not set Safari WebKitTabToLinksPreferenceKey (Safari may need to be launched first)" +defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2TabsToLinks -bool true 2>/dev/null || echo "Warning: Could not set Safari WebKit2TabsToLinks (Safari may need to be launched first)" # Show the full URL in the address bar (note: this still hides the scheme) -defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true +defaults write com.apple.Safari ShowFullURLInSmartSearchField -bool true 2>/dev/null || echo "Warning: Could not set Safari ShowFullURLInSmartSearchField (Safari may need to be launched first)" -# Set Safari’s home page to `about:blank` for faster loading -defaults write com.apple.Safari HomePage -string "about:blank" +# Set Safari's home page to `about:blank` for faster loading +defaults write com.apple.Safari HomePage -string "about:blank" 2>/dev/null || echo "Warning: Could not set Safari HomePage (Safari may need to be launched first)" -# Prevent Safari from opening ‘safe’ files automatically after downloading -defaults write com.apple.Safari AutoOpenSafeDownloads -bool false +# Prevent Safari from opening 'safe' files automatically after downloading +defaults write com.apple.Safari AutoOpenSafeDownloads -bool false 2>/dev/null || echo "Warning: Could not set Safari AutoOpenSafeDownloads (Safari may need to be launched first)" # Allow hitting the Backspace key to go to the previous page in history -#defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true +#defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2BackspaceKeyNavigationEnabled -bool true 2>/dev/null || echo "Warning: Could not set Safari WebKit2BackspaceKeyNavigationEnabled" -# Hide Safari’s bookmarks bar by default -defaults write com.apple.Safari ShowFavoritesBar -bool false +# Hide Safari's bookmarks bar by default +defaults write com.apple.Safari ShowFavoritesBar -bool false 2>/dev/null || echo "Warning: Could not set Safari ShowFavoritesBar (Safari may need to be launched first)" -# Hide Safari’s sidebar in Top Sites -defaults write com.apple.Safari ShowSidebarInTopSites -bool false +# Hide Safari's sidebar in Top Sites +defaults write com.apple.Safari ShowSidebarInTopSites -bool false 2>/dev/null || echo "Warning: Could not set Safari ShowSidebarInTopSites (Safari may need to be launched first)" -# Disable Safari’s thumbnail cache for History and Top Sites -defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2 +# Disable Safari's thumbnail cache for History and Top Sites +defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2 2>/dev/null || echo "Warning: Could not set Safari DebugSnapshotsUpdatePolicy (Safari may need to be launched first)" -# Enable Safari’s debug menu -defaults write com.apple.Safari IncludeInternalDebugMenu -bool true +# Enable Safari's debug menu +defaults write com.apple.Safari IncludeInternalDebugMenu -bool true 2>/dev/null || echo "Warning: Could not set Safari IncludeInternalDebugMenu (Safari may need to be launched first)" -# Make Safari’s search banners default to Contains instead of Starts With -defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false +# Make Safari's search banners default to Contains instead of Starts With +defaults write com.apple.Safari FindOnPageMatchesWordStartsOnly -bool false 2>/dev/null || echo "Warning: Could not set Safari FindOnPageMatchesWordStartsOnly (Safari may need to be launched first)" -# Remove useless icons from Safari’s bookmarks bar -defaults write com.apple.Safari ProxiesInBookmarksBar "()" +# Remove useless icons from Safari's bookmarks bar +defaults write com.apple.Safari ProxiesInBookmarksBar "()" 2>/dev/null || echo "Warning: Could not set Safari ProxiesInBookmarksBar (Safari may need to be launched first)" # Enable the Develop menu and the Web Inspector in Safari -defaults write com.apple.Safari IncludeDevelopMenu -bool true -defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true -defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true +defaults write com.apple.Safari IncludeDevelopMenu -bool true 2>/dev/null || echo "Warning: Could not set Safari IncludeDevelopMenu (Safari may need to be launched first)" +defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true 2>/dev/null || echo "Warning: Could not set Safari WebKitDeveloperExtrasEnabledPreferenceKey (Safari may need to be launched first)" +defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true 2>/dev/null || echo "Warning: Could not set Safari WebKit2DeveloperExtrasEnabled (Safari may need to be launched first)" # Add a context menu item for showing the Web Inspector in web views defaults write NSGlobalDomain WebKitDeveloperExtras -bool true @@ -524,7 +586,11 @@ defaults write com.apple.mail SpellCheckingBehavior -string "NoSpellCheckingEnab # Disable Spotlight indexing for any volume that gets mounted and has not yet # been indexed before. # Use `sudo mdutil -i off "/Volumes/foo"` to stop indexing any volume. -sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes" +if sudo test -d /.Spotlight-V100; then + sudo defaults write /.Spotlight-V100/VolumeConfiguration Exclusions -array "/Volumes" 2>/dev/null || echo "Warning: Could not set Spotlight VolumeConfiguration (directory may not exist yet)" +else + echo "Info: Spotlight VolumeConfiguration directory not found - this is normal on fresh systems" +fi # Change indexing order and disable some search results # Yosemite-specific search results (remove them if your are using OS X 10.9 or older): # MENU_DEFINITION @@ -653,7 +719,8 @@ defaults write com.googlecode.iterm2 PromptOnQuit -bool false defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true # Disable local Time Machine backups -hash tmutil &> /dev/null && sudo tmutil disablelocal +# Note: disablelocal is deprecated and no longer needed in modern macOS +# hash tmutil > /dev/null 2>&1 && sudo tmutil disablelocal ############################################################################### # Activity Monitor # @@ -673,16 +740,18 @@ defaults write com.apple.ActivityMonitor SortColumn -string "CPUUsage" defaults write com.apple.ActivityMonitor SortDirection -int 0 ############################################################################### -# Address Book, Dashboard, iCal, TextEdit, and Disk Utility # +# Contacts, Calendar, TextEdit, and Disk Utility # ############################################################################### -# Enable the debug menu in Address Book -defaults write com.apple.addressbook ABShowDebugMenu -bool true +# Enable the debug menu in Contacts (formerly Address Book) +# Note: Contacts app may need to be closed first +killall "Contacts" 2>/dev/null +defaults write com.apple.AddressBook ABShowDebugMenu -bool true 2>/dev/null || echo "Warning: Could not set AddressBook ABShowDebugMenu (Contacts may need to be launched first)" -# Enable Dashboard dev mode (allows keeping widgets on the desktop) -defaults write com.apple.dashboard devmode -bool true +# Dashboard was removed in macOS Big Sur - this setting is no longer needed +# defaults write com.apple.dashboard devmode -bool true -# Enable the debug menu in iCal (pre-10.8) +# Enable the debug menu in Calendar (formerly iCal, pre-10.8) defaults write com.apple.iCal IncludeDebugMenu -bool true # Use plain text mode for new TextEdit documents @@ -774,7 +843,7 @@ defaults write com.irradiatedsoftware.SizeUp ShowPrefsOnNextStart -bool false ############################################################################### # Install Sublime Text settings -cp -r init/Preferences.sublime-settings ~/Library/Application\ Support/Sublime\ Text*/Packages/User/Preferences.sublime-settings 2> /dev/null +cp -r "${HOME}/init/Preferences.sublime-settings" ~/Library/Application\ Support/Sublime\ Text*/Packages/User/Preferences.sublime-settings 2> /dev/null ############################################################################### # Transmission.app # @@ -852,10 +921,10 @@ defaults write com.divisiblebyzero.Spectacle UndoLastMove -data 62706c6973743030 # Kill affected applications # ############################################################################### -for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \ +for app in "Activity Monitor" "Calendar" "Contacts" "cfprefsd" \ "Dock" "Finder" "Google Chrome" "Google Chrome Canary" "Mail" "Messages" \ "Opera" "Safari" "SizeUp" "Spectacle" "SystemUIServer" \ - "Transmission" "Twitter" "iCal"; do + "Transmission" "Twitter"; do killall "${app}" > /dev/null 2>&1 done echo "Done. Note that some of these changes require a logout/restart of your OS to take effect. At a minimum, be sure to restart your Terminal."