01配置 PowerShell 代理
在 Windows Terminal 中打开 PowerShell 标签页,逐条执行以下命令配置代理开关函数。
❯
if (!(Test-Path -Path $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force }
❯
notepad $PROFILE
在记事本中粘贴下方配置内容,Ctrl+S 保存并关闭。
profile.ps1
POWERSHELL · $PROFILE
if (Test-Path Alias:curl) { Remove-Item Alias:curl }
if (Test-Path Alias:wget) { Remove-Item Alias:wget }
$PH = "http://127.0.0.1:10808"
$PS5 = "socks5://127.0.0.1:10808"
function proxy {
$env:all_proxy = $env:ALL_PROXY = $env:http_proxy = $env:HTTP_PROXY = `
$env:https_proxy = $env:HTTPS_PROXY = $PH
if (Get-Command git -EA 0) { git config --global http.proxy $PS5; git config --global https.proxy $PS5 }
if (Get-Command npm -EA 0) { npm config set proxy $PH 2>$null; npm config set https-proxy $PH 2>$null }
if (Get-Command yarn -EA 0) { yarn config set proxy $PH 2>$null; yarn config set https-proxy $PH 2>$null }
Write-Host "Proxy ON" -ForegroundColor Green
}
function unproxy {
'all_proxy','ALL_PROXY','http_proxy','https_proxy','HTTP_PROXY','HTTPS_PROXY' | `
ForEach-Object { Remove-Item "Env:\$_" -EA 0 }
if (Get-Command git -EA 0) { git config --global --unset http.proxy 2>$null; git config --global --unset https.proxy 2>$null }
if (Get-Command npm -EA 0) { npm config delete proxy 2>$null; npm config delete https-proxy 2>$null }
if (Get-Command yarn -EA 0) { yarn config delete proxy 2>$null; yarn config delete https-proxy 2>$null }
Write-Host "Proxy OFF" -ForegroundColor Yellow
}
proxy
❯
. $PROFILE
重新加载后终端显示 "Proxy ON" 即配置成功。之后可用 proxy / unproxy 随时开关。
02安装命令行工具
确保代理已开启,终端显示 Proxy ON 后,分别安装以下三个工具。
C
OpenAI Codex CLI
OpenAI 出品 · 终端编程代理
❯
npm i -g @openai/codex
❯
codex --version
❯
codex
认证:运行后选择 "Sign in with ChatGPT",浏览器自动打开完成 OAuth 登录。
订阅:需要 ChatGPT Plus / Pro / Team / Enterprise 订阅。
G
Google Gemini CLI
Google 出品 · 终端 AI 代理
❯
npm install -g @google/gemini-cli
❯
gemini --version
❯
gemini
认证:运行后选择 Google 账号登录,浏览器自动打开完成认证。
订阅:免费 Google 账号即可使用。
A
Anthropic Claude Code
Anthropic 出品 · 终端编程代理
❯
irm https://claude.ai/install.ps1 | iex
❯
npm install -g @anthropic-ai/claude-code
❯
claude --version
❯
claude
认证:运行后按提示完成 OAuth 登录,浏览器自动打开。也可配置 API Key 认证。
订阅:需要 Claude Pro / Max 订阅,或 Anthropic Console 绑定计费的 API Key。
03开始使用
进入项目文件夹,运行对应命令即可开始 AI 编程。
❯
cd your-project-folder
❯
codex
❯
gemini
❯
claude
建议在 Git 仓库中使用,方便追踪 AI 产生的代码变更。