118 lines
4.6 KiB
Bash
Executable File
118 lines
4.6 KiB
Bash
Executable File
#!/bin/zsh
|
|
|
|
echo "Configuring macOS System Settings (you may be asked to enter password)"
|
|
|
|
# Enable and configure firewall
|
|
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on
|
|
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on
|
|
|
|
# Set DNS servers
|
|
networksetup -setdnsservers Ethernet 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
|
|
networksetup -setdnsservers Wi-Fi 1.1.1.1 1.0.0.1 2606:4700:4700::1111 2606:4700:4700::1001
|
|
|
|
# Disable Handoff
|
|
defaults -currentHost write com.apple.coreservices.useractivityd ActivityAdvertisingAllowed -bool no
|
|
defaults -currentHost write com.apple.coreservices.useractivityd ActivityReceivingAllowed -bool no
|
|
|
|
# Configure the Dock
|
|
# Disable "Show recent applications in Dock"
|
|
defaults write com.apple.dock "show-recents" -bool FALSE
|
|
# Set "Minimise windows using" to "Scale Effect"
|
|
defaults write com.apple.dock mineffect scale
|
|
# Enable "Minimise windows into application icon"
|
|
defaults write com.apple.dock "minimize-to-application" -bool TRUE
|
|
|
|
# Set numbers of rows and columns in Launchpad
|
|
defaults write com.apple.dock springboard-columns -int 6;
|
|
defaults write com.apple.dock springboard-rows -int 6;
|
|
|
|
# Increase mouse speed beyond available options in System Settings
|
|
echo "Increase mouse speed"
|
|
defaults write -g com.apple.mouse.scaling 10
|
|
|
|
# Configure Finder
|
|
echo "Configuring Finder"
|
|
# Set list view as default
|
|
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
|
|
# Show the path and status bars (TODO: setting for tabs bar)
|
|
defaults write com.apple.finder ShowPathbar -bool true
|
|
defaults write com.apple.finder ShowStatusBar -bool true
|
|
# Sort files so directories appear above files
|
|
defaults write com.apple.finder _FXSortFoldersFirst -bool true
|
|
# Set the default search scope to be the current folder
|
|
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
|
|
# Set default location for Finder to the home directory
|
|
defaults write com.apple.finder "NewWindowTarget" -string "PfHm"
|
|
defaults write com.apple.finder "NewWindowTargetPath" -string "file://${HOME}/"
|
|
|
|
# Create location for saving screenshots and set it as the default
|
|
# Also remove shadow effect macOS adds to window screenshots
|
|
echo "- Screenshots saved to ~/Pictures/Screenshots with shadow effects disabled"
|
|
mkdir -p ~/Pictures/Screenshots
|
|
defaults write com.apple.screencapture location -string "${HOME}/Pictures/Screenshots"
|
|
defaults write com.apple.screencapture disable-shadow -bool true
|
|
# Avoid creating .DS_Store files on network or USB volumes
|
|
# ToDo - Check if this actually works
|
|
echo "- Avoid creating .DS_Store files on external volumes"
|
|
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
|
|
defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true
|
|
|
|
# Check if Xcode CLI Tools are installed, install them if not
|
|
if [[ $(xcode-select -p) == "" ]]; then
|
|
xcode-select --install
|
|
else
|
|
echo "Xcode CLI Tools are already installed"
|
|
fi
|
|
|
|
# Set git to save any credentials in the macOS Keychain
|
|
git config --global credential.helper osxkeychain
|
|
|
|
# Check if Homebrew is present, update if installed, run the install script if not
|
|
if [[ $(command -v brew) == "" ]]; then
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
else
|
|
echo "Homebrew is already installed, running brew update"
|
|
brew update
|
|
fi
|
|
|
|
# Run Homebrew bundle with specified file
|
|
brew bundle --file Brewfile
|
|
# Run bash script to reconfigure Dock
|
|
./Dock.sh
|
|
|
|
# Function to open up Terminal using the downloaded theme
|
|
setCustomTerminalTheme(){
|
|
cp Custom.terminal ~/Downloads/Custom.terminal
|
|
osascript <<EOD
|
|
tell application "Terminal"
|
|
activate
|
|
set TerminalThemeFile to (POSIX path of ((path to home folder) as text) & "/Downloads/Custom.terminal")
|
|
open TerminalThemeFile
|
|
delay 1
|
|
end tell
|
|
EOD
|
|
defaults write com.apple.Terminal "Startup Window Settings" -string "Custom"
|
|
defaults write com.apple.Terminal "Default Window Settings" -string "Custom"
|
|
rm ~/Downloads/Custom.terminal
|
|
}
|
|
|
|
# Check if custom Terminal theme is already set and set up if not
|
|
if [[ $(defaults read com.apple.Terminal "Startup Window Settings") != "Custom" ]]; then
|
|
setCustomTerminalTheme
|
|
echo "Custom Terminal theme is now the default"
|
|
else
|
|
echo "Custom Terminal theme is already set as default"
|
|
fi
|
|
|
|
#Download and load ZSH profile
|
|
curl -o ~/.zshrc "https://git.ptmlab.co.uk/ptmlab/dotfiles/raw/branch/main/macos-zshrc"
|
|
source ~/.zshrc
|
|
|
|
#Copy Notification preferences file into Library
|
|
rsync -ax com.apple.ncprefs.plist ~/Library/Preferences/com.apple.ncprefs.plist
|
|
|
|
#Import mobileconfig
|
|
open *.mobileconfig
|
|
|
|
# Prompt user to reboot
|
|
echo "Setup complete, please reboot." |