Skip to content

Latest commit

 

History

History
643 lines (453 loc) · 9.15 KB

File metadata and controls

643 lines (453 loc) · 9.15 KB

CLI - Mac Development Environment Guide

Platform: macOS (Apple Silicon)
Purpose: Standardized terminal configuration for React Native, PHP, WordPress, AI Development Tools, and IDE Launchers.


Overview

This .zshrc configuration provides:

  • PHP / Composer support
  • Ruby & CocoaPods support
  • Node.js version management (NVM)
  • Android SDK support
  • Java 17 support for React Native & Gradle
  • IDE launchers (VS Code, Cursor, PhpStorm, Windsurf, Antigravity)
  • Codex Desktop & CLI integration
  • Developer productivity aliases

Folder Structure

.zshrc
├── Composer
├── Ruby
├── NVM
├── Android SDK
├── Java
├── IDE Launchers
├── Codex Function
├── Aliases
└── rbenv

Composer

Provides access to globally installed Composer packages.

export PATH="$HOME/.composer/vendor/bin:$PATH"

Verification

composer --version

Ruby

Required for:

  • CocoaPods
  • Fastlane
  • Ruby gems
  • React Native iOS builds
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"

Verification

ruby -v

Node Version Manager (NVM)

Allows switching between multiple Node.js versions.

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"

Verification

nvm --version
node -v
npm -v

Android SDK

Required for:

  • Android Emulator
  • adb
  • React Native Android builds
export ANDROID_HOME="$HOME/Library/Android/sdk"

export PATH="$PATH:$ANDROID_HOME/emulator"
export PATH="$PATH:$ANDROID_HOME/platform-tools"

Verification

adb version
emulator -version

Java 17 for React Native / Gradle

Required by:

  • Gradle
  • Android Builds
  • React Native
export JAVA_HOME="/opt/homebrew/opt/openjdk@17"
export PATH="$JAVA_HOME/bin:$PATH"

Verification

java -version
javac -version

Windsurf

AI-powered IDE from Codeium.

export PATH="/Users/amr.elghadban/.codeium/windsurf/bin:$PATH"

Usage

surf .

or

windsurf .

Antigravity

AI-powered development environment.

export PATH="/Users/amr.elghadban/.antigravity/antigravity/bin:$PATH"

Usage

antigravity .

Antigravity IDE

Standalone IDE launcher.

export PATH="/Users/amr.elghadban/.antigravity-ide/antigravity-ide/bin:$PATH"

Usage

antigravity-ide .

PhpStorm

JetBrains PHP IDE launcher.

export PATH="/Applications/PhpStorm.app/Contents/MacOS:$PATH"

Usage

phpstorm .

Codex Launcher

Custom launcher that supports both:

  • Codex Desktop
  • Codex CLI

Desktop Mode

Open current folder in Codex Desktop.

codex
codex .
codex app .

CLI Mode

Run Codex CLI.

codex cli
codex cli --help
codex cli generate

Function Definition

# --------------------------------------------------
# Codex smart launcher (Desktop + CLI)
#
# Usage:
#   codex              → Open Codex Desktop (current dir)
#   codex .            → Open Codex Desktop (current dir)
#   codex app [path]   → Open Codex Desktop (optional path)
#
#   codex cli          → Run Codex CLI (current dir)
#   codex cli --help   → Codex CLI help
#   codex cli .        → Codex CLI scoped to dir
#
# Notes:
# - Defaults to Desktop when no mode is provided
# - Desktop and CLI are intentionally separated
# - Avoids conflicts with Codex CLI binary
# --------------------------------------------------

codex() {
  local mode="$1"
  local target

  if [[ "$mode" == "cli" || "$mode" == "app" ]]; then
    shift
  else
    mode="app"
  fi

  target="${1:-.}"

  case "$mode" in
    app)
      open -a "Codex" "$target"
      ;;
    cli)
      if command -v codex-cli >/dev/null 2>&1; then
        command codex-cli "$@"
      elif command -v codex >/dev/null 2>&1; then
        command codex "$@"
      else
        echo "Codex CLI not found in PATH"
        return 1
      fi
      ;;
  esac
}

IDE Productivity Aliases


Visual Studio Code

alias vs="code"

Usage:

vs .

Cursor

alias cr="cursor"

Usage:

cr .

PhpStorm

alias ps="phpstorm"

Usage:

ps .

Windsurf

alias ws="surf"
alias windsurf="surf"

Usage:

ws .

or

windsurf .

Antigravity

