diff --git a/scripts/core/alias.sh b/scripts/core/alias.sh index 38bc083..899db1b 100644 --- a/scripts/core/alias.sh +++ b/scripts/core/alias.sh @@ -74,6 +74,11 @@ _clash_alias_after_on() { _clash_alias_print_sep _clash_alias_proxy_show + if [ "${CLASH_WRAPPER_EXEC:-0}" = "1" ]; then + echo "⚠️ 当前通过独立命令执行,Shell 变量不会自动回写到父终端" + echo '💡 请在当前终端执行:eval "$(clashctl proxy on)"' + fi + echo "👉 下一步:$(_clash_alias_status_next)" } @@ -82,6 +87,9 @@ _clash_alias_after_off() { _clash_alias_print_sep echo "🔴 已关闭代理环境" echo "🧹 当前 Shell 代理变量已清理" + if [ "${CLASH_WRAPPER_EXEC:-0}" = "1" ]; then + echo '💡 若当前终端仍有代理变量,请执行:eval "$(clashctl proxy off)"' + fi echo "🧭 新终端默认代理:已关闭" echo "👉 下一步:clashctl status" } diff --git a/scripts/core/common.sh b/scripts/core/common.sh index 36bc8ab..6b17df6 100644 --- a/scripts/core/common.sh +++ b/scripts/core/common.sh @@ -2178,6 +2178,39 @@ EOF ensure_command_install_dir_in_shell_path } +install_alias_command_wrappers() { + local alias_file install_dir wrapper_name + + alias_file="$(alias_source_file)" + install_dir="$(command_install_dir)" + + [ -f "$alias_file" ] || die "未找到 alias 脚本:$alias_file" + + mkdir -p "$install_dir" + + for wrapper_name in \ + clashon \ + clashoff \ + clashproxy \ + clashls \ + clashselect \ + clashui \ + clashsecret \ + clashtun \ + clashupgrade \ + clashmixin + do + cat > "$install_dir/$wrapper_name" <