|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Compact installer for OpenAI, Gemini, and Claude command-line tools. |
| 4 | +# |
| 5 | +# Usage: |
| 6 | +# chmod +x install_agents.sh |
| 7 | +# ./install_agents.sh |
| 8 | +# |
| 9 | + |
| 10 | +# Helper function to check if a command is available |
| 11 | +command_exists() { |
| 12 | + command -v "$1" >/dev/null 2>&1 |
| 13 | +} |
| 14 | + |
| 15 | +echo "--- Checking Prerequisites ---" |
| 16 | +if ! command_exists node || ! command_exists npm; then |
| 17 | + echo "Error: Node.js and npm are required. Please install them and rerun." |
| 18 | + exit 1 |
| 19 | +fi |
| 20 | +echo "Prerequisites met." |
| 21 | + |
| 22 | +# --- OpenAI Codex CLI --- |
| 23 | +echo "--- Installing OpenAI Codex CLI ---" |
| 24 | +if command_exists codex; then |
| 25 | + echo "OpenAI Codex CLI is already installed." |
| 26 | +else |
| 27 | + echo "Installing via npm..." |
| 28 | + if npm install -g @openai/codex; then |
| 29 | + echo "Success. Configure with: export OPENAI_API_KEY='your-key'" |
| 30 | + else |
| 31 | + echo "Failed to install OpenAI Codex CLI." >&2 |
| 32 | + fi |
| 33 | +fi |
| 34 | + |
| 35 | +# --- Google Gemini CLI --- |
| 36 | +echo "--- Installing Google Gemini CLI ---" |
| 37 | +if command_exists gemini; then |
| 38 | + echo "Google Gemini CLI is already installed." |
| 39 | +else |
| 40 | + echo "Installing via npm..." |
| 41 | + # Installs the official Gemini CLI agent |
| 42 | + if npm install -g @google/gemini-cli; then |
| 43 | + echo "Success. Run 'gemini auth login' or just 'gemini' to authenticate." |
| 44 | + else |
| 45 | + echo "Failed to install Google Gemini CLI." >&2 |
| 46 | + fi |
| 47 | +fi |
| 48 | + |
| 49 | +# --- Anthropic Claude Code CLI --- |
| 50 | +echo "--- Installing Anthropic Claude Code CLI ---" |
| 51 | +if command_exists claude; then |
| 52 | + echo "Anthropic Claude Code CLI is already installed." |
| 53 | +else |
| 54 | + echo "Installing via npm..." |
| 55 | + if npm install -g @anthropic-ai/claude-code; then |
| 56 | + echo "Success. Run 'claude' in your project directory to start." |
| 57 | + else |
| 58 | + echo "Failed to install Anthropic Claude Code CLI." >&2 |
| 59 | + fi |
| 60 | +fi |
| 61 | + |
| 62 | +echo "Installing context 7 into claude code" |
| 63 | +npm install -g @anthropic-ai/claude-code |
| 64 | +claude mcp add screenshot-website-fast -s user -- npx -y @just-every/mcp-screenshot-website-fast |
| 65 | +claude mcp add --transport http context7 https://mcp.context7.com/mcp |
| 66 | +echo "--- Installation Complete ---" |
| 67 | +echo "Remember to configure API keys and restart your shell for changes to take effect." |
| 68 | + |
| 69 | +# --- Setting up CLI aliases --- |
| 70 | +echo "--- Setting up CLI aliases ---" |
| 71 | +ALIAS_COMMAND="alias dclaude='claude --dangerously-skip-permissions'" |
| 72 | + |
| 73 | +# Add alias to common shell configuration files |
| 74 | +for shell_config in ~/.bashrc ~/.zshrc ~/.profile; do |
| 75 | + if [ -f "$shell_config" ]; then |
| 76 | + if ! grep -q "alias dclaude=" "$shell_config"; then |
| 77 | + echo "" >> "$shell_config" |
| 78 | + echo "# Claude CLI shortcut" >> "$shell_config" |
| 79 | + echo "$ALIAS_COMMAND" >> "$shell_config" |
| 80 | + echo "Added dclaude alias to $shell_config" |
| 81 | + else |
| 82 | + echo "dclaude alias already exists in $shell_config" |
| 83 | + fi |
| 84 | + fi |
| 85 | +done |
| 86 | + |
| 87 | +echo "Alias 'dclaude' has been added. Restart your terminal or run 'source ~/.bashrc' (or appropriate shell config) to use it." |
| 88 | + |
| 89 | + |
0 commit comments