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
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:
[global] hostname_sep = "QwQ"
Or for a group only:
[[local]] hostname_sep = "QwQ"
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:
[[local]] 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
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):
~/dt/ ├── alacritty/ │ ├── alacritty.yml@@laptop │ └── alacritty.yml@@workstation ├── nvim/ │ ├── init.vim │ └── ... └── ...
You want to sync all stuff under the directory
~/.config, you can populate your config files safely with:
[[local]] 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
.* 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
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:
[[local]] 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@@workstation), see the Error Handling section for more details on this.