代码by gemini,放置路径[用户文档]\PowerShell\Microsoft.PowerShell_profile.ps1
function Invoke-CommandWithProxy {
param(
[Parameter(Mandatory=$true)]
[string]$Command,
[Parameter(ValueFromRemainingArguments=$true)]
[string[]]$Arguments
)
# 设置新的代理
$env:HTTP_PROXY = "http://localhost:1081"
$env:HTTPS_PROXY = "http://localhost:1081"
# 执行命令
echo $env:HTTP_PROXY
Invoke-Expression "$Command $Arguments"
# 恢复或清除代理设置
Remove-Item Env:HTTP_PROXY
Remove-Item Env:HTTPS_PROXY
}
function gemini_pr_func {
Invoke-CommandWithProxy -Command "gemini"
}
Set-Alias gemini_pr gemini_pr_func