# ClashTUI Usage ## Configuration of ClashTUI The configuration file path is `~/.config/clashtui/config.yaml`. ```yaml # The parameters below correspond to the command -d -f basic: clash_config_dir: '/opt/clashtui/mihomo_config' clash_bin_path: '/usr/bin/mihomo' clash_config_path: '/opt/clashtui/config.yaml' timeout: null # Timeout for simulated clash_ua download. `null` means no timeout. Unit is `seconds`. service: clash_srv_name: 'mihomo' # systemctl {restart | stop} is_user: false # true: systemctl --user ... extra: edit_cmd: 'alacritty -e nvim "%s"' # `%s` will be replaced with the corresponding file path. If empty, use `xdg-open` to open the file. open_dir_cmd: 'alacritty -e ranger "%s"' ``` ## Shortcuts Press `?` to display help. ## Portable Mode Create a folder named `data` in the directory where the ClashTUI program is located. Data will then be stored in the `data` folder instead of `~/.config/clashtui`. ## Combining with cronie for Scheduled Profile Updates ```sh clashtui -u # Update all profiles in command-line mode. If a profile has proxy-providers, they will also be updated. ``` This can be combined with cronie for scheduled profile updates: ```sh # crontab -e 0 10,14,16,22 * * * /usr/bin/env clashtui -u >> ~/cron.out 2>&1 ``` For using cronie, see [ref](https://wiki.archlinuxcn.org/wiki/Cron). ## ClashTUI File Structure `~/.config/clashtui`: - basic_clash_config.yaml: Stores the basic fields for the mihomo configuration. These fields will be merged into `clash_cfg_path`. - config.yaml: Configuration for the ClashTUI program. - templates/template_proxy_providers: Stores proxy subscriptions used by templates. clash_config_path: The final configuration used by mihomo. Basic fields of the mihomo configuration: Apart from the fields "proxy-groups", "proxy-providers", "proxies", "sub-rules", "rules", and "rule-providers", all other fields are considered basic fields. ## Template Prerequisite: Familiarity with [mihomo configuration](https://wiki.metacubex.one/config/) and YAML syntax. ### Proxy-Providers Template Purpose: Generates a proxy-provider for each subscription in `template_proxy_providers`. For example: ```yaml proxy-anchor: - delay_test: &pa_dt {url: https://www.gstatic.com/generate_204, interval: 300} - proxy_provider: &pa_pp {interval: 3600, health-check: {enable: true, url: https://www.gstatic.com/generate_204, interval: 300}} proxy-providers: provider: tpl_param: type: http # The type field must be placed here, not in pa_pp. The reason is that ClashTUI uses this field to detect if it is a network resource. <<: *pa_pp ``` ### Proxy-Groups Template Purpose: Generates a Proxy-Group for each proxy-provider created by the Proxy-Providers template. ```yaml proxy-groups: - name: "Select" tpl_param: providers: ["provider"] type: select - name: "Auto" tpl_param: providers: ["provider"] type: url-test <<: *pa_dt ``` ### Using Proxy-Groups Template Use `<>` to enclose the name of the Proxy-Group template to utilize each proxy-group generated by the Proxy-Group template. For example: ```yaml proxy-groups: - name: "Entry" type: select proxies: - -