11<h1 align =" center " >
2- 🐧 Clash for Linux</ a >
2+ 🐧 Clash for Linux TUI
33 <br >
44</h1 >
55
66<p align =" center " >
7- 💬 社区交流: <a href =" https://t.me/+NsYaX9kzqERlNzZl " >Telegram 群 </a >
7+ 基于 <a href =" https://github.com/wnlen/clash-for-linux " >wnlen/clash-for-linux </a > 改进,新增交互式 TUI 仪表盘
88</p >
99
1010<h3 align =" center " >
1111一个更完整、更优雅的 Linux Clash / <a href =" https://github.com/MetaCubeX/mihomo " >Mihomo</a > 运行平台。
1212</h3 >
13+
1314<p align =" center " >
1415 <img src =" resources/shell.png " width =" 100% " >
1516</p >
1617
18+ ## 🔀 Fork 说明
19+
20+ 本项目 Fork 自 [ wnlen/clash-for-linux] ( https://github.com/wnlen/clash-for-linux ) ,在原项目基础上新增了以下改进:
21+
22+ - ** 交互式 TUI 仪表盘** — 基于 [ gum] ( https://github.com/charmbracelet/gum ) 构建的终端控制台,一条命令 ` clashctl tui ` 即可进入全功能可视化管理界面
23+ - ** 节点延迟测速** — 支持并发测速所有节点,实时显示延迟数据并按延迟排序
24+ - ** 节点名称 Unicode 兼容** — 修复了含 emoji / 中文的策略组和节点名在 API 调用中的编码问题
1725
26+ > 上游仓库的所有功能均完整保留,TUI 为增量功能,不影响原有命令行操作方式。
27+
28+ ------
1829
1930# ✨ 核心特性
2031
32+ - 🖥️ ** TUI 仪表盘** :终端内全功能可视化控制台(` clashctl tui ` )
2133- 🚀 ** 自动识别系统架构** :自动下载并使用对应 Clash 内核
2234- 🧪 ** 端口自动检测与分配** :避免冲突
2335- 🔄 ** 多订阅管理** :可以保存多个订阅,通过 ` clashctl use ` 切换当前主订阅。
2638- 🧠 ** Mixin 机制** :可按需追加/覆盖 Clash 配置
2739- 👤 ** 不同权限** :兼容 ` root ` 与普通用户环境。
2840- 🔐 ** 安全默认配置** :自动生成或自定义 Secret
29- - 🩺 ** 内置诊断工具(` doctor ` )** :快速排障
41+ - 🩺 ** 内置诊断工具(` doctor ` )** :快速排障
3042
3143### 适用场景
3244
3648- 需要稳定访问 GitHub、Go / Node / Docker 生态的开发者
3749- 不希望手动维护 Clash 运行状态的用户
3850
51+ ------
52+
53+ # 🖥️ TUI 仪表盘
54+
55+ 通过 ` clashctl tui ` 进入交互式终端控制台,无需记忆命令即可管理所有功能。
56+
57+ ### 启动方式
58+
59+ ``` bash
60+ clashctl tui
61+ ```
62+
63+ ### 主界面
64+
65+ TUI 启动后会显示状态面板和功能菜单:
66+
67+ <!-- TODO: 替换为真实截图 -->
68+ <!-- <p align="center"><img src="resources/tui-main.png" width="80%"></p> -->
69+
70+ ```
71+ ╔══════════════════════════════════════╗
72+ ║ 🐱 Clash TUI 控制台 ║
73+ ╚══════════════════════════════════════╝
74+
75+ ╭──────────────────────────────────────╮
76+ │ ✅ 代理状态:已运行 │
77+ │ 📡 当前订阅:my-sub │
78+ │ 🚀 当前节点:香港 IPLC 01 │
79+ │ 🌐 可用性 :google.com ✓ │
80+ │ 🗺 代理模式:rule │
81+ │ 🟢 风险等级:low │
82+ │ 🔧 运行内核:mihomo │
83+ │ ⚙️ 运行后端:systemd │
84+ │ 🌐 代理端口:7890 │
85+ │ 📜 系统代理:已设置 │
86+ │ 🚦 开机接管:已开启 │
87+ ╰──────────────────────────────────────╯
88+
89+ > ⛔ 关闭代理
90+ 💫 切换节点
91+ 💱 切换订阅
92+ 🌐 代理模式
93+ 🔌 活跃连接
94+ 📡 订阅管理
95+ 📋 订阅列表
96+ 🔍 状态详情
97+ 🩺 系统诊断
98+ 📜 查看日志
99+ 🧩 配置管理
100+ 🧪 Tun 管理
101+ 🚦 开机接管
102+ 🔑 密钥管理
103+ 🔄 刷新状态
104+ ❌ 退出
105+ ```
106+
107+ ### 功能详解
108+
109+ | 功能 | 说明 |
110+ | ------| ------|
111+ | ** 切换节点** | 浏览所有策略组,搜索过滤节点,查看延迟,支持一键并发测速所有节点 |
112+ | ** 切换订阅** | 快速切换当前激活的订阅源 |
113+ | ** 代理模式** | 在 Rule / Global / Direct 模式之间一键切换 |
114+ | ** 活跃连接** | 查看当前活跃连接列表,分页浏览,支持一键关闭所有连接 |
115+ | ** 订阅管理** | 添加 / 启用 / 禁用 / 重命名 / 删除订阅 |
116+ | ** 订阅列表** | 查看所有已保存订阅的状态 |
117+ | ** 状态详情** | 展示运行内核版本、端口、配置路径等详细信息 |
118+ | ** 系统诊断** | 调用 ` doctor ` 诊断面板,快速排查问题 |
119+ | ** 查看日志** | 实时查看 Clash 运行日志,支持级别过滤 |
120+ | ** 配置管理** | 查看 / 编辑 / 重新生成运行配置 |
121+ | ** Tun 管理** | 启用 / 关闭 Tun 模式,查看 Tun 诊断 |
122+ | ** 开机接管** | 管理开机自启和系统代理持久化 |
123+ | ** 密钥管理** | 查看和修改 Web 控制台访问密钥 |
124+
125+ ### 节点切换与测速
126+
127+ <!-- TODO: 替换为真实截图 -->
128+ <!-- <p align="center"><img src="resources/tui-node-select.png" width="80%"></p> -->
129+
130+ ```
131+ ╔══════════════════════════════════════╗
132+ ║ 💫 切换节点 ║
133+ ╚══════════════════════════════════════╝
134+
135+ 选择策略组(ESC / 🔙 返回主菜单)
136+ > 🔍 搜索策略组...
137+
138+ 节点选择 │ Selector │ 香港 IPLC 01
139+ 自动选择 │ URLTest │ 日本 NTT 03
140+ 故障转移 │ Fallback │ 新加坡 BGP 02
141+
142+ ────────────────────────────────────────
143+
144+ ⚡ 测速所有节点
145+ 🔙 返回策略组
146+
147+ 🇭🇰 香港 IPLC 01 ⚡ 58ms ← 当前
148+ 🇭🇰 香港 IPLC 02 ⚡ 72ms
149+ 🇯🇵 日本 NTT 03 ⚡ 89ms
150+ 🇸🇬 新加坡 BGP 02 ⚡ 112ms
151+ 🇺🇸 美国 San Jose 01 ⚡ 186ms
152+ 🇰🇷 韩国 首尔 01 ⏱ 超时
153+ ```
154+
155+ - 支持 ** 模糊搜索** :输入关键字快速定位策略组和节点
156+ - 支持 ** 并发测速** :对所有节点同时发起测速请求(约 3 秒完成),结果按延迟排序显示
157+ - 测速结果会被缓存,在当前选择会话中复用,切换节点无需重复测速
158+
159+ ### 可选依赖
160+
161+ TUI 依赖 [ gum] ( https://github.com/charmbracelet/gum ) (Charm 出品的终端 UI 工具)。gum 不是主安装依赖;未安装时仅 ` clashctl tui ` 不可用,` clashon ` 、` clashoff ` 、` clashctl select ` 、` status ` 、` doctor ` 等命令不受影响。
162+
163+ ``` bash
164+ # macOS
165+ brew install gum
166+
167+ # Arch Linux
168+ pacman -S gum
169+
170+ # Ubuntu/Debian
171+ sudo mkdir -p /etc/apt/keyrings
172+ curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/charm.gpg
173+ echo " deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list
174+ sudo apt update && sudo apt install gum
175+
176+ # Fedora/RHEL
177+ echo ' [charm]
178+ name=Charm
179+ baseurl=https://repo.charm.sh/yum/
180+ enabled=1
181+ gpgcheck=1
182+ gpgkey=https://repo.charm.sh/yum/gpg.key' | sudo tee /etc/yum.repos.d/charm.repo
183+ sudo yum install gum
184+
185+ # Go
186+ go install github.com/charmbracelet/gum@latest
187+ ```
188+
189+ > 如果未安装 gum,其他所有命令行功能仍然完全可用,仅 ` clashctl tui ` 不可用。
190+
191+ ------
192+
39193# 🚀 一键安装(推荐)
40194
41195在终端中执行以下命令即可完成安装:
42196
43197```
44- git clone --branch master --depth 1 https://ghfast.top/https://github.com/wnlen /clash-for-linux.git
45- cd clash-for-linux
198+ git clone --branch master --depth 1 https://ghfast.top/https://github.com/Babylonehy /clash-for-linux-tui .git
199+ cd clash-for-linux-tui
46200bash install.sh
47201```
48202
@@ -57,6 +211,7 @@ bash install.sh
57211〽️ 常用命令
58212 clashon 🚀 开启代理
59213 clashoff ⛔ 关闭代理
214+ clashctl tui 🖥️ TUI 控制台(新增)
60215 clashctl select 💫 选择节点
61216🕹️ 控制台
62217 clashui 🕹️ 查看 Web 控制台
@@ -187,8 +342,8 @@ clashctl boot proxy on|off|status
187342
188343` ` ` bash
189344cd /root
190- git clone --branch master --depth 1 https://ghfast.top/https://github.com/wnlen /clash-for-linux.git
191- cd clash-for-linux
345+ git clone --branch master --depth 1 https://ghfast.top/https://github.com/Babylonehy /clash-for-linux-tui .git
346+ cd clash-for-linux-tui
192347` ` `
193348
194349安装依赖:
@@ -224,6 +379,7 @@ OpenWrt 下 root/system 安装会把 `clashctl`、`clashon`、`clashoff` 等命
224379- ` doctor`
225380- ` ui`
226381- ` select`
382+ - ` tui` (新增)
227383
228384Control 层负责把常用动作收口成可理解的命令和反馈。
229385
@@ -244,7 +400,7 @@ Control 层负责把常用动作收口成可理解的命令和反馈。
244400
245401` runtime/` 是运行时目录,不是配置目录。
246402
247- 它的作用是作为“ 唯一运行容器” ,用于存放:
403+ 它的作用是作为" 唯一运行容器" ,用于存放:
248404
249405\- 运行内核(mihomo / clash)
250406\- 运行配置(config.yaml)
@@ -490,6 +646,8 @@ chmod +x /etc/rc.local
490646
491647# # 🔗 引用
492648
649+ - [clash-for-linux](https://github.com/wnlen/clash-for-linux) — 上游项目
650+ - [gum](https://github.com/charmbracelet/gum) — TUI 组件库
493651- [clash](https://clash.wiki/)
494652- [mihomo](https://github.com/MetaCubeX/mihomo)
495653- [subconverter](https://github.com/tindy2013/subconverter)
@@ -504,9 +662,6 @@ chmod +x /etc/rc.local
504662 目前此项目已集成自动识别和转换clash配置文件的功能。如果依然无法使用,则需要通过自建或者第三方平台(不推荐,有泄露风险)对订阅地址转换。
505663
5066643. 程序日志中出现` error: unsupported rule type RULE-SET` 报错,解决方法查看官方[WIKI](https://github.com/Dreamacro/clash/wiki/FAQ#error-unsupported-rule-type-rule-set)
507- # # ⭐ Star History
508-
509- [! [Star History Chart](https://api.star-history.com/svg? repos=wnlen/clash-for-linux& type=Date)](https://star-history.com/# wnlen/clash-for-linux&Date)
510665
511666# # ⚠️ 特别声明
512667
0 commit comments