Host-specific Configuration

When you want to maintain multiple configurations for different machines, you will have to deal with host-specific syncing. This section describes how to use this feature of dt-cli properly.


First, you have to define a hostname_sep in your config file (or not, the default value @@ has a good chance at fitting your need), globally or per-group, for example, you want your hostname separator to be QwQ by default:

hostname_sep = "QwQ"

Or for a group only:

hostname_sep = "QwQ"

Source Items

Knowing what your hostname_sep is, you can now specify your source items.

dt-cli automatically deals with the logic for host-specific syncing, thus you should not contain a hostname suffix when specifying your sources.


For example, you want to sync some user-scope systemd services on your machines:

name = "SystemD-services"
basedir = "~/dt/systemd/user"
sources = ["*.service"]
target = "~/.config/systemd/user"

hostname_sep = "@@"

Then, on one of your machines, whose hostname is elbert, for example, the above basedir will be automatically expanded to ~/dt/systemd/user@@elbert first, if the expanded basedir exists, dt-cli will uses the expanded version; If the expanded basedir does not exist, dt-cli will sync the original basedir when it exists.


Another real-world example is when you are using the same terminal emulator on multiple machines, your workstation has a 8K ultra monitor, while your laptop at home only has a monitor sized 14 inches. You will not want to have the same font sizes on the two machines.

What you could do is to separately maintain two versions of config files for the terminal emulator. When your configs are maintained under the ~/dt directory, and you are using Alacritty (for example):

├── alacritty/
│   ├── alacritty.yml@@laptop
│   └── alacritty.yml@@workstation
├── nvim/
│   ├── init.vim
│   └── ...
└── ...

You want to sync all stuff under the directory ~/dt to ~/.config, you can populate your config files safely with:

name = "All-my-configs-including-for-terminal-emulator"
basedir = "~/dt"
sources = [
target = "~/.config"


dt-cli will panic (not a bug) if you use globbing patterns like .* or /path/to/something/.*, because .* also expands to the parent directory, which is almost never what you want.

The globbing patterns in the above sources array is the recommended way to glob all items under a given basedir.

Note that we did not specifically reference the alacritty directory anywhere in the above config, because dt-cli will recursively expand directories and automatically handle host-specific items in the expanded paths. You can also specify a source only, like below:

name = "Alacritty"
basedir = "~/.dt/alacritty"
sources = ["alacritty.yml"]
target = "~/.config/alacritty"


Do NOT include the host-specific part in the sources array (like alacritty.yml@@laptop or alacritty.yml@@workstation), see the Error Handling section for more details on this.