|
1 |
| -+++ |
2 |
| -title = "Variable reference" |
3 |
| -description = "Manage variable reference" |
4 |
| -date = 2021-05-16 |
5 |
| -updated = 2021-05-16 |
6 |
| -draft = false |
7 |
| -weight = 2 |
8 |
| -sort_by = "weight" |
9 |
| -template = "docs/page.html" |
10 |
| - |
11 |
| -[extra] |
12 |
| -lead = """ |
13 |
| -Variable references allows using different variable names for the same values. |
14 |
| -Define system wide color schemes, global values for specific environments etc. |
15 |
| -""" |
16 |
| -toc = true |
17 |
| -top = false |
18 |
| -+++ |
19 |
| - |
20 |
| -### Declare variable references |
21 |
| - |
22 |
| -A variable reference is declared like any other variable, except the value should be a variable name prefixed with `%`. |
23 |
| - |
24 |
| -```toml |
25 |
| -a_variable = "42" |
26 |
| -variable_ref = "%a_variable" |
27 |
| -``` |
28 |
| - |
29 |
| -Here `%a_variable` points to `"42"`. Any template call to `{{variable_ref}}` will be replace by `42` when running |
30 |
| -`bombadil link`. |
31 |
| - |
32 |
| -### Layout example |
33 |
| - |
34 |
| -The main idea behind variable references is to avoid repetition and inject values into multiple dotfiles. |
35 |
| -As you will see later in this documentation, references are meant to be mixed with profiles and scoped variable. |
36 |
| - |
37 |
| -For now let us define a simple layout. Assuming we are using sway as a window manager, and our terminal is alacritty, |
38 |
| -we are going to define three separate variables files : |
39 |
| -- A global variable file `theme_vars.toml` |
40 |
| -- A variable file for alacritty `alacritty_vars.toml` |
41 |
| -- A variable file for sway `sway_vars.toml` |
42 |
| - |
43 |
| -```toml |
44 |
| -# bombadil.toml |
45 |
| -[settings] |
46 |
| -vars = [ "theme_vars.toml", "alacritty_vars.toml", "sway_vars.toml" ] |
47 |
| -# ... |
48 |
| -``` |
49 |
| - |
50 |
| -- `theme_vars.toml` contains all our system theme colors : |
51 |
| - |
52 |
| - ```toml |
53 |
| - red = "#ff0000" |
54 |
| - black = "#000000" |
55 |
| - green = "#008000" |
56 |
| - ``` |
57 |
| -- `sway_vars.toml` contain sway specific variables, some are references, some are static. |
58 |
| - ```toml |
59 |
| - sway_client_focused_background = "%black" |
60 |
| - sway_client_focused_border = "#ffff00" |
61 |
| - # ... |
62 |
| - ``` |
63 |
| - |
64 |
| -- `alacritty_vars.toml` uses references just like sway variables. |
65 |
| - |
66 |
| - ```toml |
67 |
| - alacritty_background = "%black" |
68 |
| - alacritty_cursor = "%green" |
69 |
| - # ... |
70 |
| - ``` |
71 |
| - |
72 |
| -In the next section we will see how to scope variables to a specific dot entry. |
73 |
| - |
0 commit comments