Skip to content

Commit 3204e14

Browse files
authored
adds docs for theming (#66)
Aligns with atuinsh/atuin#2236 to explain the usage of themes. TODO: Markdown needs to be checked, but here for feedback initially. More information is available at that PR.
1 parent ba11029 commit 3204e14

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed

astro.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default defineConfig({
4848
{ label: 'Import existing history', link: '/guide/import' },
4949
{ label: 'Basic usage', link: '/guide/basic-usage' },
5050
{ label: 'Syncing dotfiles', link: '/guide/dotfiles' },
51+
{ label: 'Theming', link: '/guide/theming' },
5152
],
5253
},
5354
{

src/content/docs/configuration/config.mdx

+45
Original file line numberDiff line numberDiff line change
@@ -623,3 +623,48 @@ The port to use for client -> daemon communication. Only used on non-unix system
623623
```toml
624624
tcp_port = 8889
625625
```
626+
627+
## theme
628+
Atuin version: >= 18.4
629+
630+
The theme to use for showing the terminal interface.
631+
632+
```toml
633+
[theme]
634+
name = ""
635+
debug = false
636+
max_depth = 10
637+
```
638+
639+
### `name`
640+
Default: `""`
641+
642+
A theme name that must be present as a built-in (an empty string for the default,
643+
`autumn` or `marine`), or found in the themes directory, with the suffix `.toml`.
644+
By default this is `~/.config/atuin/themes/` but can be overridden with the
645+
`ATUIN_THEME_DIR` environment variable.
646+
647+
```toml
648+
name = "my-theme"
649+
```
650+
651+
### `debug`
652+
Default: `false`
653+
654+
Output information about why a theme will not load. Independent from other log
655+
levels as it can cause data from the theme file to be printed unfiltered to the
656+
terminal.
657+
658+
```toml
659+
debug = false
660+
```
661+
662+
### `max_depth`
663+
Default: 10
664+
665+
Number of levels of "parenthood" that will be traversed for a theme. This should not
666+
need to be added in or changed in normal usage.
667+
668+
```toml
669+
max_depth = 10
670+
```

src/content/docs/guide/theming.mdx

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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

Comments
 (0)