dot-files repo is a repo to hold all my dot files or config files from various programs like nvim, wezterm, tmux, etc., files like bashrc, and more. They could be single files or dirs. Basically just a big collection of my config files for various programs. tools/dot-files-tool is a tool to read files/dirs from various locations and copy them into data dir. dot-files-tool requires tools/config.toml to be present. This file contains data for files/dirs that need to be backed up. tools/config.toml.
- Clone repo and cd into tools dir.
- Edit
tools/config.tomlto mention files and dirs you want to backup. It is important for config file to remain in tools dir. Check Config Files section to understand the config file format. - Once config file is ready, run
tools/dot-files-toolbinary. Data will be copied and pasted into data dir.
NOTE: After the copying is done the tool uses betterleaks to scan all the files in the data dir to check for accidental leaks (API keys, OAuth tokens, etc.). If a leak is found, we don't wanna commit and push these changes, so the entire data dir gets wiped and the user is informed about which files contain leaks so that user can either fix the leaks or exclude the files and then rerun dot-files-tool.
The tools/config.toml file hold all files and dirs that need to be copied. The whole file is an array of tables, each table is a config item. Each config item has four fields:
- name: Name of item
- desc: Description of item
- item_type: Type of item. Must be "file" or "dir"
- path: Path of file/dir
Here is the format for a config item:
[[config_items]]
name = "abc"
desc = "This is a file"
item_type = "file"
path = "path/to/file-or-dir"
There is a template config item available at the top of the config file. Copy that to create new items.
VERY IMPORTANT: First config item must ALWAYS be the template because the code skips the first item.
- When developing and testing use
cargo run --bin dot-files-tool. Replace bin name with name of whatever script you are currently prototyping in. - When compiling final binary, use cargo build with release flag, then copy the resulting binary into 'tools' dir, and then run the binary from the new location to test it.
cargo build --bin dot-files-tool --release && cp target/release/dot-files-tool ../tools/dot-files-tool && ../tools/dot-files-tool