FlClash icon indicating copy to clipboard operation
FlClash copied to clipboard

【建议】桌面平台增加“http_proxy类环境变量修改命令”复制功能

Open HeroTch opened this issue 1 year ago • 3 comments

使终端应用程序使用代理,以Windows PowerShell 为例

$env:HTTP_PROXY="http://127.0.0.1:7890"; $env:HTTPS_PROXY="http://127.0.0.1:7890"

根据实际情况生成命令并复制到剪贴板。可以考虑在托盘图标右键菜单中添加。

HeroTch avatar Aug 13 '24 20:08 HeroTch

要不要试试,你 $PROFILE 里写个function,以端口号为变量/参数更实用? 没必要什么小事都让软件做叭,这样不得加好多玩意儿~

Ervoconite avatar Aug 15 '24 12:08 Ervoconite

Powershell:notepad $PROFILE

填入:

function genps {
     param (
             [Parameter(Mandatory = $true, Position = 0)]
             [string]$port
     )
    echo "`$env:HTTP_PROXY=`"http://127.0.0.1:$port`"; `$env:HTTPS_PROXY=`"http://127.0.0.1:$port`""
}

保存,重启 pwsh,运行:genps 7890

image

Ervoconite avatar Aug 15 '24 12:08 Ervoconite

genps | clip

image

Ervoconite avatar Aug 15 '24 12:08 Ervoconite

function clash-proxy {
     param (
             [Parameter(Mandatory = $false, Position = 0)]
             [int]$type = 1,
             [Parameter(Mandatory = $false, Position = 1)]
             [string]$port = "7890"
     )
     
     switch ($type) {
         1 {
             echo "`$env:HTTP_PROXY=`"http://127.0.0.1:$port`"; `$env:HTTPS_PROXY=`"http://127.0.0.1:$port`""
         }
         2 {
             echo "set HTTP_PROXY=http://127.0.0.1:$port && set HTTPS_PROXY=http://127.0.0.1:$port"
         }
         3 {
             echo "export HTTP_PROXY=http://127.0.0.1:$port && export HTTPS_PROXY=http://127.0.0.1:$port"
         }
         default {
             echo "Invalid type. Please use 1 for PowerShell, 2 for CMD, or 3 for Linux."
         }
     }
}

abel533 avatar Sep 10 '24 02:09 abel533

要不要试试,你 $PROFILE 里写个function,以端口号为变量/参数更实用? 没必要什么小事都让软件做叭,这样不得加好多玩意儿~

这是最常用的功能,看下人家clash-verge,怎么这种小事人家实现了。再说了,都是小事了,实现一下又不怎么样,能占用你多少开发时间,功能简陋就直接承认,别找借口!什么事都让用户自行写,那这项目别开发了!

silascript avatar Nov 25 '24 01:11 silascript