Skip to content

Commit

Permalink
docs: add templating feature docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gszr committed Mar 3, 2024
1 parent 2c7a6b5 commit a60babb
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ map:
respectively (the default is a symlink)
* `os`: restricts the OS where the mapping applies; can be `linux`, `macos` or
`all` - if not specified, `all` is implied
* `with`: valid only `as: copy` is used; lists variables whose values are replaced
in the input file's contents using the [Go templating engine](https://pkg.go.dev/text/template).
Currently, the feature exposes the only `.Os` variable within `with` values.

### Examples

Another example:
```
map:
i3:
Expand Down Expand Up @@ -73,6 +77,33 @@ $ tree .
└── dot.yml
```

#### The templating feature

Some system utilities have built-in support for simple variable substitutions through
environment variables, while others do not. In these cases, one can use `dot`'s templating
feature to allow for customizations.

Let's take the following dots spec as an example:

```
map:
gnupg/gpg-agent.conf:
as: copy
with:
PinentryPrefix: '{{if eq .Os "darwin"}}/opt/homebrew/bin{{else}}/usr/bin{{end}}'
```

The contents of `gnupg/gpg-agent.conf` look like the following:
```
default-cache-ttl 1800
max-cache-ttl 3600
enable-ssh-support
pinentry-program {{.PinentryPrefix}}/pinentry-tty
```

This will result in the correct path to `pinentry-tty` being set during the dot
file mapping process.

## Features

- [x] Map source to inferred destination (`file` to `~/.file`)
Expand Down

0 comments on commit a60babb

Please sign in to comment.