config.lua
config.lua is an optional Lua file loaded at startup before the UI appears. Use it for programmatic configuration — conditional settings, loading plugins, and anything that benefits from real code instead of TOML.
File location:
~/.config/jjui/config.lua$JJUI_CONFIG_DIR/config.lua
setup(config)
Section titled “setup(config)”Define a top-level setup(config) function and jjui will call it at startup with a config object for registering actions, adding bindings, and setting colors.
function setup(config) -- register actions and bindings hereendThe config object exposes config.action(...) and config.bind(...) for registering actions and bindings. For the full API, see Actions and Bindings.
Runtime values
Section titled “Runtime values”These fields are available on config inside setup and are read-only:
| Value | Type | Description |
|---|---|---|
config.repo | string | Absolute path of the current repository |
config.terminal.dark_mode | bool | Whether the terminal reports dark mode |
config.terminal.bg | string | Terminal background color (hex, if detectable) |
config.terminal.fg | string | Terminal foreground color (hex, if detectable) |
Sharing helpers with config.toml
Section titled “Sharing helpers with config.toml”config.lua and [[actions]].lua scripts in config.toml run in the same Lua VM. Any global function defined in config.lua is available to TOML action scripts:
-- config.luafunction current_diff() return jj("diff", "-r", context.change_id(), "--git")end[[actions]]name = "copy-diff"lua = '''copy_to_clipboard(current_diff())'''Modules
Section titled “Modules”require(...) resolves modules from your config directory in addition to the standard Lua path. Place Lua files under ~/.config/jjui/ and load them with require("plugins.name").
local my_plugin = require("plugins.my_plugin")
function setup(config) my_plugin.setup(config)endFor practical examples, see the Lua Cookbook. For the full runtime API (context, revisions, jj, flash, etc.), see Lua Scripting.