Dotfile templates

Toml Bombadil uses the tera templating engine. Turning dotfiles into templates is meant to make theme editing, environment managment and ricing smoother.

Source variables

To use variables in bombadil you need to source your variable files in bombadil's config :

[settings]
vars = [ "vars.toml" ]

You can split variables into multiple files :

[settings]
vars = [ "colors.toml", "env_vars.toml" ]

Declare variables

A Bombadil var files is a toml file containing key with string values only.

For example, you have the following file in {dotfiles_dir}/vars.toml.

terminal = "alacritty"
background = "#292C3E"
foreground = "#EBEBEB"
text = "#FF261E"
cursor = "#FF261E"
black = "#0d0d0d"
red = "#FF301B"
green = "#A0E521"
yellow = "#FFC620"
blue = "#1BA6FA"

# A flag to conditionally include some block of configuration.
set_cursor_color = "true"

Given the following dot entry :

[settings.dots]
alacritty = { source = "alacritty.yml", target = ".config/alacritty/alacritty.yml" }

The source attributes point to a template dotfile named alacritty.yaml. We can use the previously defined variables using the {{variable_name}} syntax :

# {dotfiles}/alacritty.yml
colors:
   primary:
       background: "{{background}}"
       foreground: "{{foreground}}"
{%- if set_cursor_color == "true" %}
   cursor:
       text: "{{text}}"
       cursor: "{{cursor}}"
{% endif -%}

Rendering

To inject your variables, simply run bombadil link. Templates will be rendered to the .dots directory, then symlinked according to your dots config.

In the previous example the output file actually linked to alacritty's config would look like this:

...
# {dotfiles}/.dots/alacritty.yml
colors:
  primary:
    background: "#292C3E"
    foreground: "#EBEBEB"
  cursor:
    text: "#FF261E"
    cursor: "#FF261E"
# ...

In the next section we will see how to organize our variables to make reusable structured themes using variable references.