Skip to content

Commit be8f580

Browse files
committed
feat(zsh): 添加 Tailscale 智能配置支持
新增 Tailscale 智能配置脚本,自动检测应用存在性并处理 CLI 模式兼容性问题。 当检测到 Tailscale 应用但缺少 CLI 命令或软链接指向错误时,自动创建包装函数, 通过 TAILSCALE_BE_CLI 环境变量强制启用 CLI 模式,避免 GUI 入口在 shell 上下文中崩溃的问题。同时确保不影响其他正常的安装来源。
1 parent b6b2efa commit be8f580

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

shell/zsh.d/10-network.zsh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Tailscale 智能配置(自动检测存在性)
2+
typeset ts_app_path="/Applications/Tailscale.app/Contents/MacOS/Tailscale"
3+
typeset ts_existing_cli_path="$(whence -p tailscale 2>/dev/null || true)"
4+
5+
if [[ -x "$ts_app_path" ]]; then
6+
typeset -i ts_should_wrap_cli=0
7+
8+
if [[ -z "$ts_existing_cli_path" ]]; then
9+
ts_should_wrap_cli=1
10+
elif [[ -L "$ts_existing_cli_path" ]] && [[ "$(readlink "$ts_existing_cli_path")" == "$ts_app_path" ]]; then
11+
ts_should_wrap_cli=1
12+
fi
13+
14+
if (( ts_should_wrap_cli )); then
15+
# 独立版 macOS app 的主二进制在普通 shell 上下文里可能误判为 GUI 入口并崩溃。
16+
# 这里显式强制 CLI 模式,只覆盖“命令缺失”或“仍指向错误软链”的场景,避免影响其他正常安装来源。
17+
tailscale() {
18+
TAILSCALE_BE_CLI=1 "/Applications/Tailscale.app/Contents/MacOS/Tailscale" "$@"
19+
}
20+
fi
21+
fi
22+
23+
unset ts_app_path ts_existing_cli_path ts_should_wrap_cli

0 commit comments

Comments
 (0)