alias ag="antigravity"

Usage:

ag .

Oh My Zsh Helpers

alias zshconfig="mate ~/.zshrc"
alias ohmyzsh="mate ~/.oh-my-zsh"

Usage

Edit zsh configuration:

zshconfig

Open Oh My Zsh folder:

ohmyzsh

rbenv

Used to manage Ruby versions.

eval "$(rbenv init - zsh)"

Verification

rbenv versions

Recommended Cleanup

Remove duplicate entries:

export PATH="/opt/homebrew/opt/ruby/bin:$PATH"

Keep only one copy.


export PATH="/Users/amr.elghadban/.antigravity-ide/antigravity-ide/bin:$PATH"

Keep only one copy.


Frequently Used Commands

Open Current Project

vs .
cr .
ps .
ws .
ag .
codex .

Check Development Environment

node -v
npm -v
ruby -v
java -version
adb version
composer --version

Reload Terminal Configuration

source ~/.zshrc

Recommended Backup

Before making changes:

cp ~/.zshrc ~/.zshrc.backup

Restore if needed:

cp ~/.zshrc.backup ~/.zshrc
source ~/.zshrc

backup snap for .zshrc

# User configuration

# export MANPATH="/usr/local/man:$MANPATH"

# You may need to manually set your language environment
# export LANG=en_US.UTF-8

# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
#   export EDITOR='vim'
# else
#   export EDITOR='mvim'
# fi

# Compilation flags
# export ARCHFLAGS="-arch x86_64"

export PATH="$HOME/.composer/vendor/bin:$PATH"
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"

export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"   # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"   # This loads nvm bash_completion

export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/emulator
export PATH=$PATH:$ANDROID_HOME/platform-tools

# Use Java 17 for React Native / Gradle
export JAVA_HOME="/opt/homebrew/opt/openjdk@17"
export PATH="$JAVA_HOME/bin:$PATH"


# Added by Windsurf
export PATH="/Users/amr.elghadban/.codeium/windsurf/bin:$PATH"

# Added by Antigravity
export PATH="/Users/amr.elghadban/.antigravity/antigravity/bin:$PATH"

# Added for PhpStorm
export PATH="/Applications/PhpStorm.app/Contents/MacOS:$PATH"

# --------------------------------------------------
# Codex smart launcher (Desktop + CLI)
#
# Usage:
#   codex              → Open Codex Desktop (current dir)
#   codex .            → Open Codex Desktop (current dir)
#   codex app [path]   → Open Codex Desktop (optional path)
#
#   codex cli          → Run Codex CLI (current dir)
#   codex cli --help   → Codex CLI help
#   codex cli .        → Codex CLI scoped to dir
#
# Notes:
# - Defaults to Desktop when no mode is provided
# - Desktop and CLI are intentionally separated
# - Avoids conflicts with Codex CLI binary
# --------------------------------------------------
codex() {
  local mode="$1"
  local target

  # Explicit mode handling
  if [[ "$mode" == "cli" || "$mode" == "app" ]]; then
    shift
  else
    mode="app"
  fi

  target="${1:-.}"

  case "$mode" in
    app)
      open -a "Codex" "$target"
      ;;
    cli)
      if command -v codex-cli >/dev/null 2>&1; then
        command codex-cli "$@"
      elif command -v codex >/dev/null 2>&1; then
        # fallback if CLI binary is also named codex
        command codex "$@"
      else
        echo "❌ Codex CLI not found in PATH"
        echo "👉 Install with: npm install -g @openai/codex"
        return 1
      fi
      ;;
  esac
}

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
alias zshconfig="mate ~/.zshrc"
alias ohmyzsh="mate ~/.oh-my-zsh"

# IDE Aliases
alias vs="code"
alias cr="cursor"
alias ps="phpstorm"
alias ws="surf"
alias windsurf="surf"
alias ag="antigravity"

#alias codex='open -a "Codex"' # <<<< example for open app via terminal command


eval "$(rbenv init - zsh)"
# Added by Antigravity IDE
export PATH="/Users/amr.elghadban/.antigravity-ide/antigravity-ide/bin:$PATH"

Owner Notes

This configuration is optimized for:

  • React Native Development
  • PHP Development
  • WordPress Projects
  • Android Builds
  • iOS Builds (CocoaPods)
  • AI-Assisted Development
    • Codex
    • Windsurf
    • Antigravity
    • Cursor
  • JetBrains PhpStorm Workflow

Maintained by: Amr Ahmed Elghadban