1 parent
b3eb178884
commit
44e1ffa974
3 files changed
+34
-4
No files matched your search
@@ -54,4 +54,5 @@ clashui
|
||||
_okcat '🎉' 'enjoy 🎉'
|
||||
clash
|
||||
# shellcheck disable=SC2016
|
||||
[ "$SUDO_USER" != 'root' ] && _okcat '请执行 clashon 开启代理环境'
|
||||
_quit
|
||||
+31
-2
@@ -4,8 +4,6 @@ clashctl \
|
||||
mihomo \
|
||||
mihomoctl \
|
||||
\
|
||||
clashon \
|
||||
clashoff \
|
||||
clashui \
|
||||
clashstatus \
|
||||
clashsecret \
|
||||
@@ -20,4 +18,35 @@ for fn in $fn_arr
|
||||
"function $fn
|
||||
bash -i -c '$fn \$@;exec fish -i' -- \$argv
|
||||
end"
|
||||
end
|
||||
|
||||
function clashon
|
||||
bash -i -c 'clashon; sudo tee /var/proxy >/dev/null <<EOF
|
||||
export http_proxy=$http_proxy
|
||||
export https_proxy=$http_proxy
|
||||
export HTTP_PROXY=$http_proxy
|
||||
export HTTPS_PROXY=$http_proxy
|
||||
|
||||
export all_proxy=$all_proxy
|
||||
export ALL_PROXY=$all_proxy
|
||||
|
||||
export no_proxy=$no_proxy
|
||||
export NO_PROXY=$no_proxy
|
||||
EOF'
|
||||
|
||||
source /var/proxy
|
||||
end
|
||||
|
||||
function clashoff
|
||||
bash -i -c 'clashoff'
|
||||
|
||||
set -e \
|
||||
http_proxy \
|
||||
https_proxy \
|
||||
HTTP_PROXY \
|
||||
HTTPS_PROXY \
|
||||
all_proxy \
|
||||
ALL_PROXY \
|
||||
no_proxy \
|
||||
NO_PROXY
|
||||
end
|
||||
+2
-2
@@ -51,8 +51,8 @@ function clashon() {
|
||||
watch_proxy() {
|
||||
# 新开交互式shell,且无代理变量时
|
||||
[ -z "$http_proxy" ] && [[ $- == *i* ]] && {
|
||||
# 为root时,自动开启代理环境(普通用户会触发sudo验证密码导致卡住)
|
||||
_is_root || _failcat '代理环境:关闭,可执行 clashon 开启' && clashon
|
||||
# root用户自动开启代理环境(普通用户会触发sudo验证密码导致卡住)
|
||||
_is_root && clashon
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user