#!/bin/bash
# First Install — macOS setup
# Review these commands before running them in Terminal.
set -e
if [ "$(uname -s)" != "Darwin" ]; then echo "This script requires macOS." >&2; exit 1; fi

# Install Homebrew if needed
if ! command -v brew >/dev/null 2>&1; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi

if ! command -v brew >/dev/null 2>&1; then
  if [ -x /opt/homebrew/bin/brew ]; then eval "$(/opt/homebrew/bin/brew shellenv)";
  elif [ -x /usr/local/bin/brew ]; then eval "$(/usr/local/bin/brew shellenv)"; fi
fi
command -v brew >/dev/null 2>&1 || { echo "Install Homebrew from https://brew.sh, then run this script again." >&2; exit 1; }

# Raycast
brew install --cask raycast

# 1Password
brew install --cask 1password

# BetterDisplay
brew install --cask betterdisplay

# CleanShot X
brew install --cask cleanshot

# Optional settings — may restart apps or require administrator access

# Auto-hide Dock
defaults write com.apple.dock autohide -bool true && killall Dock

# Show File Extensions in Finder
defaults write NSGlobalDomain AppleShowAllExtensions -bool true && killall Finder

# Tap to Click on Trackpad
defaults write com.apple.AppleMultitouchTrackpad Clicking -bool true && defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true

# Show Hidden Files
defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder

# Speed Up Key Repeat Rate
defaults write NSGlobalDomain KeyRepeat -int 2 && defaults write NSGlobalDomain InitialKeyRepeat -int 15

echo "Setup commands completed."
