ClashTui is a terminal-based user interface (TUI) tool designed to manage and interact with Mihomo (Clash.Meta) proxy services. It provides a cross-platform solution for configuring, monitoring, and automating tasks related to proxy management.
Key Features:
Cross-platform support for Linux and Windows.
User-friendly TUI interface for easy navigation and interaction.
Integration with Mihomo service for managing proxies and configurations.
Profile import functionality to add new proxy links or resources.
Scheduled updates via cronie for automated profile refreshes.
Configuration templates to streamline setup and customization.
Audience & Benefit:
Ideal for users familiar with Clash configurations who seek a terminal-based solution for efficient proxy management. ClashTui allows seamless interaction with Mihomo, enabling automation, configuration, and monitoring directly from the command line. It is particularly beneficial for users preferring TUI applications or those seeking to simplify their workflow in managing proxies.
This software can be installed via winget, ensuring easy setup across supported platforms.
# ## Install mihomo
paru -S mihomo
# ## Add mihomo hook
# cat /etc/pacman.d/hooks/mihomo.hook (If there is no system similar to hook, use ClashSrvCtl Tab's SetPermission or use mihomo@root service)
[Trigger]
Operation = Install
Operation = Upgrade
Type = Path
Target = usr/bin/mihomo
[Action]
When = PostTransaction
Exec = /usr/bin/setcap 'cap_net_admin,cap_net_bind_service=+ep' /usr/bin/mihomo
# ## Edit mihomo service unit
# systemctl edit mihomo
[Service]
# Remove original ExecStart
ExecStart=
ExecStart=/usr/bin/mihomo -d /srv/mihomo -f /srv/mihomo/config.yaml
# ## Create /srv/mihomo
mkdir /srv/mihomo
cd /srv/mihomo
chown -R mihomo:mihomo /srv/mihomo
usermod -a -G mihomo
groups # Check if already added to mihomo group
# Optional. After version 0.2.0, clashtui will automatically fix file permissions.
chmod g+w /srv/mihomo # clashtui needs permission to create files.
chmod g+s /srv/mihomo # Make the group of files created by clashtui mihomo. This is to give clashtui group read and write permissions to files in this directory.
chmod g+w /srv/mihomo/config.yaml # clashtui needs write permission.
# ## Set mihomo service unit
systemctl enable mihomo # Start on boot
systemctl restart mihomo # Start service
It is recommended to test the mihomo service with a valid configuration to ensure its success. Check if meta-rules-dat file is missing.
# ## Install clashtui
# There is a latest [PKGBUILD](./PkgManagers/PKGBUILD).
paru -S clashtui. # For other Linux distributions, manually download and place clashtui in PATH.
# ## Configure clashtui
clashtui # Running this will generate some default files in ~/.config/clashtui.
# nvim ~/.config/clashtui/config.yaml
# The following parameters correspond to the command -d -f
basic:
clash_config_dir: '/srv/mihomo'
clash_bin_path: '/usr/bin/mihomo'
clash_config_path: '/srv/mihomo/config.yaml'
timeout: null # the timeout duration for downloading via clash_ua. `null` means no timeout. The unit is `seconds`.
service:
clash_srv_name: 'mihomo' # systemctl {restart | stop}
is_user: false # true: systemctl --user ...
extra:
edit_cmd: ''
open_dir_cmd: ''
clash_core_path: "/usr/bin/mihomo"
clash_cfg_dir: "/srv/mihomo"
clash_cfg_path: "/srv/mihomo/config.yaml"
clash_srv_name: "mihomo" # systemctl {restart | stop}
clash_srv_is_user: false # true: systemctl --user ...
timeout: 0
The subsequent versions of clashtui have not been uploaded to crates.io because clashtui is now separated into multiple modules. If uploaded to crates.io, it would require uploading each dependent module, and some modules do not need to be uploaded to crates.io. See ref. So, do not use cargo install clashtui for installation.
Configure basic_clash_config.yaml
Configure ~/.config/clashtui/basic_clash_config.yaml manually. Some basic fields in this file will be merged into clash_cfg_path. Refer to here for configuring tun mode.
Portable Mode
Create a folder named data in the directory where clashtui program resides. Then the data will be placed in data instead of ~/.config/clashtui.
Usage Instructions
Press ? to display help.
Importing Links
Import profile: In the Profile area, press i to input Name (preferably without suffix) and Uri (url or file path).
Update profile: Press a to update all resources dependent on the Profile. By default, it uses its own proxy for updates. If tun mode or system proxy is enabled and there are no available nodes, stop the mihomo service first (ClashSrvCtl Tab's StopClashService), then update.
Select profile: Press Enter to select the Profile.
Open mihomo ui: Enter http://127.0.0.1:9090/ui in the browser. Provided your mihomo configuration has already set up ui related fields, reference.
If it is the first time installing clashtui:
If you have changed the basic_clash_config or other configurations, restart clashtui to reparse the changes in basic_clash_config, etc.
Import a profile that does not require updating with a proxy.
Press a to update all resources dependent on the profile.
Press Enter to select this profile, merging the fields of basic_clash_config into clash_cfg_path.
Restart the mihomo service (StartClashService in ClashSrvCtl Tab).
Scheduled Updates with cronie
clashtui -u # Updates all profiles in command-line mode. If the profile has proxy-providers, they will also be updated.
Generate a proxy-provider for each link in template_proxy_providers:
proxy-providers:
provider:
tpl_param:
type: http # type field must be placed here, not within pa_pp. This is because clashtui detects if it is a network resource based on this field.
<<: *pa_pp
Generate a Select, Auto proxy-group for each proxy-providers:
This project is for learning and reference purposes only. The author does not guarantee the accuracy, completeness, or applicability of the code in the project. Users should use the code in this project at their own risk.
The author is not responsible for any direct or indirect losses caused by the use of the code in this project, including but not limited to data loss, computer damage, and business interruption.
Before using the code in this project, users should fully understand its functionality and potential risks, and seek professional advice if necessary. The author is not liable for any consequences resulting from the use of the code in this project.
When using the code in this project, please comply with relevant laws and regulations, and refrain from using it for illegal activities or activities that infringe upon the rights of others.
The author reserves the right of final interpretation of this disclaimer, and may modify and update it at any time.