Files
dotfiles/macos/defaults-interactive.sh
T
David F GliddenandClaude 0838f1cf8c Initial commit: Complete macOS dotfiles system
🖖 Features:
- Master 'engage' script for one-command setup
- 120+ CLI tools via Homebrew
- 40+ Applications (casks + MAS apps)
- Complete macOS system configuration
- Security hardening and privacy settings
- Obsidian knowledge vault setup
- Comprehensive backup strategies
- Automated symlink management

Live long and prosper\! 🚀

🤖 Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-27 13:17:01 +02:00

195 lines
5.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Interactive macOS defaults setter
# Choose which categories to apply
set -euo pipefail
# Colors
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m'
echo -e "${BLUE}macOS Defaults Configuration${NC}"
echo "=============================="
echo "Select which settings to apply:"
echo ""
# Ask for sudo upfront
sudo -v
# Function to ask yes/no
ask() {
while true; do
read -p "$1 (y/n) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
return 0
elif [[ $REPLY =~ ^[Nn]$ ]]; then
return 1
fi
done
}
# General UI/UX
if ask "Apply General UI/UX settings?"; then
echo -e "${YELLOW}Applying General UI/UX settings...${NC}"
# Expand save/print panels by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
# Save to disk by default
defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false
# Disable auto-correct and substitutions
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
echo -e "${GREEN}✓ General UI/UX settings applied${NC}"
fi
# Keyboard & Input
if ask "Apply Keyboard settings?"; then
echo -e "${YELLOW}Applying Keyboard settings...${NC}"
# Enable full keyboard access
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
# Fast key repeat
defaults write NSGlobalDomain KeyRepeat -int 2
defaults write NSGlobalDomain InitialKeyRepeat -int 15
# Disable press-and-hold
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
echo -e "${GREEN}✓ Keyboard settings applied${NC}"
fi
# Finder
if ask "Apply Finder settings?"; then
echo -e "${YELLOW}Applying Finder settings...${NC}"
# Show extensions, status bar, path bar
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
defaults write com.apple.finder ShowStatusBar -bool true
defaults write com.apple.finder ShowPathbar -bool true
# Keep folders on top
defaults write com.apple.finder _FXSortFoldersFirst -bool true
# Search current folder by default
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
# Disable extension change warning
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
# Show Library folder
chflags nohidden ~/Library
echo -e "${GREEN}✓ Finder settings applied${NC}"
fi
# Dock
if ask "Apply Dock settings?"; then
echo -e "${YELLOW}Which Dock position?${NC}"
echo "1) Left"
echo "2) Bottom"
echo "3) Right"
read -p "Choice (1-3): " -n 1 -r
echo
case $REPLY in
1) position="left";;
2) position="bottom";;
3) position="right";;
*) position="right";;
esac
defaults write com.apple.dock orientation -string "$position"
# Other Dock settings
defaults write com.apple.dock tilesize -int 48
defaults write com.apple.dock minimize-to-application -bool true
defaults write com.apple.dock show-process-indicators -bool true
defaults write com.apple.dock launchanim -bool false
defaults write com.apple.dock autohide -bool true
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock show-recents -bool false
echo -e "${GREEN}✓ Dock settings applied${NC}"
fi
# Security
if ask "Apply Security settings?"; then
echo -e "${YELLOW}Applying Security settings...${NC}"
# Require password immediately after sleep
defaults write com.apple.screensaver askForPassword -int 1
defaults write com.apple.screensaver askForPasswordDelay -int 0
echo -e "${GREEN}✓ Security settings applied${NC}"
fi
# Screenshots
if ask "Apply Screenshot settings?"; then
echo -e "${YELLOW}Where should screenshots be saved?${NC}"
echo "1) Desktop (default)"
echo "2) Pictures/Screenshots"
echo "3) Downloads"
read -p "Choice (1-3): " -n 1 -r
echo
case $REPLY in
2)
mkdir -p ~/Pictures/Screenshots
location="$HOME/Pictures/Screenshots"
;;
3)
location="$HOME/Downloads"
;;
*)
location="$HOME/Desktop"
;;
esac
defaults write com.apple.screencapture location -string "$location"
defaults write com.apple.screencapture type -string "png"
defaults write com.apple.screencapture disable-shadow -bool true
echo -e "${GREEN}✓ Screenshot settings applied${NC}"
fi
# Development Tools
if ask "Apply Development settings (Safari, Terminal)?"; then
echo -e "${YELLOW}Applying Development settings...${NC}"
# Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
# Terminal
defaults write com.apple.terminal StringEncodings -array 4
defaults write com.apple.terminal SecureKeyboardEntry -bool true
echo -e "${GREEN}✓ Development settings applied${NC}"
fi
# Restart affected apps
if ask "Restart affected applications?"; then
echo -e "${YELLOW}Restarting applications...${NC}"
for app in "Dock" "Finder" "SystemUIServer"; do
killall "${app}" &> /dev/null || true
done
echo -e "${GREEN}✓ Applications restarted${NC}"
fi
echo ""
echo -e "${GREEN}Configuration complete!${NC}"
echo "Some changes may require logging out or restarting."