Themes
A theme sets the colors and the text styles of yuke. yuke has one theme, default. This theme works on light and dark terminals.
To change the theme, run /themes. Use the arrow keys to see a theme. Press Enter to keep it. Press Esc to go back to the old theme.
Write a theme
A theme is a plugin. Create the file ~/.config/yuke/plugins/nord/plugin.json:
{
"name": "nord",
"extensions": { "sh.yuke": { "entry": "./index.ts" } }
}In the same folder, create the file index.ts. The colors in this file are an example:
import type { PluginContext } from "yuke:plugins";
export function apply(ctx: PluginContext): undefined {
ctx.get("tui")?.styles.addTheme("nord", {
dark: {
palette: { fg: "#eceff4", bg: "#2e3440", accent: "#88c0d0", surface: "#3b4252" },
groups: { "chat.title": { fg: "#ebcb8b" } },
},
light: {
palette: { accent: "#2e6f8e" },
},
});
return undefined;
}Add the folder to ~/.config/yuke/config.json:
{
"plugins": ["./plugins/nord"]
}Run /reload. Then select nord in /themes. Run /reload again after each change to the theme.
Set only the values that you want to change. All other values come from default. If you set only dark or only light, yuke uses the same values on the two backgrounds.
Palette
A group can name a palette color. When you change accent, each group that names accent changes, also the groups of other plugins. The palette names are PaletteColor in types/tui.d.ts.
A color is a hex value ("#88c0d0"), a 256-color index (110), or "reset". The value "reset" gives the color of the terminal. In default, fg and bg are "reset".
A terminal without 24-bit color uses palette256, such as palette256: { accent: 110 }, next to palette. A color that it leaves out comes from palette. yuke finds 24-bit color from the variable COLORTERM: the values truecolor and 24bit turn it on.
Groups
A group sets the style of one part of the interface. Set only the fields that you want to change. To remove a field, set it to null.
groups: {
"chat.title": { fg: "#ebcb8b" }, // The title stays bold.
"chat.thought": { italic: null },
"picker.match": { underline: true },
}The fields are fg, bg, underlineColor, bold, dim, italic, reverse, underline, and inherits. inherits names a second group. That group gives the fields that the first group does not set.
default-theme.ts has all the groups and all the colors. To change many values, copy this file.
Start from a different theme
ctx.get("tui")?.styles.addTheme("my-nord", {
inherits: "nord",
dark: { palette: { accent: "#a3be8c" } },
});The order in which the plugins load has no effect. If two plugins add a theme with the same name, yuke uses the newest theme. The name default is reserved: addTheme("default", ...) throws a TypeError.
Plugins and themes
Use styles.add to set the style of the groups of your plugin. Use palette names or inherits, and your plugin follows each theme:
ctx.get("tui")?.styles.add({
"notes.title": { inherits: "chat.title" },
"notes.count": { fg: "accent" },
});A hex value does not change with the theme or the background. A theme has priority over styles.add, and styles.add has priority over default.
To set a style for one theme, read styles.theme at startup and on the event theme.changed. yuke also sends this event when the background of the terminal changes.
import type { PluginContext } from "yuke:plugins";
export function apply(ctx: PluginContext): undefined {
const tui = ctx.get("tui");
if (tui === undefined) return undefined;
let undo = (): void => {};
const look = (): void => {
undo();
undo = tui.styles.theme === "nord" ? tui.styles.add({ "notes.title": { fg: "#ebcb8b" } }) : () => {};
};
look();
ctx.addListener("theme.changed", look);
return undefined;
}If nord sets notes.title later, the value of nord has priority. You can keep this code.
The themes plugin applies the saved theme name at startup. Until the plugin that adds that theme loads, yuke shows the look of default.