diff --git a/advanced-claude-workflows/my-aliases.md b/advanced-claude-workflows/my-aliases.md index ab33079..ba9ba91 100644 --- a/advanced-claude-workflows/my-aliases.md +++ b/advanced-claude-workflows/my-aliases.md @@ -1,8 +1,10 @@ # My Claude Code Aliases -## zclaude (Windows PowerShell) +## Aliases File: `~\Documents\PowerShell\alias.ps1` -Launches Claude with the Z.ai API endpoint and custom model settings. +Keep all Claude aliases in a dedicated file, sourced from `$PROFILE`. + +### `~\Documents\PowerShell\alias.ps1` ```powershell function zclaude { @@ -14,20 +16,32 @@ function zclaude { $env:ANTHROPIC_DEFAULT_HAIKU_MODEL="GLM-5" claude } + +# Skip permission prompts +function x { claude --dangerously-skip-permissions } + +# Fast Haiku model +function h { claude --model claude-haiku-4-5-20251001 } + +# Load diagrams from current project +function cdi { + $diagrams = Get-Content .ai\diagrams\*.md -Raw -ErrorAction SilentlyContinue + if ($diagrams) { claude --append-system-prompt $diagrams } else { claude } +} ``` ## How to Install -1. Open your PowerShell profile: +1. Create the aliases file (Claude will write this for you, or paste manually): ```powershell - notepad $PROFILE - ``` - If the file doesn't exist, create it first: - ```powershell - New-Item -Path $PROFILE -ItemType File -Force + New-Item -Path "$HOME\Documents\PowerShell\alias.ps1" -ItemType File -Force ``` -2. Paste the function above at the bottom of the file and save. +2. Add one line to your `$PROFILE` to source it: + ```powershell + . "$HOME\Documents\PowerShell\alias.ps1" + ``` + Open profile with: `notepad $PROFILE` 3. Reload your profile: ```powershell @@ -38,37 +52,6 @@ function zclaude { ## Notes -- Environment variables set this way are scoped to the current session only - they won't leak to other terminals. -- To also load your Mermaid diagrams, extend the function: - ```powershell - function zclaude { - $env:ANTHROPIC_AUTH_TOKEN="your-api-key" - $env:ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic" - $env:API_TIMEOUT_MS="3000000" - $env:ANTHROPIC_DEFAULT_OPUS_MODEL="GLM-5" - $env:ANTHROPIC_DEFAULT_SONNET_MODEL="GLM-5" - $env:ANTHROPIC_DEFAULT_HAIKU_MODEL="GLM-5" - $diagrams = Get-Content .ai\diagrams\*.md -Raw -ErrorAction SilentlyContinue - if ($diagrams) { - claude --append-system-prompt $diagrams - } else { - claude - } - } - ``` - -## Other Useful Aliases (Optional) - -```powershell -# Skip permission prompts -function x { claude --dangerously-skip-permissions } - -# Fast Haiku model -function h { claude --model claude-haiku-4-5-20251001 } - -# Load diagrams -function cdi { - $diagrams = Get-Content .ai\diagrams\*.md -Raw - claude --append-system-prompt $diagrams -} -``` +- Environment variables set inside functions are scoped to the current session only. +- Edit `alias.ps1` anytime to add new aliases - no need to touch `$PROFILE` again. +- You can version control `alias.ps1` separately from your profile.