From 1a2d761d7d49096b912eacf9e22934449400196e Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Tue, 15 Sep 2020 22:54:45 +0200 Subject: [PATCH] migrate dynamic doc --- docs/config-details.md | 85 +++++++++++++++++++++++++++++++++++++++++ docs/config.md | 86 ------------------------------------------ 2 files changed, 85 insertions(+), 86 deletions(-) diff --git a/docs/config-details.md b/docs/config-details.md index 4aee230..bf92088 100644 --- a/docs/config-details.md +++ b/docs/config-details.md @@ -526,3 +526,88 @@ It is possible to make non-existing paths not fatal by appending the path with ` import_configs: - other-config.yaml:optional ``` + +## Dynamic dotfile paths + +Dotfile source (`src`) and destination (`dst`) can be dynamically constructed using +defined variables ([variables and dynvariables](#variables)). + +For example to have a dotfile deployed on the 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 +``` + +Make sure to quote the path in the config file. + +## Dynamic actions + +Variables ([config variables and dynvariables](#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. + +## Dynamic transformations + +As for [dynamic actions](#dynamic-actions), transformations support +the use of variables ([variables and dynvariables](#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 +``` diff --git a/docs/config.md b/docs/config.md index 9c9543c..784096a 100644 --- a/docs/config.md +++ b/docs/config.md @@ -53,91 +53,6 @@ which are controlled by the `link` config attribute of each dotfile: For more see [this how-to](howto/symlink-dotfiles.md) -## Dynamic dotfile paths - -Dotfile source (`src`) and destination (`dst`) can be dynamically constructed using -defined variables ([variables and dynvariables](#variables)). - -For example to have a dotfile deployed on the 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 -``` - -Make sure to quote the path in the config file. - -## Dynamic actions - -Variables ([config variables and dynvariables](#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. - -## Dynamic transformations - -As for [dynamic actions](#dynamic-actions), transformations support -the use of variables ([variables and dynvariables](#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 -``` - ## All dotfiles for a profile To use all defined dotfiles for a profile, simply use @@ -161,7 +76,6 @@ profiles: - f_vimrc ``` - ## Ignore patterns It is possible to ignore specific patterns when using dotdrop. For example for `compare` when temporary