mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 18:34:48 +00:00
documentation
This commit is contained in:
95
docs/config/config-actions.md
vendored
Normal file
95
docs/config/config-actions.md
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
# Actions entry
|
||||
|
||||
The **actions** entry (optional) contains an actions mapping.
|
||||
|
||||
```yaml
|
||||
actions:
|
||||
<action-key>: <command-to-execute>
|
||||
```
|
||||
|
||||
*pre* actions:
|
||||
```yaml
|
||||
actions:
|
||||
pre:
|
||||
<action-key>: <command-to-execute>
|
||||
```
|
||||
|
||||
*post* actions:
|
||||
```yaml
|
||||
actions:
|
||||
post:
|
||||
<action-key>: <command-to-execute>
|
||||
```
|
||||
|
||||
Actions can be either `post` or `pre`.
|
||||
|
||||
* `post` action will be executed after the dotfile deployment.
|
||||
* `pre` action will be executed before the dotfile deployment.
|
||||
|
||||
If you don't specify either `post` or `pre`, the action will be executed
|
||||
after the dotfile deployment (which is equivalent to `post`).
|
||||
Actions cannot obviously be named `pre` or `post`.
|
||||
|
||||
Four types of actions can be defined:
|
||||
|
||||
* [Dotfiles actions](config-dotfiles.md#dotfile-actions)
|
||||
* [Default actions](config-config.md#default_actions-entry)
|
||||
* [Profile actions](config-profiles.md#profile-actions-entry)
|
||||
* [Fake dotfiles and actions](config-actions.md#fake-dotfile-and-actions)
|
||||
|
||||
**Notes**:
|
||||
|
||||
* Any action with a key starting with an underscore (`_`) won't be shown in output. This can be useful when working with sensitive data containing passwords, for example.
|
||||
* Make sure to quote your actions to avoid bad surprises
|
||||
* Actions are executed using the default shell (`$SHELL`)
|
||||
* To use shell variables in your actions, you need to escape the curly brackets (`${HOME}` becomes `${{HOME}}`)
|
||||
|
||||
## Fake dotfile and actions
|
||||
|
||||
*Fake* dotfile can be created by specifying no `dst` and no `src` (see [Fake dotfiles and actions](config-actions.md#fake-dotfile-and-actions)).
|
||||
By binding an action to such a *fake* dotfile, you make sure the action is always executed since
|
||||
*fake* dotfile are always considered installed.
|
||||
|
||||
```yaml
|
||||
actions:
|
||||
always_action: 'date > ~/.dotdrop.log'
|
||||
dotfiles:
|
||||
fake:
|
||||
src:
|
||||
dst:
|
||||
actions:
|
||||
- always_action
|
||||
```
|
||||
|
||||
## Dynamic actions
|
||||
|
||||
Variables ([config variables and dynvariables](config-file.md#variables)
|
||||
and [template variables](../templating.md#template-variables)) can be used
|
||||
in actions for more advanced use-cases.
|
||||
|
||||
```yaml
|
||||
dotfiles:
|
||||
f_test:
|
||||
dst: ~/.test
|
||||
src: test
|
||||
actions:
|
||||
- cookie_mv_somewhere "/tmp/moved-cookie"
|
||||
variables:
|
||||
cookie_dir_available: (test -d /tmp/cookiedir || mkdir -p /tmp/cookiedir)
|
||||
cookie_header: "{{@@ cookie_dir_available @@}} && echo 'header' > /tmp/cookiedir/cookie"
|
||||
cookie_mv: "{{@@ cookie_header @@}} && mv /tmp/cookiedir/cookie"
|
||||
actions:
|
||||
cookie_mv_somewhere: "{{@@ cookie_mv @@}} {0}"
|
||||
```
|
||||
|
||||
or even something like this:
|
||||
```yaml
|
||||
actions:
|
||||
log: "echo {0} >> {1}"
|
||||
config:
|
||||
default_actions:
|
||||
- preaction '{{@@ _dotfile_key @@}} installed' "/tmp/log"
|
||||
...
|
||||
```
|
||||
|
||||
Make sure to quote the actions using variables.
|
||||
215
docs/config/config-config.md
vendored
Normal file
215
docs/config/config-config.md
vendored
Normal file
@@ -0,0 +1,215 @@
|
||||
# Config block
|
||||
|
||||
The **config** entry (mandatory) contains global settings.
|
||||
|
||||
Entry | Description | Default
|
||||
-------- | ------------- | ------------
|
||||
`backup` | Create a backup of the dotfile in case it differs from the one that will be installed by dotdrop | true
|
||||
`banner` | Display the banner | true
|
||||
`check_version` | Check if a new version of dotdrop is available on github | false
|
||||
`chmod_on_import` | Always add a chmod entry on newly imported dotfiles (see `--preserve-mode`) | false
|
||||
`clear_workdir` | On `install` clear the `workdir` before installing dotfiles (see `--workdir-clear`) | false
|
||||
`compare_workdir` | On `compare` notify on files in `workdir` not tracked by dotdrop | false
|
||||
`cmpignore` | List of patterns to ignore when comparing, applied to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns)) | -
|
||||
`create` | Create a directory hierarchy when installing dotfiles if it doesn't exist | true
|
||||
`default_actions` | List of action keys to execute for all installed dotfiles (See [actions](config-actions.md)) | -
|
||||
`diff_command` | The diff command to use for diffing files | `diff -r -u {0} {1}`
|
||||
`dotpath` | Path to the directory containing the dotfiles to be managed by dotdrop (absolute path or relative to the config file location) | `dotfiles`
|
||||
`filter_file` | List of paths to load templating filters from (See [Templating available filters](../templating.md#template-filters)) | -
|
||||
`force_chmod` | If true, do not ask confirmation to apply permissions on install | false
|
||||
`func_file` | List of paths to load templating functions from (See [Templating available methods](../templating.md#template-methods)) | -
|
||||
`ignore_missing_in_dotdrop` | Ignore missing files in dotdrop when comparing and importing (See [Ignore missing](config-file.md#ignore-missing)) | false
|
||||
`ignoreempty` | Do not deploy template if empty | false
|
||||
`impignore` | List of patterns to ignore when importing (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns)) | -
|
||||
`import_actions` | List of paths to load actions from (absolute path or relative to the config file location; see [Import actions from file](config-config.md#import_actions-entry)) | -
|
||||
`import_configs` | List of config file paths to be imported into the current config (absolute paths or relative to the current config file location; see [Import config files](config-config.md#import_configs-entry)) | -
|
||||
`import_variables` | List of paths to load variables from (absolute paths or relative to the config file location; see [Import variables from file](config-config.md#import_variables-entry)) | -
|
||||
`instignore` | List of patterns to ignore when installing, applied to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns)) | -
|
||||
`keepdot` | Preserve leading dot when importing hidden file in the `dotpath` | false
|
||||
`key_prefix` | Prefix dotfile key on `import` with `f<key_separator>` for file and `d<key_separator>` for directory | true
|
||||
`key_separator` | Separator to use on dotfile key generation on `import` | `_`
|
||||
`link_dotfile_default` | Set a dotfile's `link` attribute to this value when undefined. Possible values: *nolink*, *absolute*, *relative* (See [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) | `nolink`
|
||||
`link_on_import` | Set a dotfile's `link` attribute to this value when importing. Possible values: *nolink*, *absolute*, *relative* [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) | `nolink`
|
||||
`longkey` | Use long keys for dotfiles when importing (See [Import dotfiles](../usage.md#import-dotfiles)) | false
|
||||
`minversion` | (*for internal use, do not modify*) Provides the minimal dotdrop version to use | -
|
||||
`showdiff` | On install, show a diff before asking to overwrite (See `--showdiff`) | false
|
||||
`template_dotfile_default` | Disable templating on all dotfiles when set to false | true
|
||||
`upignore` | List of patterns to ignore when updating, appled to all dotfiles (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns)) | -
|
||||
`workdir` | Path to the directory where templates are installed before being symlinked when using `link:absolute|relative|link_children` (absolute path or relative to the config file location) | `~/.config/dotdrop`
|
||||
<s>link_by_default</s> | When importing a dotfile, set `link` to this value by default | false
|
||||
|
||||
|
||||
## import_variables entry
|
||||
|
||||
It is possible to load variables/dynvariables from external files by providing their
|
||||
paths in the config entry `import_variables`.
|
||||
|
||||
The paths can be absolute or relative to the config file location.
|
||||
|
||||
`config.yaml`
|
||||
```yaml
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
import_variables:
|
||||
- variables.d/myvars.yaml
|
||||
```
|
||||
|
||||
`variables.d/myvars.yaml`
|
||||
```yaml
|
||||
variables:
|
||||
var1: "extvar1"
|
||||
dynvariables:
|
||||
dvar1: "echo extdvar1"
|
||||
```
|
||||
|
||||
Dotdrop will fail if an imported path points to a non-existing file.
|
||||
It is possible to make non-existing paths not fatal by appending `:optional` to the path:
|
||||
```yaml
|
||||
import_variables:
|
||||
- variables.d/myvars.yaml:optional
|
||||
```
|
||||
|
||||
## import_actions entry
|
||||
|
||||
It is possible to load actions from external files by providing their
|
||||
paths in the config entry `import_actions`.
|
||||
|
||||
The paths can be absolute or relative to the config file location.
|
||||
|
||||
`config.yaml`
|
||||
```yaml
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
import_actions:
|
||||
- actions.d/myactions.yaml
|
||||
dotfiles:
|
||||
f_abc:
|
||||
dst: ~/.abc
|
||||
src: abc
|
||||
actions:
|
||||
- dateme
|
||||
```
|
||||
|
||||
`actions.d/myactions.yaml`
|
||||
```yaml
|
||||
actions:
|
||||
dateme: date > /tmp/timestamp
|
||||
```
|
||||
|
||||
External/imported variables will take precedence over variables defined
|
||||
inside the main config file.
|
||||
|
||||
Dotdrop will fail if an imported path points to a non-existing file.
|
||||
It is possible to make non-existing paths not fatal by appending `:optional` to the path:
|
||||
```yaml
|
||||
import_actions:
|
||||
- actions.d/myactions.yaml:optional
|
||||
```
|
||||
|
||||
## import_configs entry
|
||||
|
||||
Entire config files can be imported using the `import_configs` entry.
|
||||
This means making the following available from the imported config file in the original config file:
|
||||
|
||||
* dotfiles
|
||||
* profiles
|
||||
* actions
|
||||
* read/write transformations
|
||||
* variables/dynvariables
|
||||
|
||||
Paths to import can be absolute or relative to the importing config file
|
||||
location.
|
||||
|
||||
`config.yaml`
|
||||
```yaml
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
import_configs:
|
||||
- other-config.yaml
|
||||
dotfiles:
|
||||
f_abc:
|
||||
dst: ~/.abc
|
||||
src: abc
|
||||
actions:
|
||||
- show
|
||||
profiles:
|
||||
my-host:
|
||||
dotfiles:
|
||||
- f_abc
|
||||
- f_def
|
||||
my-haskell:
|
||||
include:
|
||||
- other-host
|
||||
```
|
||||
|
||||
`other-config.yaml`
|
||||
```yaml
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles-other
|
||||
import_actions:
|
||||
- actions.yaml
|
||||
dotfiles:
|
||||
f_def:
|
||||
dst: ~/.def
|
||||
src: def
|
||||
f_ghci:
|
||||
dst: ~/.ghci
|
||||
src: ghci
|
||||
profiles:
|
||||
other-host:
|
||||
dotfiles:
|
||||
- f_gchi
|
||||
```
|
||||
|
||||
`actions.yaml`
|
||||
```yaml
|
||||
actions:
|
||||
post:
|
||||
show: less
|
||||
```
|
||||
|
||||
In this example, `config.yaml` imports `other-config.yaml`. The dotfile `f_def`
|
||||
used in the profile `my-host` is defined in `other-config.yaml`, and so is the
|
||||
profile `other-host` included from `my-haskell`. The action `show` is defined
|
||||
in `actions.yaml`, which is in turn imported by `other-config.yaml`.
|
||||
|
||||
Dotdrop will fail if an imported path points to a non-existing file.
|
||||
It is possible to make non-existing paths not fatal by appending `:optional` to the path.
|
||||
```yaml
|
||||
import_configs:
|
||||
- other-config.yaml:optional
|
||||
```
|
||||
|
||||
## default_actions entry
|
||||
|
||||
Dotdrop allows to execute an action for any dotfile installation. These actions work as any other action (`pre` or `post`).
|
||||
|
||||
For example, the below action will log each dotfile installation to a file.
|
||||
|
||||
```yaml
|
||||
actions:
|
||||
post:
|
||||
loginstall: "echo {{@@ _dotfile_abs_src @@}} installed to {{@@ _dotfile_abs_dst @@}} >> {0}"
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
default_actions:
|
||||
- loginstall "/tmp/dotdrop-installation.log"
|
||||
dotfiles:
|
||||
f_vimrc:
|
||||
dst: ~/.vimrc
|
||||
src: vimrc
|
||||
profiles:
|
||||
hostname:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
```
|
||||
218
docs/config/config-dotfiles.md
vendored
Normal file
218
docs/config/config-dotfiles.md
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
# Dotfiles block
|
||||
|
||||
The **dotfiles** entry (mandatory) contains a YAML object with sub-objects for the dotfiles managed by dotdrop. The entries in the sub-objects are as follows:
|
||||
|
||||
Entry | Description
|
||||
-------- | -------------
|
||||
`dst` | Where this dotfile needs to be deployed (dotfiles with empty `dst` are ignored and considered installed, can use `variables`, make sure to quote)
|
||||
`src` | Dotfile path within the `dotpath` (dotfiles with empty `src` are ignored and considered installed, can use `variables`, make sure to quote)
|
||||
`link` | Defines how this dotfile is installed. Possible values: *nolink*, *absolute*, *relative*, *link_children* (See [Symlinking dotfiles](config-file.md#symlinking-dotfiles)) (defaults to value of `link_dotfile_default`)
|
||||
`actions` | List of action keys that need to be defined in the **actions** entry below (See [actions](config-actions.md))
|
||||
`chmod` | Defines the file permissions in octal notation to apply during installation (See [permissions](config-file.md#permissions))
|
||||
`cmpignore` | List of patterns to ignore when comparing (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns))
|
||||
`ignore_missing_in_dotdrop` | Ignore missing files in dotdrop when comparing and importing (see [Ignore missing](config-file.md#ignore-missing))
|
||||
`ignoreempty` | If true, an empty template will not be deployed (defaults to the value of `ignoreempty`)
|
||||
`instignore` | List of patterns to ignore when installing (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns))
|
||||
`template` | If false, disable templating for this dotfile (defaults to the value of `template_dotfile_default`)
|
||||
`trans_read` | Transformation key to apply when installing this dotfile (must be defined in the **trans_read** entry below; see [transformations](config-transformations.md))
|
||||
`trans_write` | Transformation key to apply when updating this dotfile (must be defined in the **trans_write** entry below; see [transformations](config-transformations.md))
|
||||
`upignore` | List of patterns to ignore when updating (enclose in quotes when using wildcards; see [ignore patterns](config-file.md#ignore-patterns))
|
||||
<s>link_children</s> | Replaced by `link: link_children`
|
||||
<s>trans</s> | Replaced by `trans_read`
|
||||
|
||||
```yaml
|
||||
<dotfile-key-name>:
|
||||
dst: <where-this-file-is-deployed>
|
||||
src: <filename-within-the-dotpath>
|
||||
## Optional
|
||||
link: (nolink|absolute|relative|link_children)
|
||||
ignoreempty: (true|false)
|
||||
cmpignore:
|
||||
- "<ignore-pattern>"
|
||||
upignore:
|
||||
- "<ignore-pattern>"
|
||||
instignore:
|
||||
- "<ignore-pattern>"
|
||||
actions:
|
||||
- <action-key>
|
||||
template: (true|false)
|
||||
chmod: '<file-permissions>'
|
||||
trans_read: <transformation-key>
|
||||
trans_write: <transformation-key>
|
||||
```
|
||||
|
||||
## Dotfile actions
|
||||
|
||||
It is sometimes useful to execute some kind of action
|
||||
when deploying a dotfile.
|
||||
|
||||
Note that a dotfile's actions are only
|
||||
executed when the dotfile is installed (that is, when
|
||||
the version present in dotdrop differs from the one
|
||||
in the filesystem).
|
||||
|
||||
For example, let's consider
|
||||
[Vundle](https://github.com/VundleVim/Vundle.vim), used
|
||||
to manage Vim's plugins. The following action could
|
||||
be set to update and install the plugins when `vimrc` is
|
||||
deployed:
|
||||
|
||||
```yaml
|
||||
actions:
|
||||
vundle: vim +VundleClean! +VundleInstall +VundleInstall! +qall
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
dotfiles:
|
||||
f_vimrc:
|
||||
dst: ~/.vimrc
|
||||
src: vimrc
|
||||
actions:
|
||||
- vundle
|
||||
profiles:
|
||||
home:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
```
|
||||
|
||||
Thus, when `f_vimrc` is installed, the command
|
||||
`vim +VundleClean! +VundleInstall +VundleInstall! +qall` will
|
||||
be executed.
|
||||
|
||||
Sometimes, you may even want to execute some action prior to deploying a dotfile.
|
||||
Let's take another example with
|
||||
[vim-plug](https://github.com/junegunn/vim-plug):
|
||||
|
||||
```yaml
|
||||
actions:
|
||||
pre:
|
||||
vim-plug-install: test -e ~/.vim/autoload/plug.vim || (mkdir -p ~/.vim/autoload; curl
|
||||
-fLo ~/.vim/autoload/plug.vim https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim)
|
||||
vim-plug: vim +PlugInstall +qall
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
dotfiles:
|
||||
f_vimrc:
|
||||
dst: ~/.vimrc
|
||||
src: vimrc
|
||||
actions:
|
||||
- vim-plug-install
|
||||
- vim-plug
|
||||
profiles:
|
||||
home:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
```
|
||||
|
||||
This way, we make sure [vim-plug](https://github.com/junegunn/vim-plug)
|
||||
is installed prior to deploying the `~/.vimrc` dotfile.
|
||||
|
||||
You can also define `post` actions like this:
|
||||
|
||||
```yaml
|
||||
actions:
|
||||
post:
|
||||
some-action: echo "Hello, World!" >/tmp/log
|
||||
```
|
||||
|
||||
Actions can even be parameterized. For example:
|
||||
|
||||
```yaml
|
||||
actions:
|
||||
echoaction: echo '{0}' > {1}
|
||||
config:
|
||||
backup: true
|
||||
create: true
|
||||
dotpath: dotfiles
|
||||
dotfiles:
|
||||
f_vimrc:
|
||||
dst: ~/.vimrc
|
||||
src: vimrc
|
||||
actions:
|
||||
- echoaction "vim installed" /tmp/mydotdrop.log
|
||||
f_xinitrc:
|
||||
dst: ~/.xinitrc
|
||||
src: xinitrc
|
||||
actions:
|
||||
- echoaction "xinitrc installed" /tmp/myotherlog.log
|
||||
profiles:
|
||||
home:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
- f_xinitrc
|
||||
```
|
||||
|
||||
The above will execute `echo 'vim installed' > /tmp/mydotdrop.log` when
|
||||
vimrc is installed and `echo 'xinitrc installed' > /tmp/myotherlog.log'`
|
||||
when xinitrc is installed.
|
||||
|
||||
## Dynamic dotfile paths
|
||||
|
||||
Dotfile source (`src`) and destination (`dst`) paths can be dynamically constructed using
|
||||
defined variables ([variables and dynvariables](config-file.md#variables)).
|
||||
|
||||
For example, to have a dotfile deployed on a unique Firefox profile where the
|
||||
profile path is dynamically found using a shell oneliner stored in a dynvariable:
|
||||
```yaml
|
||||
dynvariables:
|
||||
mozpath: find ~/.mozilla/firefox -name '*.default'
|
||||
dotfiles:
|
||||
f_somefile:
|
||||
dst: "{{@@ mozpath @@}}/somefile"
|
||||
src: firefox/somefile
|
||||
profiles:
|
||||
home:
|
||||
dotfiles:
|
||||
- f_somefile
|
||||
```
|
||||
|
||||
Or when you need to select the dotfile to deploy depending on
|
||||
the profile used (`ssh_config.perso` for the profile `perso` and
|
||||
`ssh_config.work` for the `work` profile):
|
||||
```yaml
|
||||
dotfiles:
|
||||
f_ssh_config:
|
||||
src: "{{@@ ssh_config_file @@}}"
|
||||
dst: ~/.ssh/config
|
||||
profiles:
|
||||
perso:
|
||||
dotfiles:
|
||||
- f_ssh_config
|
||||
variables:
|
||||
- ssh_config_file: "ssh_config.perso"
|
||||
work:
|
||||
dotfiles:
|
||||
- f_ssh_config
|
||||
variables:
|
||||
- ssh_config_file: "ssh_config.work"
|
||||
```
|
||||
|
||||
## Dynamic dotfile link value
|
||||
|
||||
Dotfile `link` values can be dynamically constructed using
|
||||
defined variables ([variables and dynvariables](config-file.md#variables)).
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
variables:
|
||||
link_value: "nolink"
|
||||
dotfiles:
|
||||
f_test:
|
||||
src: test
|
||||
dst: ~/.test
|
||||
link: "{{@@ link_value @@}}"
|
||||
profiles:
|
||||
linux:
|
||||
dotfiles:
|
||||
- f_test
|
||||
variables:
|
||||
link_value: "absolute"
|
||||
windows:
|
||||
dotfiles:
|
||||
- f_test
|
||||
```
|
||||
|
||||
Make sure to quote the link value in the config file.
|
||||
36
docs/config/config-dynvars.md
vendored
Normal file
36
docs/config/config-dynvars.md
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# Dynvariables entry
|
||||
|
||||
The **dynvariables** entry (optional) contains an interpreted variables mapping.
|
||||
|
||||
```yaml
|
||||
dynvariables:
|
||||
<variable-name>: <shell-oneliner>
|
||||
```
|
||||
|
||||
You can also use multi-line (see [yaml related doc](https://yaml-multiline.info/)).
|
||||
For example:
|
||||
```yaml
|
||||
dynvariables:
|
||||
<variable-name>: >-
|
||||
<line1>
|
||||
<line2>
|
||||
<line3>
|
||||
```
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
dynvariables:
|
||||
dvar1: head -1 /proc/meminfo
|
||||
dvar2: "echo 'this is some test' | rev | tr ' ' ','"
|
||||
dvar3: /tmp/my_shell_script.sh
|
||||
user: "echo $USER"
|
||||
config_file: >-
|
||||
test -f "{{@@ base_config @@}}" &&
|
||||
echo "{{@@ base_config @@}}" ||
|
||||
echo "{{@@ dfl_config @@}}"
|
||||
variables:
|
||||
base_config: "profile_base.yaml"
|
||||
dfl_config: "profile_default.yaml"
|
||||
```
|
||||
|
||||
They have the same properties as [Variables](config-variables.md).
|
||||
328
docs/config/config-file.md
vendored
Normal file
328
docs/config/config-file.md
vendored
Normal file
@@ -0,0 +1,328 @@
|
||||
# Config file
|
||||
|
||||
## Location
|
||||
|
||||
The default config file used by dotdrop is
|
||||
[config.yaml](https://github.com/deadc0de6/dotdrop/blob/master/config.yaml).
|
||||
|
||||
Unless specified otherwise, dotdrop will look in the following places for its config file
|
||||
and use the first one found:
|
||||
|
||||
* Current/working directory or the directory where [dotdrop.sh](https://github.com/deadc0de6/dotdrop/blob/master/dotdrop.sh) is located if used
|
||||
* `${XDG_CONFIG_HOME}/dotdrop/`
|
||||
* `~/.config/dotdrop/`
|
||||
* `/etc/xdg/dotdrop/`
|
||||
* `/etc/dotdrop/`
|
||||
|
||||
You can force dotdrop to use a different file either by using the `-c`/`--cfg` CLI switch
|
||||
or by defining the `DOTDROP_CONFIG` environment variable.
|
||||
|
||||
## Variables
|
||||
|
||||
Multiple variables can be used within the config file to
|
||||
parametrize the following elements of the config:
|
||||
|
||||
* Dotfile `src` and `dst` paths (See [Dynamic dotfile paths](config-dotfiles.md#dynamic-dotfile-paths))
|
||||
* External paths
|
||||
* `import_variables`
|
||||
* `import_actions`
|
||||
* `import_configs`
|
||||
* Profiles' `import`
|
||||
* Profiles' `include`
|
||||
* `actions`
|
||||
* `transformations`
|
||||
|
||||
Note that variables used in `actions` and `transformations`
|
||||
are resolved when the action/transformation is executed
|
||||
(See [Dynamic actions](config-actions.md#dynamic-actions),
|
||||
[Dynamic transformations](config-transformations.md#dynamic-transformations) and [Templating](../templating.md)).
|
||||
|
||||
The following variables are available in the config files:
|
||||
|
||||
* [Variables defined in the config](config-variables.md)
|
||||
* [Interpreted variables defined in the config](config-dynvars.md)
|
||||
* [User variables defined in the config](config-variables.md)
|
||||
* [Profile variables defined in the config](config-profiles.md#profile-variables-entry)
|
||||
* Environment variables: `{{@@ env['MY_VAR'] @@}}`
|
||||
* The [enriched variables](../templating.md#enriched-variables)
|
||||
* Dotdrop header: `{{@@ header() @@}}` (see [Dotdrop header](../templating.md#dotdrop-header))
|
||||
|
||||
as well as all [template methods](../templating.md#template-methods) and [template filters](../templating.md#template-filters).
|
||||
|
||||
Note that all variables available in the config file will
|
||||
then be available during [templating](../templating.md).
|
||||
|
||||
Here are some rules on the use of variables in configs:
|
||||
|
||||
* [dynvariables](config-dynvars.md) are executed in their own file.
|
||||
* [dynvariables](config-dynvars.md) and
|
||||
[variables](config-variables.md) are templated before
|
||||
[dynvariables](config-dynvars.md) are executed.
|
||||
* Config files do not have access to variables defined above in the import tree
|
||||
(variables defined in importing config are not seen by the imported config file,
|
||||
where *import* can be any of `import_configs`, `import_variables`, `import_actions`,
|
||||
profile's `import` and profile's `include`)
|
||||
* [dynvariables](config-dynvars.md) take precedence over [variables](config-variables.md).
|
||||
* Profile `(dyn)variables` take precedence over any other `(dyn)variables`.
|
||||
* Profile `(dyn)variables` take precedence over profile's included `(dyn)variables`.
|
||||
* External/imported `(dyn)variables` take precedence over
|
||||
`(dyn)variables` defined inside the main config file.
|
||||
* [uservariables](config-uservars.md) are ignored if
|
||||
any other variable with the same key is defined.
|
||||
|
||||
For more see the [CONTRIBUTING doc](/CONTRIBUTING.md).
|
||||
|
||||
## Permissions
|
||||
|
||||
Dotdrop allows to control the permissions applied to a dotfile using the
|
||||
config dotfile entry [chmod](config-dotfiles.md).
|
||||
A [chmod](config-dotfiles.md) entry on a directory
|
||||
is applied to the directory only, not recursively.
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
dotfiles:
|
||||
f_file:
|
||||
src: file
|
||||
dst: ~/file
|
||||
chmod: 644
|
||||
f_dir:
|
||||
src: dir
|
||||
dst: ~/dir
|
||||
chmod: 744
|
||||
```
|
||||
|
||||
On `import`, the following rules are applied:
|
||||
|
||||
* If the `-m`/`--preserve-mode` switch is provided or the config option
|
||||
`chmod_on_import` is true, the imported file's permissions are
|
||||
stored in a `chmod` entry
|
||||
* If the imported file's permissions differ from the umask, then the permissions are automatically
|
||||
stored in the `chmod` entry.
|
||||
* Otherwise, no `chmod` entry is added
|
||||
|
||||
On `install`, the following rules are applied:
|
||||
|
||||
* If `chmod` is specified in the dotfile, it will be applied to the installed dotfile.
|
||||
* Otherwise, the permissions of the dotfile in the `dotpath` are applied.
|
||||
* If the global setting `force_chmod` is set to true, dotdrop will not ask
|
||||
for confirmation to apply permissions.
|
||||
|
||||
On `update`, the following rule is applied:
|
||||
|
||||
* If the permissions of the file in the filesystem differ from the dotfile in the `dotpath`,
|
||||
then the dotfile entry `chmod` is added/updated accordingly.
|
||||
|
||||
|
||||
## Symlinking dotfiles
|
||||
|
||||
see the [symlink dotfiles documentation](../howto/symlink-dotfiles.md).
|
||||
|
||||
## Template config entries
|
||||
|
||||
Some entries in the config can be templated (See [templating](../templating.md)):
|
||||
|
||||
Entry | Related doc
|
||||
-------- | -------------
|
||||
dotpath | [config entries](config-config.md#config-block)
|
||||
dotfile src | [dynamic dotfile paths](config-dotfiles.md#dynamic-dotfile-paths)
|
||||
dotfile dst | [dynamic dotfile paths](config-dotfiles.md#dynamic-dotfile-paths)
|
||||
dotfile link | [dynamic dotfile link value](config-dotfiles.md#dynamic-dotfile-link-value)
|
||||
variables | [variables](config-variables.md)
|
||||
dynvariables | [dynvariables](config-dynvars.md)
|
||||
actions | [dynamic actions](config-dynvars.md)
|
||||
profile include | [Profile include](config-profiles.md#profile-include-entry)
|
||||
profile import | [Profile import](config-profiles.md#profile-import-entry)
|
||||
import_variables | [import_variables](config-config.md#import_variables-entry)
|
||||
import_actions | [import_actions](config-config.md#import_actions-entry)
|
||||
import_configs | [import_configs](config-config.md#import_configs-entry)
|
||||
|
||||
## All dotfiles for a profile
|
||||
|
||||
To use all defined dotfiles in a profile, simply use
|
||||
the keyword `ALL`.
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
dotfiles:
|
||||
f_xinitrc:
|
||||
dst: ~/.xinitrc
|
||||
src: xinitrc
|
||||
f_vimrc:
|
||||
dst: ~/.vimrc
|
||||
src: vimrc
|
||||
profiles:
|
||||
host1:
|
||||
dotfiles:
|
||||
- ALL
|
||||
host2:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
```
|
||||
|
||||
## Ignore patterns
|
||||
|
||||
It is possible to ignore specific patterns when using dotdrop.
|
||||
|
||||
* For [install](../usage.md#install-dotfiles):
|
||||
* Using config block [instignore](config-config.md)
|
||||
* Using dotfiles block [instignore](config-dotfiles.md)
|
||||
* For [import](../usage.md#import-dotfiles):
|
||||
* Using config block [impignore](config-config.md)
|
||||
* For [compare](../usage.md#compare-dotfiles):
|
||||
* Using config block [cmpignore](config-config.md)
|
||||
* Using dotfiles block [cmpignore](config-dotfiles.md)
|
||||
* Using the command line switch `-i`/`--ignore`
|
||||
* For [update](../usage.md#update-dotfiles):
|
||||
* Using config block [upignore](config-config.md)
|
||||
* Using dotfiles block [upignore](config-dotfiles.md)
|
||||
* Using the command line switch `-i`/`--ignore`
|
||||
|
||||
The ignore pattern must follow Unix shell-style wildcards, like, for example `*/path/to/file`.
|
||||
Make sure to quote these when using wildcards in the config file.
|
||||
|
||||
```yaml
|
||||
config:
|
||||
cmpignore:
|
||||
- '*/README.md'
|
||||
upignore:
|
||||
- '*/README.md'
|
||||
instignore:
|
||||
- '*/README.md'
|
||||
impignore:
|
||||
- '*/README.md'
|
||||
...
|
||||
dotfiles:
|
||||
d_vim
|
||||
dst: ~/.vim
|
||||
src: vim
|
||||
upignore:
|
||||
- '*/undo-dir'
|
||||
- '*/plugged'
|
||||
instignore:
|
||||
- '*/internal'
|
||||
cmpignore:
|
||||
- '*/ignore-me'
|
||||
...
|
||||
```
|
||||
|
||||
Patterns used for a specific dotfile can be specified relative to the dotfile destination (`dst`).
|
||||
|
||||
Similar to a `.gitignore` file, you can prefix ignore patterns with an exclamation point (`!`).
|
||||
This so-called "negative ignore pattern" will cause any files that match that pattern to __not__ be ignored,
|
||||
provided they *would have* been ignored by an earlier ignore pattern (dotdrop will warn if that is not the
|
||||
case). This feature allows to, for example, ignore all files within a certain directory, except for a
|
||||
particular one (See examples below).
|
||||
|
||||
To completely ignore comparison of a specific dotfile:
|
||||
```yaml
|
||||
dotfiles:
|
||||
d_vim
|
||||
dst: ~/.vim
|
||||
src: vim
|
||||
cmpignore:
|
||||
- '*'
|
||||
```
|
||||
|
||||
To ignore a specific directory when updating:
|
||||
```yaml
|
||||
dotfiles:
|
||||
d_colorpicker:
|
||||
src: config/some_directory
|
||||
dst: ~/.config/some_directory
|
||||
upignore:
|
||||
- '*sub_directory_to_ignore'
|
||||
```
|
||||
|
||||
To ignore a specific file `testfile` and directory `testdir` when importing:
|
||||
```yaml
|
||||
config:
|
||||
impignore:
|
||||
- "*/testfile"
|
||||
- "testdir"
|
||||
```
|
||||
|
||||
To ignore all files within a certain directory relative to `dst`, except one called `custom_plugin.zsh`:
|
||||
```yaml
|
||||
dotfiles:
|
||||
d_zsh:
|
||||
src: zsh
|
||||
dst: ~/.config/zsh
|
||||
upignore:
|
||||
- "plugins/*"
|
||||
- "!plugins/custom_plugin.zsh"
|
||||
```
|
||||
|
||||
To ignore everything except a single file named `file`:
|
||||
```yaml
|
||||
dotfiles:
|
||||
d_dir
|
||||
src: dir
|
||||
dst: ~/dir
|
||||
cmpignore:
|
||||
- '!file'
|
||||
- '[a-zA-Z0-9]*'
|
||||
```
|
||||
|
||||
To ignore specific files on different profiles (same `src` but some files
|
||||
are not installed for specific profile)
|
||||
```yaml
|
||||
dotfiles:
|
||||
d_testdir_p1:
|
||||
src: testdir
|
||||
dst: ~/.testdir
|
||||
instignore:
|
||||
- '*/ignore-me-1'
|
||||
d_testdir_p2:
|
||||
src: testdir
|
||||
dst: ~/.testdir
|
||||
instignore:
|
||||
- '*/ignore-me-2'
|
||||
profiles:
|
||||
p1:
|
||||
dotfiles:
|
||||
- d_testdir_p1
|
||||
p2:
|
||||
dotfiles:
|
||||
- d_testdir_p2
|
||||
```
|
||||
|
||||
## Ignore missing
|
||||
|
||||
Sometimes, it is nice to have [update](../usage.md#update-dotfiles) not copy all the files in the installed directory
|
||||
or [compare](../usage.md#compare-dotfiles) diff them.
|
||||
|
||||
For example,
|
||||
maybe you only want to include a single configuration file in your repository
|
||||
and don't want to include other files the program uses,
|
||||
such as a cached files.
|
||||
Maybe you only want to change one file and don't want the others cluttering your repository.
|
||||
Maybe the program changes these files quite often and creates unnecessary diffs in your dotfiles.
|
||||
|
||||
In these cases, you can use the [ignore-missing](config-config.md) option.
|
||||
This option is available as a flag (`--ignore-missing` or `-z`) to the `update` and `compare` commands,
|
||||
or [as ignore-missing in the config](config-config.md).
|
||||
|
||||
To configure globally, place the following in `config.yaml`:
|
||||
```yaml
|
||||
config:
|
||||
ignore_missing_in_dotdrop: true
|
||||
```
|
||||
|
||||
To configure per dotfile:
|
||||
```yaml
|
||||
dotfiles:
|
||||
f_abc:
|
||||
ignore_missing_in_dotdrop: true
|
||||
```
|
||||
|
||||
## toml
|
||||
|
||||
Dotdrop should be able to handle `toml` config file however this
|
||||
feature hasn't been extensively tested.
|
||||
A base [config.toml](/config.toml) is available to get started.
|
||||
|
||||
The script [yaml-to-toml.py](https://github.com/deadc0de6/dotdrop/blob/master/scripts/yaml-to-toml.py) allows to convert a `yaml` dotdrop
|
||||
config file to `toml`.
|
||||
|
||||
For more see issue [#343](https://github.com/deadc0de6/dotdrop/issues/343).
|
||||
153
docs/config/config-profiles.md
vendored
Normal file
153
docs/config/config-profiles.md
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
# Profiles entry
|
||||
|
||||
The **profiles** entry (mandatory) contains a YAML object with sub-objects for the profiles for the different dotfiles that need to be managed. The entries in the sub-objects are as follows:
|
||||
|
||||
Entry | Description
|
||||
-------- | -------------
|
||||
`dotfiles` | The dotfiles associated with this profile
|
||||
`import` | List of paths containing dotfile keys for this profile (absolute path or relative to the config file location; see [Import profile dotfiles from file](config-profiles.md#profile-import-entry)).
|
||||
`include` | Include all elements (dotfiles, actions, (dyn)variables, etc) from another profile (See [Include dotfiles from another profile](config-profiles.md#profile-include-entry) and [meta profiles](../howto/group-hosts.md))
|
||||
`variables` | Profile-specific variables (See [Variables](config-file.md#variables))
|
||||
`dynvariables` | Profile-specific interpreted variables (See [Interpreted variables](config-dynvars.md))
|
||||
`actions` | List of action keys that need to be defined in the **actions** entry below (See [actions](config-actions.md))
|
||||
|
||||
```yaml
|
||||
<some-profile-name-usually-the-hostname>:
|
||||
dotfiles:
|
||||
- <some-dotfile-key-name-defined-above>
|
||||
- <some-other-dotfile-key-name>
|
||||
- ...
|
||||
## Optional
|
||||
include:
|
||||
- <some-other-profile>
|
||||
- ...
|
||||
variables:
|
||||
<name>: <value>
|
||||
dynvariables:
|
||||
<name>: <value>
|
||||
actions:
|
||||
- <some-action>
|
||||
- ...
|
||||
import:
|
||||
- <some-path>
|
||||
- ...
|
||||
```
|
||||
|
||||
## Profile include entry
|
||||
|
||||
If one profile is using the entire set of another profile, one can use
|
||||
the `include` entry to avoid redundancy.
|
||||
|
||||
Note that everything from the included profile is made available
|
||||
(actions, variables/dynvariables, etc). See also an example in
|
||||
[meta profiles](../howto/group-hosts.md).
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
profiles:
|
||||
host1:
|
||||
dotfiles:
|
||||
- f_xinitrc
|
||||
include:
|
||||
- host2
|
||||
host2:
|
||||
dotfiles:
|
||||
- f_vimrc
|
||||
```
|
||||
Here profile *host1* contains all the dotfiles defined for *host2* plus `f_xinitrc`.
|
||||
|
||||
For more advanced use-cases, variables
|
||||
([variables](config-variables.md) and [dynvariables](config-dynvars.md))
|
||||
can be used to specify the profile to include in a profile:
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
variables:
|
||||
var1: "john"
|
||||
dynvariables:
|
||||
d_user: "echo $USER"
|
||||
profiles:
|
||||
profile_john:
|
||||
dotfiles:
|
||||
- f_john_dotfile
|
||||
profile_bill:
|
||||
dotfiles:
|
||||
- f_bill_dotfile
|
||||
p1:
|
||||
include:
|
||||
- "profile_{{@@ d_user @@}}"
|
||||
p2:
|
||||
include:
|
||||
- "profile_{{@@ var1 @@}}"
|
||||
```
|
||||
|
||||
Note that profiles cannot include other profiles defined above in
|
||||
the import tree (for example, when a profile exists in another file and is imported using `import_configs`).
|
||||
|
||||
## Profile import entry
|
||||
|
||||
A profile's dotfiles list can be loaded from external files
|
||||
by specifying their paths in the config entry `import` under the specific profile.
|
||||
|
||||
The paths can be absolute or relative to the config file location.
|
||||
|
||||
`config.yaml`
|
||||
```yaml
|
||||
dotfiles:
|
||||
f_abc:
|
||||
dst: ~/.abc
|
||||
src: abc
|
||||
f_def:
|
||||
dst: ~/.def
|
||||
src: def
|
||||
f_xyz:
|
||||
dst: ~/.xyz
|
||||
src: xyz
|
||||
profiles:
|
||||
p1:
|
||||
dotfiles:
|
||||
- f_abc
|
||||
import:
|
||||
- somedotfiles.yaml
|
||||
```
|
||||
|
||||
`somedotfiles.yaml`
|
||||
```
|
||||
dotfiles:
|
||||
- f_def
|
||||
- f_xyz
|
||||
```
|
||||
|
||||
Variables can be used in `import`, what allows to do something like:
|
||||
```yaml
|
||||
import:
|
||||
- profiles.d/{{@@ profile @@}}.yaml
|
||||
```
|
||||
|
||||
## Profile variables entry
|
||||
|
||||
Profile variables will take precedence over globally defined variables.
|
||||
This means that you could do something like this:
|
||||
```yaml
|
||||
variables:
|
||||
git_email: home@email.com
|
||||
dotfiles:
|
||||
f_gitconfig:
|
||||
dst: ~/.gitconfig
|
||||
src: gitconfig
|
||||
profiles:
|
||||
work:
|
||||
dotfiles:
|
||||
- f_gitconfig
|
||||
variables:
|
||||
git_email: work@email.com
|
||||
private:
|
||||
dotfiles:
|
||||
- f_gitconfig
|
||||
```
|
||||
|
||||
## Profile actions entry
|
||||
|
||||
A profile action can be either a `pre` or `post` action (see [actions](config-actions.md)).
|
||||
These are executed before any dotfile installation (for `pre`) and after all dotfile installations (for `post`)
|
||||
only if at least one dotfile has been installed.
|
||||
100
docs/config/config-transformations.md
vendored
Normal file
100
docs/config/config-transformations.md
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
# Transformations entry
|
||||
|
||||
For examples of transformation uses, see:
|
||||
|
||||
* [Handle compressed directories](../howto/store-compressed-directories.md)
|
||||
* [Handle secrets](../howto/sensitive-dotfiles.md)
|
||||
|
||||
**Notes**:
|
||||
|
||||
* Any transformation with a key starting with an underscore (`_`) won't be shown in output. This can be useful when working with sensitive data containing passwords, for example.
|
||||
* Make sure to quote your transformations to avoid bad surprises
|
||||
* Transformations are executed using the default shell (`$SHELL`)
|
||||
* To use shell variables in your transformations you need to escape the curly brackets (`${HOME}` becomes `${{HOME}}`)
|
||||
|
||||
There are two types of transformations available:
|
||||
|
||||
* **Read transformations**: used to transform dotfiles before they are installed ([config](config-config.md) key `trans_read`)
|
||||
* Used for commands `install` and `compare`
|
||||
* They have two mandatory arguments:
|
||||
* **{0}** will be replaced with the dotfile to process
|
||||
* **{1}** will be replaced with a temporary file to store the result of the transformation
|
||||
* This Happens **before** the dotfile is templated (see [templating](../templating.md))
|
||||
|
||||
* **Write transformations**: used to transform files before updating a dotfile ([config](config-config.md) key `trans_write`)
|
||||
* Used for command `update` and `import`
|
||||
* They have two mandatory arguments:
|
||||
* **{0}** will be replaced with the file path to update the dotfile with
|
||||
* **{1}** will be replaced with a temporary file to store the result of the transformation
|
||||
|
||||
A typical use-case for transformations is when dotfiles need to be
|
||||
stored encrypted or compressed. For more, see [the howto](../howto/howto.md).
|
||||
|
||||
Note that transformations cannot be used if the dotfile is to be linked (when `link: absolute|relative|link_children`).
|
||||
|
||||
Transformations also support additional positional arguments that must start from 2 (since `{0}` and `{1}` are added automatically). The transformations themselves as well as their arguments can also be templated.
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
trans_read:
|
||||
targ: echo "$(basename {0}); {{@@ _dotfile_key @@}}; {2}; {3}" > {1}
|
||||
dotfiles:
|
||||
f_abc:
|
||||
dst: /tmp/abc
|
||||
src: abc
|
||||
trans_read: targ "{{@@ profile @@}}" lastarg
|
||||
profiles:
|
||||
p1:
|
||||
dotfiles:
|
||||
- f_abc
|
||||
```
|
||||
|
||||
will result in `abc; f_abc; p1; lastarg`.
|
||||
|
||||
## trans_read entry
|
||||
|
||||
The **trans_read** entry (optional) contains a transformations mapping (See [transformations](config-transformations.md)).
|
||||
|
||||
```yaml
|
||||
trans_read:
|
||||
<trans-key>: <command-to-execute>
|
||||
```
|
||||
|
||||
## trans_write entry
|
||||
|
||||
The **trans_write** entry (optional) contains a write transformations mapping (See [transformations](config-transformations.md)).
|
||||
|
||||
```yaml
|
||||
trans_write:
|
||||
<trans-key>: <command-to-execute>
|
||||
```
|
||||
|
||||
## Dynamic transformations
|
||||
|
||||
As for [dynamic actions](config-actions.md#dynamic-actions), transformations support
|
||||
the use of variables ([variables and dynvariables](config-file.md#variables)
|
||||
and [template variables](../templating.md#template-variables)).
|
||||
|
||||
A very dumb example:
|
||||
```yaml
|
||||
trans_read:
|
||||
r_echo_abs_src: echo "{0}: {{@@ _dotfile_abs_src @@}}" > {1}
|
||||
r_echo_var: echo "{0}: {{@@ r_var @@}}" > {1}
|
||||
trans_write:
|
||||
w_echo_key: echo "{0}: {{@@ _dotfile_key @@}}" > {1}
|
||||
w_echo_var: echo "{0}: {{@@ w_var @@}}" > {1}
|
||||
variables:
|
||||
r_var: readvar
|
||||
w_var: writevar
|
||||
dotfiles:
|
||||
f_abc:
|
||||
dst: ${tmpd}/abc
|
||||
src: abc
|
||||
trans_read: r_echo_abs_src
|
||||
trans_write: w_echo_key
|
||||
f_def:
|
||||
dst: ${tmpd}/def
|
||||
src: def
|
||||
trans_read: r_echo_var
|
||||
trans_write: w_echo_var
|
||||
```
|
||||
41
docs/config/config-uservars.md
vendored
Normal file
41
docs/config/config-uservars.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# Uservariables entry
|
||||
|
||||
The **uservariables** entry (optional) contains a collection of variables
|
||||
whose values are queried from the user
|
||||
(See [User variables](config-variables.md)).
|
||||
|
||||
```yaml
|
||||
uservariables:
|
||||
<variable-name>: <prompt>
|
||||
```
|
||||
|
||||
If you want to manually enter variables' values, you can use the
|
||||
`uservariables` entry. Each variable will be prompted to the user.
|
||||
|
||||
For example:
|
||||
```yaml
|
||||
uservariables:
|
||||
emailvar: "email"
|
||||
```
|
||||
|
||||
will prompt the user to enter a value for the variable `emailvar`:
|
||||
```
|
||||
Please provide the value for "email":
|
||||
```
|
||||
|
||||
And store the entered text as the value for the variable `email`.
|
||||
The variable can then be used as any other [variable](config-file.md#variables).
|
||||
|
||||
`uservariables` are eventually saved to `uservariables.yaml` (relatively to the
|
||||
config file).
|
||||
This allows to use the following construct to prompt once for some specific variables and
|
||||
then store them in a file. You might also want to add `uservariables.yaml` to your `.gitignore`.
|
||||
```yaml
|
||||
uservariables:
|
||||
emailvar: "email"
|
||||
config:
|
||||
import_variables:
|
||||
- uservariables.yaml:optional
|
||||
```
|
||||
|
||||
For an example, see [prompt user for variables](../howto/prompt-user-for-variables.md).
|
||||
44
docs/config/config-variables.md
vendored
Normal file
44
docs/config/config-variables.md
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# Variables entry
|
||||
|
||||
The **variables** entry (optional) contains a variables mapping (See [variables](config-file.md#variables)).
|
||||
|
||||
```yaml
|
||||
variables:
|
||||
<variable-name>: <variable-content>
|
||||
```
|
||||
|
||||
Variables defined in the `variables` entry are made available within the config file.
|
||||
|
||||
For example
|
||||
```yaml
|
||||
variables:
|
||||
myvar: "some value"
|
||||
home: "{{@@ env['HOME'] @@}}"
|
||||
email: "user@domain.com"
|
||||
```
|
||||
|
||||
Config variables are recursively evaluated, which means that
|
||||
a config like the below:
|
||||
```yaml
|
||||
variables:
|
||||
var1: "var1"
|
||||
var2: "{{@@ var1 @@}} var2"
|
||||
var3: "{{@@ var2 @@}} var3"
|
||||
var4: "{{@@ dvar4 @@}}"
|
||||
dynvariables:
|
||||
dvar1: "echo dvar1"
|
||||
dvar2: "{{@@ dvar1 @@}} dvar2"
|
||||
dvar3: "{{@@ dvar2 @@}} dvar3"
|
||||
dvar4: "echo {{@@ var3 @@}}"
|
||||
```
|
||||
|
||||
will result in the following available variables:
|
||||
|
||||
* var1: `var1`
|
||||
* var2: `var1 var2`
|
||||
* var3: `var1 var2 var3`
|
||||
* var4: `echo var1 var2 var3`
|
||||
* dvar1: `dvar1`
|
||||
* dvar2: `dvar1 dvar2`
|
||||
* dvar3: `dvar1 dvar2 dvar3`
|
||||
* dvar4: `var1 var2 var3`
|
||||
Reference in New Issue
Block a user