|
| 1 | +--- |
| 2 | +title: Theming |
| 3 | +--- |
| 4 | + |
| 5 | +For terminal interface customization, Atuin supports user and built-in color themes. |
| 6 | + |
| 7 | +Atuin ships with only a couple of built-in alternative themes, but more can be added via TOML files. |
| 8 | + |
| 9 | +# Required config |
| 10 | + |
| 11 | +The following is required in your config file (`~/.config/atuin/config.toml`) |
| 12 | + |
| 13 | +``` |
| 14 | +[theme] |
| 15 | +name = "THEMENAME" |
| 16 | +``` |
| 17 | + |
| 18 | +Where `THEMENAME` is a known theme. The following themes are available out-of-the-box: |
| 19 | + |
| 20 | +* default theme (can be explicitly referenced with an empty name `""`) |
| 21 | +* `autumn` theme |
| 22 | +* `marine` theme |
| 23 | + |
| 24 | +These are present to ensure users and developers can try out theming, but in general, you |
| 25 | +will need to download themes or make your own. |
| 26 | + |
| 27 | +If you are writing your own themes, you can add the following line to get additional output: |
| 28 | + |
| 29 | +``` |
| 30 | +debug = true |
| 31 | +``` |
| 32 | + |
| 33 | +to the same config block. This will print out any color names that cannot be parsed from |
| 34 | +the requested theme. |
| 35 | + |
| 36 | +A final optional setting is available: |
| 37 | + |
| 38 | +``` |
| 39 | +max_depth: 10 |
| 40 | +``` |
| 41 | + |
| 42 | +which sets the maximum levels of theme parents to traverse. This should not need to be |
| 43 | +explicitly added in normal use. |
| 44 | + |
| 45 | +# Usage |
| 46 | + |
| 47 | +## Theme structure |
| 48 | + |
| 49 | +Themes are maps from *Meanings*, describing the developer's intentions, |
| 50 | +to (at present) colors. In future, this may be expanded to allow richer style support. |
| 51 | + |
| 52 | +*Meanings* are from an enum with the following values: |
| 53 | + |
| 54 | +* `AlertInfo`: alerting the user at an INFO level |
| 55 | +* `AlertWarn`: alerting the user at a WARN level |
| 56 | +* `AlertError`: alerting the user at an ERROR level |
| 57 | +* `Annotation`: less-critical, supporting text |
| 58 | +* `Base`: default foreground color |
| 59 | +* `Guidance`: instructing the user as help or context |
| 60 | +* `Important`: drawing the user's attention to information |
| 61 | +* `Title`: titling a section or view |
| 62 | + |
| 63 | +These may expand over time as they are added to Atuin's codebase, but Atuin |
| 64 | +should have fallbacks added for any new *Meanings* so that, whether themes limit to |
| 65 | +the present list or take advantage of new *Meanings* in future, they should |
| 66 | +keep working sensibly. |
| 67 | + |
| 68 | +**Note for Atuin contributors**: please do identify and, where appropriate during your own |
| 69 | +PRs, extend the Meanings enum if needed (along with a fallback Meaning!). |
| 70 | + |
| 71 | +## Theme creation |
| 72 | + |
| 73 | +When a theme name is read but not yet loaded, Atuin will look for it in the folder |
| 74 | +`~/.config/atuin/themes/` unless overridden by the `ATUIN_THEME_DIR` environment |
| 75 | +variable. It will attempt to open a file of name `THEMENAME.toml` and read it as a |
| 76 | +map from *Meanings* to colors. |
| 77 | + |
| 78 | +Colors may be specified either as names from the [palette](https://ogeon.github.io/docs/palette/master/palette/named/index.html) |
| 79 | +crate in lowercase, or as six-character hex codes, prefixed with `#`. For example, |
| 80 | +the following are valid color names: |
| 81 | + |
| 82 | +* `#ff0088` |
| 83 | +* `teal` |
| 84 | +* `powderblue` |
| 85 | + |
| 86 | +A theme file, say `my-theme.toml` can then be built up, such as: |
| 87 | + |
| 88 | +```toml |
| 89 | +[theme] |
| 90 | +name = "my-theme" |
| 91 | +parent = "autumn" |
| 92 | + |
| 93 | +[colors] |
| 94 | +AlertInto = "green" |
| 95 | +Guidance = "#888844" |
| 96 | + |
| 97 | +``` |
| 98 | + |
| 99 | +where not all of the *Meanings* need to be explicitly defined. If they are absent, |
| 100 | +then the color will be chosen from the parent theme, if one is defined, or if that |
| 101 | +key is missing in the `theme` block, from the default theme. |
| 102 | + |
| 103 | +This theme file should be moved to `~/.config/atuin/themes/my-theme.toml` and the |
| 104 | +following added to `~/.config/atuin/config.toml`: |
| 105 | + |
| 106 | +``` |
| 107 | +[theme] |
| 108 | +name = "my-theme" |
| 109 | +``` |
| 110 | + |
| 111 | +When you next run Atuin, your theme should be applied. |
0 commit comments