English | 简体中文
一个 Mihomo 命令行工具
[!IMPORTANT] Mihomosh 不包含 Mihomo 本体
Mihomosh 只是 一个用于操作 Mihomo 的工具
如果你的机器没有安装 Mihomo,请参考文档进行安装[!CAUTION] v2 版本因为添加了很多新功能和修改,导致与 v1 版本的配置完全不兼容!
请进行迁移以体验最新功能
Mihomo 外部控制 API 所提供的功能几乎都可以通过 Mihomosh 进行操作,而不需要使用复杂的 cURL 命令
EDITOR 环境变量指定的文件编辑器,若环境变量不存在则使用 nano,你也可以传入参数自行选择文件编辑器less 作为文件浏览器,你也可以传入参数自行选择文件浏览器自动从 GitHub Release 中搜索与你系统相匹配的预编译二进制文件进行下载安装
$ curl https://i.jpillora.com/SamuNatsu/mihomosh@latest! | bash
最新版本:https://github.com/SamuNatsu/mihomosh/releases/latest
请寻找与你系统和架构相匹配的预编译二进制文件下载安装
我们提供如下预编译二进制:
如果预编译二进制中没有你需要的,你可以通过 Cargo 编译安装
$ cargo install --git https://github.com/SamuNatsu/mihomosh.git
如果你的 Mihomo 配置文件路径需要使用 root 用户才能进行写入,那么你同样应该使用 root 用户来运行 Mihomosh,否则可能出现权限问题!
初次使用时,你需要编辑 Mihomosh 配置,告诉它 Mihomo 的配置文件路径以及 API 链接:
$ mihomosh config edit
默认会使用 EDITOR 环境变量指定的文件编辑器,若环境变量未指定则打开 nano 作为编辑器,如果你需要使用其他编辑器,请携带参数 -e,如:
$ mihomosh config edit -e vim
在编辑器中,你需要修改 mihomo-path、mihomo-api 和 mihomo-secret 为对应的配置文件路径、外部控制 API 和 API token(可选)
由于 v2 为了实现新功能而修改了很多文件配置和结构,导致与 v1 无法兼容
请将以下文件夹的内容(v1 配置)拷贝并删除:
~/.local/share/mihomosh~/Library/Application Support/io.github.SNRainiar.mihomosh~\AppData\Local\SNRainiar\mihomosh\data在 v2 中,会覆盖使用以下文件夹保存配置:
~/.local/share/mihomosh~/Library/Application Support/io.github.SamuNatsu.mihomosh~\AppData\Local\SamuNatsu\mihomosh\data你需要迁移 v1 文件夹中的如下内容:
config.yamlprofile_conf 中所有的文件所有命令的用法都可以通过 -h 或 --help 参数获得详细的说明,因此这里只会对一些需要特别注意的操作进行讲解:
Usage: mihomosh <COMMAND>
Commands:
config Manage configs
profile Manage profiles
connection Manage connections
inspect Inspect Mihomo runtime info
control Control Mihomo
proxy Print/Update/Test proxies
proxy-set Print/Update/Test proxy sets
rule Print rules
rule-set Print/Update rule sets
shell-completion Generate shell completion
help Print this message or the help of the given subcommand(s)
Options:
-h, --help Print help
-V, --version Print version
Mihomosh 支持 bash、elvish、fish、powershell 和 zsh 的命令行补全:
Usage: mihomosh shell-completion <SHELL>
Arguments:
<SHELL> Target shell name [possible values: bash, elvish, fish, powershell, zsh]
Options:
-h, --help Print help
执行命令后,mihomosh 会输出对应 Shell 的补全脚本,请参考对应 Shell 的文档来安装这个脚本
例如 Bash,你需要在 .bashrc 中添加以下代码:
eval "$(mihomosh shell-completion bash)"
有些代理组可以手动选择使用的代理(如 GLOBAL 代理组选择使用的全局代理),你可以使用如下命令:
$ mihomosh proxy update
$ claude mcp add mihomosh \
-- python -m otcore.mcp_server <graph>