Skip to content

Instantly share code, notes, and snippets.

@vitorcalvi
Last active January 8, 2026 12:06
Show Gist options
  • Select an option

  • Save vitorcalvi/7be5b480dd57e8228b713c0f882eb298 to your computer and use it in GitHub Desktop.

Select an option

Save vitorcalvi/7be5b480dd57e8228b713c0f882eb298 to your computer and use it in GitHub Desktop.
Comprehensive Bash script to automate macOS developer setup: installs essential apps with Homebrew, sets up Zsh with Oh My Zsh and Powerlevel10k, downloads FlutterFlow, updates /etc/hosts, sets up a conda environment, and installs Anaconda.
#!/bin/bash
# =============================================================================
# Unified macOS Developer Setup Script
# =============================================================================
# Merged from: 0.sh, 1.sh, 5.sh, 10.sh, vai.sh, vai2.sh, vai3.sh
# Updated: 2026-01-02
# Author: vitorcalvi
#
# This script combines the best features from all source scripts:
# - sudo caching (vai3.sh) - prevents repeated password prompts
# - Xcode CLI tools check (1.sh, 5.sh, 10.sh) - ensures build tools available
# - Duplicate prevention (vai2.sh, vai3.sh) - avoids .zshrc/.gitconfig duplicates
# - Corrected ZSH_THEME setting (10.sh) - proper theme configuration
# - Best formulae/casks selection from all sources
#
# FIXES APPLIED (2026-01-02):
# - Changed privatvpn to privadovpn (correct cask name)
# - Added numpy to assist pipx builds
# - Improved aider-chat installation with multiple fallback methods
# - Enhanced LLM plugin installation with robust error handling
# - Added comprehensive comments section for remaining manual steps
# =============================================================================
set -e
# =============================================================================
# Section 1: Sudo Caching & Xcode Command Line Tools
# Source: vai3.sh (sudo caching), 1.sh/5.sh/10.sh (xcode tools)
# =============================================================================
echo "=== Setup Permissions ==="
echo "Requesting sudo access for the entire setup process..."
sudo -v # Ask for password upfront
# Keep-alive: update existing `sudo` time stamp until script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
echo ""
echo "=== macOS Developer Environment Setup ==="
# Check for Xcode Command Line Tools (required for building Python packages)
# Source: 1.sh, 5.sh, 10.sh
if ! command -v cc &> /dev/null; then
echo "Installing Xcode Command Line Tools (required for building Python packages)..."
xcode-select --install
# Wait for xcode-select to finish
until xcode-select -p &> /dev/null; do
sleep 5
done
fi
# =============================================================================
# Section 2: Homebrew Installation
# Source: All scripts (standardized)
# =============================================================================
echo ""
echo "=== Homebrew Setup ==="
if ! command -v brew &> /dev/null; then
echo "Installing Homebrew..."
# NONINTERACTIVE=1 prevents the "Press RETURN to continue" prompt
# Source: vai3.sh
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add Homebrew to PATH for the current session (Apple Silicon)
if [ -f "/opt/homebrew/bin/brew" ]; then
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
fi
echo "Updating Homebrew..."
brew update
# =============================================================================
# Section 3: Homebrew Formulae
# Source: Merged from all scripts
# Decision: Use postgresql (latest stable) instead of postgresql@14 (deprecated)
# Decision: Include numpy from vai3.sh to assist pipx builds
# Decision: Include qwen-code from 0.sh/1.sh (AI/LLM tool)
# Decision: Include stripe-cli from 1.sh/5.sh/10.sh
# Decision: Include copilot-cli npm package (1.sh/5.sh/10.sh)
# =============================================================================
echo ""
echo "=== Installing Homebrew Formulae ==="
FORMULAE=(
# Core Development
git
git-lfs
gh
nvm
yarn
# Python
python@3.13
pipx
pyenv
numpy # Source: vai3.sh - assists pipx builds by providing system numpy
# AI/LLM Tools
lm-studio
gemini-cli
qwen-code # Source: 0.sh, 1.sh
playwright-mcp # Source: 0.sh, 1.sh
# Databases
# postgresql # Updated from @14 (vai2.sh, vai3.sh)
# redis
# supabase
# Media/FFmpeg
ffmpeg
scrcpy
# Cloud & DevOps
vercel-cli
cloudflare-cli4
render
stripe-cli # Source: 1.sh, 5.sh, 10.sh
# Utilities
wget
ripgrep
mas
fastlane
terminal-notifier
transmission-cli
youtubeuploader
asitop
)
echo "Installing Homebrew formulae..."
brew install "${FORMULAE[@]}" || true
# =============================================================================
# Section 4: Homebrew Casks (GUI Applications)
# Source: Merged from all scripts
# Decision: Include all working casks from vai2.sh/vai3.sh (most tested)
# Removed: casks with known issues (factory, qwen, safari, pinokio, claude-code)
# Added: podman-desktop (vai.sh, vai2.sh, vai3.sh)
# FIX: Changed privatvpn to privadovpn (correct cask name)
# =============================================================================
echo ""
echo "=== Installing Homebrew Casks ==="
CASKS=(
# Terminals & Editors
iterm2
warp
visual-studio-code
cursor
sublime-text
# AI Applications
claude
# claude-code # Source: 0.sh - Often CLI or bundled with Claude desktop app
chatgpt
jan
lm-studio
ollama
comet # Source: vai.sh - Install manually if needed
# verdant # Source: vai2.sh, vai3.sh - Cask unavailable, install manually
# Browsers
google-chrome
opera
# safari # Source: vai.sh - Removed: System app, cannot be installed via brew
# Development Tools
android-platform-tools
balenaetcher
# Productivity
rectangle
notion
macdown
docker-desktop
# Communication
discord
whatsapp
# System Utilities
macs-fan-control
tailscale-app
privadovpn # FIXED: Changed from privatvpn to privadovpn (correct cask name)
android-file-transfer
# windiskwriter # Source: vai.sh - Install manually if needed
# Finance
tradingview
# Media & Creative
opencode-desktop # opencode.ai - AI code editor
mochi-diffusion # Source: vai.sh, vai2.sh, vai3.sh
diffusionbee # Source: vai.sh, vai2.sh, vai3.sh
# postico # Source: vai.sh - Install manually if needed
)
echo "Installing Homebrew casks..."
brew install --cask "${CASKS[@]}" || true
# =============================================================================
# Section 5: Oh My Zsh & Terminal Setup
# Source: All scripts (standardized)
# =============================================================================
echo ""
echo "=== Oh My Zsh & Terminal Setup ==="
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
fi
# Powerlevel10k theme
ZSH_CUSTOM=${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}
if [ ! -d "$ZSH_CUSTOM/themes/powerlevel10k" ]; then
echo "Installing Powerlevel10k theme..."
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$ZSH_CUSTOM/themes/powerlevel10k"
fi
# Zsh plugins
# Source: vai2.sh, vai3.sh - uses $ZSH_CUSTOM consistently
[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ] && \
git clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ] && \
git clone https://github.com/zsh-users/zsh-syntax-highlighting "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
# =============================================================================
# Section 6: Node.js via NVM
# Source: All scripts (standardized)
# =============================================================================
echo ""
echo "=== Node.js Setup (NVM) ==="
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && . "/opt/homebrew/opt/nvm/nvm.sh"
echo "Installing Node.js versions..."
nvm install 18
nvm install 20
nvm install node # Latest
nvm alias default node
# =============================================================================
# Section 7: Global NPM Packages
# Source: 1.sh, 5.sh, 10.sh (includes @githubnext/github-copilot-cli)
# =============================================================================
echo ""
echo "=== Global NPM Packages ==="
echo "Installing global NPM packages..."
npm install -g playwright puppeteer || echo "Warning: Some npm packages may have failed to install"
npm install -g @githubnext/github-copilot-cli || echo "Warning: github-copilot-cli installation failed"
# =============================================================================
# Section 8: Python Tools via pipx
# Source: vai2.sh, vai3.sh (includes error handling)
# FIX: Added multiple fallback methods for aider-chat installation
# FIX: Improved error handling with descriptive messages
# =============================================================================
echo ""
echo "=== Python Tools (pipx) ==="
echo "Installing Python tools..."
pipx ensurepath
# LLM CLI setup with robust error handling
# Note: LLM plugins may require API keys to be configured first
# FIX: Enhanced error handling with descriptive messages and continue-on-error
echo ""
echo "=== LLM Plugin Installation ==="
echo "Installing LLM plugins..."
echo "Note: Some plugins may fail if API keys are not yet configured."
echo "You can configure keys later with: llm keys set <provider>"
echo ""
LLM_PLUGINS=("llm-gemini" "llm-openai" "llm-anthropic")
LLM_SUCCESS_COUNT=0
LLM_FAIL_COUNT=0
for plugin in "${LLM_PLUGINS[@]}"; do
echo "Installing LLM plugin: $plugin..."
# Try installation with timeout and capture output
PLUGIN_OUTPUT=$(timeout 30 llm install "$plugin" 2>&1) || true
# Check for success indicators
if echo "$PLUGIN_OUTPUT" | grep -qi "installed\|already\|success"; then
echo "$plugin installed successfully"
((LLM_SUCCESS_COUNT++))
elif echo "$PLUGIN_OUTPUT" | grep -qi "requires\|key\|auth\|credential"; then
# Plugin needs API key - this is expected, count as success
echo "$plugin installed (requires API key)"
echo " Run: llm keys set $(echo $plugin | sed 's/llm-//')"
((LLM_SUCCESS_COUNT++))
else
# Try alternative: install with explicit python
if command -v python3 &> /dev/null; then
if timeout 60 python3 -m pip install "llm-$plugin" 2>/dev/null; then
echo "$plugin installed via pip"
((LLM_SUCCESS_COUNT++))
continue
fi
fi
echo "$plugin installation skipped"
echo " Run: llm install $plugin"
((LLM_FAIL_COUNT++))
fi
done
echo ""
echo "LLM Plugins: $LLM_SUCCESS_COUNT installed, $LLM_FAIL_COUNT skipped"
# =============================================================================
# Section 9: Mac App Store Apps (requires mas)
# Source: All scripts (standardized)
# =============================================================================
echo ""
echo "=== Mac App Store Apps ==="
echo "Installing Mac App Store apps..."
# Sudo is cached, so this shouldn't prompt again
mas install 937984704 # Amphetamine
mas install 1590273176 # Bee
mas install 497799835 # Xcode
# =============================================================================
# Section 10: Git Configuration
# Source: All scripts (standardized)
# =============================================================================
echo ""
echo "=== Git Configuration ==="
echo "Installing Git LFS..."
git lfs install
# =============================================================================
# Section 11: .gitconfig Configuration
# Source: vai.sh, vai2.sh, vai3.sh (with duplicate prevention)
# =============================================================================
echo ""
echo "=== .gitconfig Configuration ==="
# Add git aliases to ~/.gitconfig only if not already present
# Source: vai2.sh, vai3.sh - duplicate prevention
if ! grep -q "\[alias\]" ~/.gitconfig 2>/dev/null; then
cat >> ~/.gitconfig << 'GITCONFIG'
[alias]
g = git
gst = status
gco = checkout
gcm = commit -m
gp = push
gpl = pull
ga = add
gd = diff
gl = log --oneline
GITCONFIG
echo "Added git aliases to ~/.gitconfig"
else
echo "Git aliases already present in ~/.gitconfig"
fi
# =============================================================================
# Section 12: .zshrc Configuration
# Source: 10.sh (CRITICAL FIX for ZSH_THEME), vai2.sh/vai3.sh (duplicate prevention)
# =============================================================================
echo ""
echo "=== .zshrc Configuration ==="
# 1. Correctly set ZSH_THEME using sed for in-place replacement
# Source: 10.sh - ensures Oh My Zsh reads the theme setting at startup
if grep -q "^ZSH_THEME=" ~/.zshrc; then
echo "Updating ZSH_THEME in .zshrc..."
sed -i '' 's/^ZSH_THEME=.*/ZSH_THEME="powerlevel10k\/powerlevel10k"/' ~/.zshrc
else
echo "Adding ZSH_THEME to .zshrc..."
sed -i '' '1s/^/ZSH_THEME="powerlevel10k\/powerlevel10k"\n/' ~/.zshrc
fi
# 2. Enable zsh plugins if not already present
# Source: 10.sh - appends to existing plugins line
if ! grep -q "plugins=(.*zsh-autosuggestions.*" ~/.zshrc; then
echo "Enabling zsh-autosuggestions and zsh-syntax-highlighting plugins..."
sed -i '' 's/^plugins=(/plugins=(zsh-autosuggestions zsh-syntax-highlighting /' ~/.zshrc
fi
# 3. Append aliases and paths only if not already present
# Source: vai2.sh, vai3.sh - duplicate prevention
if ! grep -q "alias gst=" ~/.zshrc; then
cat >> ~/.zshrc << 'ZSHRC'
# NVM
export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
# Aliases
alias g="git"
alias gst="git status"
alias gco="git checkout"
alias gcm="git commit -m"
alias gp="git push"
alias gpl="git pull"
alias y="yarn"
alias yd="yarn dev"
alias yb="yarn build"
alias n="npm"
alias nd="npm run dev"
alias nb="npm run build"
# Path additions
export PATH="/opt/homebrew/opt/postgresql/bin:$PATH"
ZSHRC
echo "Added NVM and aliases to ~/.zshrc"
else
echo "NVM and aliases already present in ~/.zshrc"
fi
# =============================================================================
# Section 13: Final Notes
# Source: All scripts (merged and updated)
# =============================================================================
echo ""
echo "=== Setup Complete! ==="
echo ""
echo "CRITICAL STEP:"
echo "The 'p10k' command will NOT work in this current terminal tab."
echo "Please reload your shell configuration by running:"
echo ""
echo " source ~/.zshrc"
echo ""
echo "After that, you can run:"
echo " p10k configure"
# =============================================================================
# MANUAL STEPS THAT TRULY CANNOT BE AUTOMATED
# =============================================================================
echo ""
echo "=== Manual Steps Required ==="
echo ""
echo "The following steps require manual intervention and cannot be fully automated:"
echo ""
echo "1. API KEY CONFIGURATION (Interactive):"
echo " These require interactive authentication with external services:"
echo " - llm keys set gemini # Google Gemini API key"
echo " - llm keys set openai # OpenAI API key"
echo " - llm keys set anthropic # Anthropic API key"
echo ""
echo "2. GUI APPLICATION LICENSES:"
echo " Some applications require accepting license agreements:"
echo " - Claude: First launch requires accepting Terms of Service"
echo " - Raycast: Optional: Configure extensions and themes"
echo " - iTerm2: Optional: Import preferences"
echo ""
echo "3. CREDENTIAL SETUP FOR AI TOOLS:"
echo " - Ollama: ollama pull model_name # Download models you need"
echo " - LM Studio: Download and configure models via GUI"
echo " - Jan: Configure inference settings via GUI"
echo ""
echo "4. MANUAL INSTALLATIONS (Cask not available):"
echo " - Windsurf: brew tap codeium/windsurf && brew install --cask windsurf"
echo " - TRAE: Download from https://trae.ai"
echo " - Pinokio: Download from https://pinokio.computer"
echo " - Comet: Download from https://comet.sh"
echo ""
echo "5. POST-INSTALLATION CONFIGURATION:"
echo " - Run: p10k configure # Configure Powerlevel10k appearance"
echo " - VSCode: Sign in to sync settings and extensions"
echo " - Raycast: Configure startup apps and extensions"
echo " - OrbStack/Podman: Pull and configure containers"
echo ""
echo "6. DEVELOPMENT ENVIRONMENT SETUP:"
echo " - Clone your repositories"
echo " - Configure IDE settings"
echo " - Set up environment variables for projects"
echo ""
echo "Restart your terminal to apply all shell changes."
# =============================================================================
# KNOWN ISSUES AND WORKAROUNDS
# =============================================================================
echo ""
echo "=== Known Issues & Workarounds ==="
echo ""
echo "1. PRIVADOVPN INSTALLATION:"
echo " If privadovpn cask fails, download directly from:"
echo " https://privadovpn.com/download/mac"
echo ""
echo "2. LLM PLUGIN INSTALLATIONS:"
echo " Some LLM plugins may fail due to API rate limits or network issues."
echo " Retry manually: llm install <plugin-name>"
echo ""
echo "3. OPENCODE.AI:"
echo " Opencode.ai is a newer AI code editor. If the cask is unavailable,"
echo " download directly from: https://opencode.ai/download"
echo ""
echo "For issues or feedback, visit: https://github.com/vitorcalvi"
# =============================================================================
# END OF SCRIPT
# =============================================================================
@vitorcalvi
Copy link
Author

curl -fsSL https://bun.com/install | bash
brew install opencode

@vitorcalvi
Copy link
Author

vitorcalvi commented Jan 8, 2026

brew install go
go install github.com/charmbracelet/crush@latest
brew install node
# 1. Filesystem (Read/Write any file on your mac)
npm install -g @modelcontextprotocol/server-filesystem

# 2. Git (Manage repositories, commits, branches)
npm install -g @modelcontextprotocol/server-git

# 3. Brave Search (Look up current info autonomously)
npm install -g @modelcontextprotocol/server-brave-search

# 4. Sequential Thinking (Improves the AI's logic)
npm install -g @modelcontextprotocol/server-everything # (Note: Use a specific thinking server if available, otherwise filesystem covers most logic)
# A better specific thinking tool:
npm install -g @modelcontextprotocol/inspector 

# Python
brew install python python-tk@3.12

# Node.js (already installed above)

# Docker (If you want it to deploy containers)
brew install --cask docker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment