Setting up aliases on your macOS system can significantly enhance your productivity and streamline your workflow. In this guide, we'll walk you through the process of setting up aliases, ensuring you have the prerequisites covered, and providing you with a comprehensive understanding of how to make the most out of this feature.
Prerequisites for Setting Up Aliases
Before diving into the world of aliases, make sure you have the following tools installed on your system:
- Homebrew: The package manager for macOS, which can be installed from brew.sh.
- Zsh: The default shell for macOS since Catalina (), which comes pre-installed.
- Claude CLI: Anthropic's CLI tool, which can be installed using
curl -fsSL https://claude.ai/install.sh | bash.
Installing Homebrew and Claude CLI
To install Homebrew, run the following command in your terminal:
bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)For installing Claude CLI, you have multiple options:
- Native Install (Recommended):
curl -fsSL https://claude.ai/install.sh | bash - Homebrew:
brew install --cask claude-code - Bun:
bun add -g @anthropic-ai/claude-code
Understanding Shell Configuration Files
On macOS with Zsh, aliases are typically stored in two files:
- ~/.zshrc: The main Zsh configuration file.
- ~/.zsh_aliases: A dedicated file for aliases (optional).
Always remember to backup your shell configuration before making any changes: cp ~/.zshrc ~/.zshrc.backup.
Setting Up Aliases
Follow these steps to set up your aliases:
- Open Your Zsh Configuration: Open your
.zshrcfile in your preferred editor, such asnano ~/.zshrc,code ~/.zshrc, orzed ~/.zshrc. - Add Your Aliases: Add the following aliases at the end of the file:
# Claude CLI Aliases # ------------------ alias zai='ANTHROPIC_API_KEY="YOUR_API_KEY" \ ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic" \ API_TIMEOUT_MS="" \ ANTHROPIC_MODEL="glm-4.7" \ ANTHROPIC_SMALL_FAST_MODEL="glm-" \ ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-4.6" \ ANTHROPIC_DEFAULT_SONNET_MODEL="glm-4.7" \ ANTHROPIC_DEFAULT_OPUS_MODEL="glm-" \ claude --dangerously-skip-permissions' alias minimax='ANTHROPIC_API_KEY="YOUR_API_KEY" \ ANTHROPIC_BASE_URL="https://api.minimax.io/anthropic" \ API_TIMEOUT_MS="" \ ANTHROPIC_MODEL="MiniMax-M" \ ANTHROPIC_SMALL_FAST_MODEL="MiniMax-M2.1" \ ANTHROPIC_DEFAULT_OPUS_MODEL="MiniMax-M2.1" \ ANTHROPIC_DEFAULT_SONNET_MODEL="MiniMax-M" \ ANTHROPIC_DEFAULT_HAIKU_MODEL="MiniMax-M2.1" \ claude --dangerously-skip-permissions' alias claude-skip='claude --dangerously-skip-permissions' # Editor Shortcuts # ---------------- alias edit-alias='zed ~/.zshrc' alias edit-claude='zed ~/.claude.json' alias edit-claude-skills='zed ~/.claude/skills/' alias edit-claude-agents='zed ~/.claude/agents/' alias edit-claude-commands='zed ~/.claude/commands/' alias edit-claude-plugins='zed ~/.claude/plugins' alias edit-sh='zed ~/.zsh_functions/' - Replace API Keys: Never commit API keys to version control. Replace
YOUR_API_KEYwith your actual API key from Z.AI or MiniMax. - Apply Changes: Save the file and reload your shell configuration using
source ~/.zshrcor simply open a new terminal window.
Verifying Your Aliases
Check if your aliases are set up correctly by listing all aliases with alias or testing a specific alias with which claude-skip.
Usage Examples
Here are some examples of how to use your newly set up aliases:
- Claude Skip: Run Claude CLI skipping permission prompts with
claude-skip. - Z.AI: Run Claude with Z.AI backend using
zai. - MiniMax: Run Claude with MiniMax backend using
minimax.
Editor Aliases Quick Reference
Here's a quick reference for your editor aliases:
Alias Opens edit-alias ~/.zshrc edit-claude ~/.claude.json edit-claude-skills ~/.claude/skills/ edit-claude-agents ~/.claude/agents/ edit-claude-commands ~/.claude/commands/ edit-claude-plugins ~/.claude/plugins edit-sh ~/.zsh_functions/
Troubleshooting
If you encounter any issues, refer to the following troubleshooting tips:
- Alias not found after adding: Make sure you've reloaded your shell configuration using
source ~/.zshrcor opened a new terminal window. - Command not found: claude: Ensure Claude CLI is installed globally using
bun add -g @anthropic-ai/claude-codeand verify the installation withwhich claude. - API authentication errors: Double-check that your API key is correct and active, properly quoted in the alias, and that there are no extra spaces around the
=signs.