Last active
May 12, 2026 06:50
-
-
Save nickleefly/d1cc8d55fe1a0aa8da7453bb91478f80 to your computer and use it in GitHub Desktop.
setup_macos_zsh_claude.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # ============================================================================= | |
| # macOS Setup Script: Zsh + Homebrew + Node.js + Claude Code CLI | |
| # ============================================================================= | |
| # This script will: | |
| # 1. Install Xcode Command Line Tools (if missing) | |
| # 2. Install zsh (if not present) and set it as the default shell | |
| # 3. Install Oh-My-Zsh for a better zsh experience | |
| # 4. Install Homebrew (if not present) | |
| # 5. Install Node.js via Homebrew | |
| # 6. Install @anthropic-ai/claude-code globally via npm | |
| # 7. Configure Claude Code with DeepSeek API (interactive) | |
| # ============================================================================= | |
| set -e # Exit immediately if a command exits with a non-zero status | |
| # Colors for output | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| CYAN='\033[0;36m' | |
| NC='\033[0m' # No Color | |
| # Global variables | |
| DEEPSEEK_API_KEY="" | |
| SKIP_API_PROMPT=false | |
| SKIP_SHELL_CHANGE=false | |
| INSTALL_PLUGINS=true | |
| AUTO_SOURCE=true | |
| # Helper functions | |
| print_header() { | |
| echo "" | |
| echo "${BLUE}═══════════════════════════════════════════════════════════════${NC}" | |
| echo "${BLUE} $1${NC}" | |
| echo "${BLUE}═══════════════════════════════════════════════════════════════${NC}" | |
| } | |
| print_success() { | |
| echo "${GREEN}✓ $1${NC}" | |
| } | |
| print_warning() { | |
| echo "${YELLOW}⚠ $1${NC}" | |
| } | |
| print_error() { | |
| echo "${RED}✗ $1${NC}" | |
| } | |
| print_info() { | |
| echo "${BLUE}ℹ $1${NC}" | |
| } | |
| print_question() { | |
| echo -n "${CYAN}? $1${NC} " | |
| } | |
| confirm_action() { | |
| local prompt="$1" | |
| local default="${2:-y}" | |
| if [[ "$default" == "y" ]]; then | |
| print_question "$prompt [Y/n]: " | |
| else | |
| print_question "$prompt [y/N]: " | |
| fi | |
| read -r response | |
| response=${response:-$default} | |
| if [[ "$response" =~ ^[Yy]$ ]]; then | |
| return 0 | |
| else | |
| return 1 | |
| fi | |
| } | |
| # ============================================================================= | |
| # Check and Install Xcode Command Line Tools | |
| # ============================================================================= | |
| check_xcode_clt() { | |
| print_header "Checking Xcode Command Line Tools" | |
| if xcode-select -p &> /dev/null; then | |
| print_success "Xcode Command Line Tools are already installed" | |
| return 0 | |
| else | |
| print_warning "Xcode Command Line Tools not found" | |
| echo "" | |
| echo "These tools are required for:" | |
| echo " • Git (needed for Oh-My-Zsh and plugins)" | |
| echo " • Homebrew package manager" | |
| echo " • Compiling native Node.js modules" | |
| echo "" | |
| if confirm_action "Install Xcode Command Line Tools now?" "y"; then | |
| print_info "Installing Xcode Command Line Tools..." | |
| print_info "A popup window will appear. Please click 'Install' to continue." | |
| echo "" | |
| # Trigger the installation | |
| xcode-select --install | |
| # Wait for installation to complete | |
| print_info "Waiting for installation to complete..." | |
| print_info "Press Enter when installation is finished" | |
| read -r | |
| # Verify installation | |
| if xcode-select -p &> /dev/null; then | |
| print_success "Xcode Command Line Tools installed successfully" | |
| return 0 | |
| else | |
| print_error "Xcode Command Line Tools installation failed or not completed" | |
| print_warning "You can install them manually by running: xcode-select --install" | |
| if confirm_action "Continue without Xcode Command Line Tools? (some features may fail)" "n"; then | |
| print_warning "Continuing without Xcode CLT - some installations may fail" | |
| return 0 | |
| else | |
| print_info "Exiting. Please install Xcode Command Line Tools and run the script again." | |
| exit 1 | |
| fi | |
| fi | |
| else | |
| print_warning "Skipping Xcode Command Line Tools installation" | |
| if confirm_action "Continue anyway? (git, Homebrew, and some packages may fail)" "n"; then | |
| print_warning "Continuing without Xcode CLT - proceed with caution" | |
| return 0 | |
| else | |
| print_info "Exiting. Please install Xcode Command Line Tools and run the script again." | |
| exit 0 | |
| fi | |
| fi | |
| fi | |
| } | |
| # ============================================================================= | |
| # Source ZSH RC | |
| # ============================================================================= | |
| source_zshrc() { | |
| print_header "Applying Configuration" | |
| if [[ "$AUTO_SOURCE" == true ]]; then | |
| print_info "Sourcing ~/.zshrc to apply changes..." | |
| if [[ -f "$HOME/.zshrc" ]]; then | |
| # Source in the current shell | |
| if [[ -n "$ZSH_VERSION" ]]; then | |
| # We're in zsh | |
| source "$HOME/.zshrc" | |
| print_success "Configuration applied to current zsh session" | |
| else | |
| # We're in bash or another shell | |
| print_warning "Current shell is not zsh" | |
| print_info "Attempting to source with zsh..." | |
| if command -v zsh &> /dev/null; then | |
| # Source using zsh | |
| zsh -c "source $HOME/.zshrc && echo 'Configuration verified with zsh'" | |
| print_success "Configuration verified with zsh" | |
| print_warning "Changes will be fully applied when you start a zsh session" | |
| else | |
| print_warning "Cannot source ~/.zshrc - zsh not found" | |
| fi | |
| fi | |
| # Export PATH for the current session | |
| if [[ -d "$HOME/.npm-global/bin" ]]; then | |
| export PATH="$HOME/.npm-global/bin:$PATH" | |
| print_info "Added npm global bin to PATH for this session" | |
| fi | |
| if [[ $(uname -m) == "arm64" && -f "/opt/homebrew/bin/brew" ]]; then | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| print_info "Added Homebrew to PATH for this session" | |
| fi | |
| else | |
| print_warning "~/.zshrc not found, cannot source" | |
| fi | |
| else | |
| print_info "Auto-sourcing disabled - please run 'source ~/.zshrc' manually" | |
| fi | |
| } | |
| # ============================================================================= | |
| # Interactive Configuration | |
| # ============================================================================= | |
| print_header "Interactive Setup Configuration" | |
| echo "" | |
| echo "Welcome to the macOS Development Environment Setup!" | |
| echo "This script will install and configure:" | |
| echo " • Xcode Command Line Tools (if missing)" | |
| echo " • Zsh + Oh-My-Zsh" | |
| echo " • Homebrew" | |
| echo " • Node.js" | |
| echo " • Claude Code CLI (with DeepSeek API support)" | |
| echo "" | |
| # Ask for API key | |
| if [[ -z "$DEEPSEEK_API_KEY" && "$SKIP_API_PROMPT" != true ]]; then | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "${CYAN}DeepSeek API Configuration${NC}" | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "" | |
| echo "To use Claude Code CLI with DeepSeek, you'll need your DeepSeek API key." | |
| echo "You can get your API key from: ${GREEN}https://platform.deepseek.com/api_keys${NC}" | |
| echo "" | |
| if confirm_action "Do you have a DeepSeek API key?" "y"; then | |
| print_question "Please paste your DeepSeek API key: " | |
| read -r DEEPSEEK_API_KEY | |
| while [[ -z "$DEEPSEEK_API_KEY" ]]; do | |
| print_error "API key cannot be empty" | |
| print_question "Please paste your DeepSeek API key: " | |
| read -r DEEPSEEK_API_KEY | |
| done | |
| print_success "API key saved (will be configured in settings)" | |
| else | |
| print_warning "You can add the API key later by editing ~/.claude/settings.json" | |
| print_question "Would you like to continue without the API key? [Y/n]: " | |
| read -r continue_without_key | |
| if [[ ! "$continue_without_key" =~ ^[Yy]$ ]] && [[ -n "$continue_without_key" ]]; then | |
| print_info "Exiting. Please get your API key from https://platform.deepseek.com/api_keys and run the script again." | |
| exit 0 | |
| fi | |
| fi | |
| echo "" | |
| fi | |
| # Ask about plugins | |
| if [[ "$INSTALL_PLUGINS" == true ]]; then | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "${CYAN}Zsh Plugins Configuration${NC}" | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "" | |
| if confirm_action "Install zsh-autosuggestions and zsh-syntax-highlighting?" "y"; then | |
| INSTALL_PLUGINS=true | |
| print_success "Will install Zsh plugins" | |
| else | |
| INSTALL_PLUGINS=false | |
| print_info "Skipping Zsh plugins installation" | |
| fi | |
| echo "" | |
| fi | |
| # Ask about shell change | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "${CYAN}Shell Configuration${NC}" | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "" | |
| if confirm_action "Set Zsh as your default shell? (requires logout)" "y"; then | |
| SKIP_SHELL_CHANGE=false | |
| print_success "Will set Zsh as default shell" | |
| else | |
| SKIP_SHELL_CHANGE=true | |
| print_info "Will keep current default shell" | |
| fi | |
| echo "" | |
| # Ask about auto-sourcing | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "${CYAN}Configuration Application${NC}" | |
| echo "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}" | |
| echo "" | |
| if confirm_action "Automatically source ~/.zshrc after installation?" "y"; then | |
| AUTO_SOURCE=true | |
| print_success "Will attempt to apply configuration automatically" | |
| else | |
| AUTO_SOURCE=false | |
| print_info "You will need to run 'source ~/.zshrc' manually" | |
| fi | |
| echo "" | |
| # Final confirmation | |
| print_header "Ready to Install" | |
| echo "The following will be installed:" | |
| echo " • Xcode Command Line Tools (if missing)" | |
| echo " • Zsh shell" | |
| [[ "$SKIP_SHELL_CHANGE" != true ]] && echo " • Zsh will be set as default shell" | |
| echo " • Oh-My-Zsh framework" | |
| [[ "$INSTALL_PLUGINS" == true ]] && echo " • Zsh plugins (autosuggestions, syntax-highlighting)" | |
| echo " • Homebrew package manager" | |
| echo " • Node.js (latest)" | |
| echo " • Claude Code CLI" | |
| [[ -n "$DEEPSEEK_API_KEY" ]] && echo " • Claude Code with DeepSeek API (pre-configured)" | |
| [[ -z "$DEEPSEEK_API_KEY" ]] && echo " • Claude Code (API key will need to be added manually)" | |
| [[ "$AUTO_SOURCE" == true ]] && echo " • Will automatically apply configuration" | |
| echo "" | |
| if ! confirm_action "Proceed with installation?" "y"; then | |
| print_info "Installation cancelled by user" | |
| exit 0 | |
| fi | |
| # ============================================================================= | |
| # STEP 0: Check/Install Xcode Command Line Tools | |
| # ============================================================================= | |
| check_xcode_clt | |
| # ============================================================================= | |
| # STEP 1: Install and Configure Zsh | |
| # ============================================================================= | |
| print_header "STEP 1: Installing and Configuring Zsh" | |
| # Check if zsh is installed | |
| if ! command -v zsh &> /dev/null; then | |
| print_info "Zsh is not installed. Installing via Homebrew..." | |
| # First, we need to temporarily use bash to install Homebrew | |
| if ! command -v brew &> /dev/null; then | |
| print_info "Homebrew not found. Installing Homebrew first (needed for zsh)..." | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| # Add Homebrew to PATH for this session | |
| if [[ $(uname -m) == "arm64" ]]; then | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| else | |
| eval "$(/usr/local/bin/brew shellenv)" | |
| fi | |
| fi | |
| brew install zsh | |
| print_success "Zsh installed successfully" | |
| else | |
| print_success "Zsh is already installed ($(zsh --version))" | |
| fi | |
| # Check if zsh is the default shell | |
| if [[ "$SKIP_SHELL_CHANGE" != true ]]; then | |
| CURRENT_SHELL=$(dscl . -read ~/ UserShell | awk '{print $2}') | |
| ZSH_PATH=$(command -v zsh) | |
| if [[ "$CURRENT_SHELL" != "$ZSH_PATH" ]]; then | |
| print_info "Changing default shell from $CURRENT_SHELL to zsh..." | |
| # Add zsh to /etc/shells if not present | |
| if ! grep -q "$ZSH_PATH" /etc/shells; then | |
| print_info "Adding zsh to /etc/shells (requires sudo)..." | |
| echo "$ZSH_PATH" | sudo tee -a /etc/shells > /dev/null | |
| fi | |
| # Change default shell | |
| chsh -s "$ZSH_PATH" | |
| print_success "Default shell changed to zsh" | |
| print_warning "Please log out and log back in for the shell change to take full effect" | |
| else | |
| print_success "Zsh is already the default shell" | |
| fi | |
| else | |
| print_info "Skipping default shell change as requested" | |
| fi | |
| # ============================================================================= | |
| # STEP 2: Install Oh-My-Zsh | |
| # ============================================================================= | |
| print_header "STEP 2: Installing Oh-My-Zsh" | |
| if [[ ! -d "$HOME/.oh-my-zsh" ]]; then | |
| print_info "Installing Oh-My-Zsh..." | |
| sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended | |
| print_success "Oh-My-Zsh installed" | |
| else | |
| print_success "Oh-My-Zsh is already installed" | |
| fi | |
| # ============================================================================= | |
| # STEP 3: Configure Zsh with Useful Settings | |
| # ============================================================================= | |
| print_header "STEP 3: Configuring Zsh" | |
| ZSHRC="$HOME/.zshrc" | |
| # Backup existing .zshrc if it exists | |
| if [[ -f "$ZSHRC" ]]; then | |
| BACKUP_FILE="$ZSHRC.backup.$(date +%Y%m%d%H%M%S)" | |
| cp "$ZSHRC" "$BACKUP_FILE" | |
| print_success "Backed up existing .zshrc to $BACKUP_FILE" | |
| fi | |
| # Check if our config already exists to avoid duplication | |
| if ! grep -q "# Custom Configuration Added by Setup Script" "$ZSHRC" 2>/dev/null; then | |
| # Create/update .zshrc with useful configurations | |
| cat >> "$ZSHRC" << 'EOF' | |
| # ============================================================================= | |
| # Custom Configuration Added by Setup Script | |
| # ============================================================================= | |
| # Set PATH to include common directories | |
| export PATH="/usr/local/bin:/usr/local/sbin:$PATH" | |
| # Homebrew configuration for Apple Silicon Macs | |
| if [[ $(uname -m) == "arm64" ]]; then | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| fi | |
| # Node.js global packages path (if using npm global without sudo) | |
| export PATH="$HOME/.npm-global/bin:$PATH" | |
| # Useful aliases | |
| alias ll='ls -la' | |
| alias ..='cd ..' | |
| alias ...='cd ../..' | |
| alias update='brew update && brew upgrade' | |
| alias zshconfig='nano ~/.zshrc' | |
| alias reload='source ~/.zshrc' | |
| # Enable syntax highlighting (if installed) | |
| if [[ -f "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]]; then | |
| source "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" | |
| fi | |
| # Enable autosuggestions (if installed) | |
| if [[ -f "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" ]]; then | |
| source "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh" | |
| fi | |
| # Better history settings | |
| HISTSIZE=10000 | |
| SAVEHIST=10000 | |
| setopt SHARE_HISTORY | |
| setopt HIST_IGNORE_DUPS | |
| # ============================================================================= | |
| EOF | |
| print_success "Zsh configuration added" | |
| else | |
| print_success "Zsh configuration already present" | |
| fi | |
| # ============================================================================= | |
| # STEP 4: Install Useful Zsh Plugins (if selected) | |
| # ============================================================================= | |
| if [[ "$INSTALL_PLUGINS" == true ]]; then | |
| print_header "STEP 4: Installing Zsh Plugins" | |
| # Ensure git is available (should be from Xcode CLT) | |
| if ! command -v git &> /dev/null; then | |
| print_error "Git not found. Xcode Command Line Tools may not be installed properly." | |
| print_warning "Skipping plugin installation. You can install plugins manually later." | |
| else | |
| # zsh-autosuggestions | |
| if [[ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]]; then | |
| print_info "Installing zsh-autosuggestions..." | |
| git clone https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" | |
| print_success "zsh-autosuggestions installed" | |
| else | |
| print_success "zsh-autosuggestions already installed" | |
| fi | |
| # zsh-syntax-highlighting | |
| if [[ ! -d "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" ]]; then | |
| print_info "Installing zsh-syntax-highlighting..." | |
| git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting" | |
| print_success "zsh-syntax-highlighting installed" | |
| else | |
| print_success "zsh-syntax-highlighting already installed" | |
| fi | |
| # Update plugins list in .zshrc | |
| if ! grep -q "zsh-autosuggestions" "$ZSHRC"; then | |
| # Replace plugins line to include new plugins | |
| sed -i '' 's/plugins=(git)/plugins=(git zsh-autosuggestions zsh-syntax-highlighting)/' "$ZSHRC" 2>/dev/null || true | |
| print_success "Updated plugins in .zshrc" | |
| fi | |
| fi | |
| else | |
| print_header "STEP 4: Skipping Zsh Plugins" | |
| print_info "Zsh plugins installation skipped as requested" | |
| fi | |
| # ============================================================================= | |
| # STEP 5: Install Homebrew | |
| # ============================================================================= | |
| print_header "STEP 5: Installing Homebrew" | |
| if ! command -v brew &> /dev/null; then | |
| print_info "Installing Homebrew..." | |
| /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
| # Add Homebrew to PATH for this session | |
| if [[ $(uname -m) == "arm64" ]]; then | |
| eval "$(/opt/homebrew/bin/brew shellenv)" | |
| # Also add to .zprofile for future sessions | |
| if ! grep -q "brew shellenv" "$HOME/.zprofile" 2>/dev/null; then | |
| echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> "$HOME/.zprofile" | |
| fi | |
| else | |
| eval "$(/usr/local/bin/brew shellenv)" | |
| fi | |
| print_success "Homebrew installed" | |
| else | |
| print_success "Homebrew is already installed ($(brew --version | head -n 1))" | |
| fi | |
| # ============================================================================= | |
| # STEP 6: Install Node.js | |
| # ============================================================================= | |
| print_header "STEP 6: Installing Node.js" | |
| if ! command -v node &> /dev/null; then | |
| print_info "Installing Node.js via Homebrew..." | |
| brew install node | |
| print_success "Node.js installed" | |
| else | |
| print_success "Node.js is already installed ($(node --version))" | |
| if confirm_action "Reinstall/update Node.js to latest version?" "n"; then | |
| brew upgrade node || brew install node | |
| print_success "Node.js updated" | |
| fi | |
| fi | |
| if ! command -v npm &> /dev/null; then | |
| print_warning "npm not found. Reinstalling Node.js..." | |
| brew reinstall node | |
| fi | |
| print_success "npm is available ($(npm --version))" | |
| # ============================================================================= | |
| # STEP 7: Install Claude Code CLI | |
| # ============================================================================= | |
| print_header "STEP 7: Installing Claude Code CLI" | |
| # Setup npm global directory without sudo (recommended) | |
| if [[ ! -d "$HOME/.npm-global" ]]; then | |
| print_info "Setting up npm global directory..." | |
| mkdir -p "$HOME/.npm-global" | |
| npm config set prefix '~/.npm-global' | |
| print_success "npm global directory configured" | |
| fi | |
| # Install Claude Code CLI | |
| if ! command -v claude &> /dev/null; then | |
| print_info "Installing @anthropic-ai/claude-code..." | |
| npm install -g @anthropic-ai/claude-code | |
| print_success "Claude Code CLI installed" | |
| else | |
| print_success "Claude Code CLI is already installed ($(claude --version 2>&1 || echo 'unknown version'))" | |
| if confirm_action "Update Claude Code CLI to latest version?" "n"; then | |
| npm update -g @anthropic-ai/claude-code | |
| print_success "Claude Code CLI updated" | |
| fi | |
| fi | |
| # ============================================================================= | |
| # STEP 8: Configure Claude Code Settings | |
| # ============================================================================= | |
| print_header "STEP 8: Configuring Claude Code Settings" | |
| CLAUDE_DIR="$HOME/.claude" | |
| SETTINGS_FILE="$CLAUDE_DIR/settings.json" | |
| # Create .claude directory if it doesn't exist | |
| if [[ ! -d "$CLAUDE_DIR" ]]; then | |
| print_info "Creating ~/.claude directory..." | |
| mkdir -p "$CLAUDE_DIR" | |
| print_success "Directory created" | |
| else | |
| print_info "~/.claude directory already exists" | |
| fi | |
| # Backup existing settings.json if present | |
| if [[ -f "$SETTINGS_FILE" ]]; then | |
| if confirm_action "Backup existing settings.json?" "y"; then | |
| cp "$SETTINGS_FILE" "$SETTINGS_FILE.backup.$(date +%Y%m%d%H%M%S)" | |
| print_success "Backed up existing settings.json" | |
| fi | |
| fi | |
| # Write the settings.json file | |
| print_info "Writing Claude Code settings..." | |
| # Use the API key if provided, otherwise use placeholder | |
| if [[ -n "$DEEPSEEK_API_KEY" ]]; then | |
| API_KEY_VALUE="$DEEPSEEK_API_KEY" | |
| print_success "Using your provided DeepSeek API key" | |
| else | |
| API_KEY_VALUE="your-key-here" | |
| print_warning "No API key provided - you'll need to add it manually" | |
| fi | |
| cat > "$SETTINGS_FILE" << EOF | |
| { | |
| "env": { | |
| "ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic", | |
| "ANTHROPIC_AUTH_TOKEN": "$API_KEY_VALUE", | |
| "API_TIMEOUT_MS": "600000", | |
| "ANTHROPIC_MODEL": "deepseek-v4-pro[1m]", | |
| "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro[1m]", | |
| "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro[1m]", | |
| "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4-flash", | |
| "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1" | |
| }, | |
| "permissions": { | |
| "defaultMode": "bypassPermissions" | |
| }, | |
| "skipDangerousModePermissionPrompt": true, | |
| "skipAutoPermissionPrompt": true | |
| } | |
| EOF | |
| print_success "Claude Code settings written to ~/.claude/settings.json" | |
| if [[ -z "$DEEPSEEK_API_KEY" ]]; then | |
| print_warning "Don't forget to edit ~/.claude/settings.json and add your DeepSeek API key!" | |
| fi | |
| # ============================================================================= | |
| # STEP 9: Source Configuration | |
| # ============================================================================= | |
| source_zshrc | |
| # ============================================================================= | |
| # STEP 10: Verification | |
| # ============================================================================= | |
| print_header "Installation Verification" | |
| echo "" | |
| echo "${GREEN}╔═══════════════════════════════════════════════════════════════╗${NC}" | |
| echo "${GREEN}║ Installation Summary ║${NC}" | |
| echo "${GREEN}╚═══════════════════════════════════════════════════════════════╝${NC}" | |
| echo "" | |
| # Check each tool | |
| echo -n "Xcode CLT: " | |
| if xcode-select -p &> /dev/null; then | |
| echo "${GREEN}Installed${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "Git: " | |
| if command -v git &> /dev/null; then | |
| echo "${GREEN}$(git --version | cut -d' ' -f3)${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "Zsh: " | |
| if command -v zsh &> /dev/null; then | |
| echo "${GREEN}$(zsh --version)${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "Oh-My-Zsh: " | |
| if [[ -d "$HOME/.oh-my-zsh" ]]; then | |
| echo "${GREEN}Installed${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "Homebrew: " | |
| if command -v brew &> /dev/null; then | |
| echo "${GREEN}$(brew --version | head -n 1)${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "Node.js: " | |
| if command -v node &> /dev/null; then | |
| echo "${GREEN}$(node --version)${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "npm: " | |
| if command -v npm &> /dev/null; then | |
| echo "${GREEN}$(npm --version)${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "Claude Code CLI: " | |
| if command -v claude &> /dev/null; then | |
| echo "${GREEN}$(claude --version 2>&1 | head -n1 || echo 'Installed')${NC}" | |
| else | |
| echo "${RED}Not installed${NC}" | |
| fi | |
| echo -n "Claude Settings: " | |
| if [[ -f "$HOME/.claude/settings.json" ]]; then | |
| echo "${GREEN}Configured${NC}" | |
| else | |
| echo "${RED}Not found${NC}" | |
| fi | |
| echo -n "DeepSeek API Key: " | |
| if [[ -f "$HOME/.claude/settings.json" ]] && grep -q "your-key" "$HOME/.claude/settings.json" 2>/dev/null; then | |
| echo "${YELLOW}Not configured${NC}" | |
| elif [[ -f "$HOME/.claude/settings.json" ]]; then | |
| echo "${GREEN}Configured${NC}" | |
| else | |
| echo "${RED}Missing${NC}" | |
| fi | |
| echo "" | |
| echo "${GREEN}╔═══════════════════════════════════════════════════════════════╗${NC}" | |
| echo "${GREEN}║ Setup Complete! ║${NC}" | |
| echo "${GREEN}╚═══════════════════════════════════════════════════════════════╝${NC}" | |
| echo "" | |
| # Next steps based on choices | |
| print_info "Next steps:" | |
| STEP_NUM=1 | |
| if [[ "$AUTO_SOURCE" != true ]]; then | |
| echo " $STEP_NUM. Run ${YELLOW}source ~/.zshrc${NC} to load the new configuration" | |
| ((STEP_NUM++)) | |
| fi | |
| if [[ "$SKIP_SHELL_CHANGE" != true ]] && [[ "$CURRENT_SHELL" != "$ZSH_PATH" ]]; then | |
| echo " $STEP_NUM. ${YELLOW}Log out and log back in${NC} (or restart Terminal) to activate zsh as default shell" | |
| ((STEP_NUM++)) | |
| fi | |
| if [[ -z "$DEEPSEEK_API_KEY" ]]; then | |
| echo " $STEP_NUM. ${YELLOW}Edit ~/.claude/settings.json${NC} and replace 'your-key-here' with your actual DeepSeek API key" | |
| ((STEP_NUM++)) | |
| fi | |
| echo " $STEP_NUM. Run ${YELLOW}claude${NC} to start using the Claude Code CLI" | |
| ((STEP_NUM++)) | |
| echo "" | |
| print_info "Useful commands:" | |
| echo " • ${YELLOW}brew update && brew upgrade${NC} - Update all Homebrew packages" | |
| echo " • ${YELLOW}npm update -g @anthropic-ai/claude-code${NC} - Update Claude Code CLI" | |
| echo " • ${YELLOW}omz update${NC} - Update Oh-My-Zsh" | |
| echo " • ${YELLOW}claude${NC} - Start Claude Code CLI" | |
| echo " • ${YELLOW}reload${NC} - Reload zsh configuration (alias defined in .zshrc)" | |
| echo "" | |
| print_success "Installation complete! 🎉" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment