Use the bundled script for repeatable Mihomo operations instead of re-discovering paths and API auth each time.
Quick start
Run:
CODEBLOCK0
The script auto-detects common Mihomo installs by checking:
- - INLINECODE0
- INLINECODE1
- INLINECODE2
It extracts:
Common commands
CODEBLOCK1
When switching a group
- 1. List groups first:
CODEBLOCK2
- 2. Switch the selector/group to a target proxy:
CODEBLOCK3
Use exact group and proxy names.
For latency / node quality questions
Default to:
CODEBLOCK4
This shows the latest recorded delay from Mihomo's history.
If the user wants a live test for one node, run:
CODEBLOCK5
Treat 0ms with caution: it may indicate missing/failed measurement rather than a truly perfect route.
For deeper API work
Read references/api.md when you need raw endpoint details, request shapes, or want to call an endpoint not wrapped by the helper script.
Practical notes
- - Prefer read-only commands first (
status, proxies, groups, connections) before mutating state. - Before
switch or restart, be sure that changing the active route is actually what the user wants. - If API requests return
Unauthorized, re-check secret from the detected config. - If the script cannot find config automatically, inspect running processes for
mihomo, clash, verge, or clashmac, then locate the active config path from process args. - On macOS with ClashMac, the real core may run as
mihomo under ~/Library/Application Support/clashmac/core/ while the GUI runs as ClashMac.app.
Useful fallback detection
When auto-detect fails, use:
CODEBLOCK6
Then inspect the config path from the process command line.
技能名称: mihomo-cli
详细描述:
使用捆绑脚本执行可重复的Mihomo操作,无需每次重新发现路径和API认证信息。
快速开始
运行:
bash
scripts/mihomo-cli.sh status
该脚本通过检查以下路径自动检测常见的Mihomo安装:
- - ~/Library/Application Support/clashmac/work/config.yaml
- ~/.config/mihomo/config.yaml
- ~/.config/clash/config.yaml
它会提取:
- - external-controller
- secret
常用命令
bash
scripts/mihomo-cli.sh status
scripts/mihomo-cli.sh proxies
scripts/mihomo-cli.sh groups
scripts/mihomo-cli.sh test
scripts/mihomo-cli.sh test 🇭🇰 E0 香港核心
scripts/mihomo-cli.sh connections
scripts/mihomo-cli.sh flush dns
scripts/mihomo-cli.sh flush fakeip
scripts/mihomo-cli.sh restart
scripts/mihomo-cli.sh config
切换分组时
- 1. 首先列出分组:
bash
scripts/mihomo-cli.sh groups
- 2. 将选择器/分组切换到目标代理:
bash
scripts/mihomo-cli.sh switch GLOBAL 🇭🇰 E0 香港核心
请使用精确的分组和代理名称。
关于延迟/节点质量问题
默认使用:
bash
scripts/mihomo-cli.sh proxies
这将显示Mihomo历史记录中最新记录的延迟。
如果用户希望对单个节点进行实时测试,请运行:
bash
scripts/mihomo-cli.sh test <代理名称>
谨慎对待0ms:它可能表示测量缺失/失败,而非真正完美的路由。
深入API工作
当需要原始端点详情、请求格式或调用辅助脚本未封装的端点时,请阅读references/api.md。
实用提示
- - 在修改状态前,优先使用只读命令(status、proxies、groups、connections)。
- 在执行switch或restart前,请确认更改活动路由确实是用户所需。
- 如果API请求返回Unauthorized,请从检测到的配置中重新检查secret。
- 如果脚本无法自动找到配置,请检查运行中的进程,查找mihomo、clash、verge或clashmac,然后从进程参数中定位活动配置路径。
- 在macOS上使用ClashMac时,实际核心可能以mihomo身份运行于~/Library/Application Support/clashmac/core/目录下,而GUI则作为ClashMac.app运行。
有用的后备检测方法
当自动检测失败时,使用:
bash
ps aux | grep -iE clash|mihomo|verge | grep -v grep
然后从进程命令行中检查配置路径。