# Configuration

tomes works without configuration. To change its defaults, write them to `~/.config/tomes/config.toml`; `tomes config --init` writes an example with every setting.

``` toml
colors = "book"             # or "terminal": the book's palette or yours
dark = true                 # light or dark (default: what your terminal uses)
width = 82                  # maximum width of the text
code_blocks = "border"      # or "fill"
images = "auto"             # kitty, iterm2, sixel, halfblocks, or none
max_image_rows = 30
mouse = true
hyperlinks = true           # clickable links (OSC 8)
sidebar = true
fold_output_after = 30      # fold long output (0: never)
clipboard = "auto"          # system, tmux, or osc52
send = "auto"               # where s sends commands: tmux, terminal, clipboard
terminal_position = "auto"  # bottom or right
shell = "/bin/zsh"          # for the terminal in the reader
scrolloff = 4
smooth_scroll = false
keys_preset = "vim"         # or "less"

[keys]
"ctrl-n" = "next-chapter"
"ctrl-p" = "prev-chapter"
```


# Keys

`[keys]` binds keys to actions. A key is a character (`j`, `G`, `?`) or a name (`enter`, `tab`, `space`, `up`, `pagedown`, `f1`), with `ctrl-` or `alt-` in front; sequences are separated by spaces (`"g g"`, `"z a"`). `<leader>` is `Space` (or `,` with the `less` preset). The actions are the names in the help screen (`?`), like `next-chapter`, `find`, `send`, `toggle-colors`.


# The command line inside the reader

`:` opens a command line. `Tab` completes.

| Command | What |
|----|----|
| `:5`, `:chapter scrubbing` | Open a chapter |
| `:open URL`, `:open path` | Open another book |
| `:find text` | Search the whole book |
| `:colors book`, `:light`, `:dark`, `:code border` | Colors |
| `:width 100`, `:set fold=20`, `:set mouse=off` | Settings for now |
| `:target tmux` | Where commands go |
| `:images` | Which image protocol tomes found |
| `:fold`, `:unfold`, `:bookmarks`, `:web`, `:q` | And more |


# What tomes remembers

`~/.local/state/tomes/state.json` keeps, for every book, where you were, your marks and bookmarks, and the chapters you've read; and your choices (colors, light or dark, the mouse, the outline). `tomes config` shows where both files are. `TOMES_HOME` puts them both in another directory.

Books from the web are cached in your cache folder (`~/Library/Caches/tomes` on macOS, `~/.cache/tomes` on Linux).


# Environment variables

| Variable | What |
|----|----|
| `TOMES_HOME` | Directory for the configuration and the state |
| `TOMES_NO_QUERY=1` | Ask the terminal nothing at startup (for terminals that don't answer) |
| `TOMES_TIMING=1` | Print how long the first frame took |
| `NO_COLOR` | `cat` prints without colors |
