Customize

Configuration

Where Tooee reads its config files, how the layers merge, and how to remap keys by command id.

.tooee/config.json
{
  "theme": { "name": "gruvbox" },
  "keys": {
    "cursor-down": "down",
    "cursor-up": "up",
    "quit": "ctrl+x"
  },
  "view": { "gutter": false }
}

Run tooee view README.md from the folder that holds .tooee/. View starts in gruvbox with the gutter off. down and up move the cursor, j and k do nothing, and ctrl+x quits. The file applies to every Tooee app started from that folder or from a folder below it, including apps you build on @tooee/shell.

Config files

LayerLocationApplies to
Global~/.config/tooee/config.json. When XDG_CONFIG_HOME is set, it replaces ~/.config.Every Tooee app you run.
Project.tooee/config.json in the working directory, or in the nearest parent directory that has one.Apps started inside that directory.
Overridesprovider.config on launchCli or runCliSession.One app.

Tooee starts from its defaults, tokyonight in dark mode, then applies the global file, the project file, and the overrides in that order. Each of theme, keys, and view merges key by key, so a project file that sets keys.quit keeps the keys.cursor-down from the global file. The search for a project file stops at the first .tooee/config.json it meets on the way up.

A file that fails to parse is skipped. A key Tooee does not know is dropped, so the file cannot carry settings of your own. A value of the wrong type is dropped as well; in keys, one value that is not a string drops the whole keys map of that file.

Settings

KeyValuesEffect
theme.nameA theme nameThe theme at start. Default tokyonight. Themes lists the names.
theme.modedark, lightWhich colour variant of the theme to resolve. Default dark.
keys{ "<command id>": "<hotkey>" }Replaces the default hotkey of each named command.
view.guttertrue, falseLine numbers in View at start. Default true. L toggles them.
view.wraptrue, falseWrap long diff lines at start. Default false. w toggles it.
view.diffLayoutsplit, stackThe first diff layout. Default stack. s toggles it.
view.copyOnSelecttrue, false, "primary", "clipboard"Where text dragged with the mouse goes. Default: the primary selection on Linux, off on other platforms. true means "primary".

TooeeConfig from @tooee/config is the type of the merged result. ColorMode is the type of theme.mode.

Remap keys

Every command has an id. keys maps an id to a new hotkey in the grammar from Commands and modes: a key, a chord such as ctrl+x, or a sequence such as g d. The new hotkey replaces the default, so the old key is free for another command.

IdDefaultRegistered by
cursor-down, cursor-upj, kEvery document
cursor-half-down, cursor-half-upctrl+d, ctrl+uEvery document
cursor-top, cursor-bottomg g, shift+gEvery document
enter-select, select-down, select-up, select-cancelv, j, k, escapeEvery document
cursor-toggle, cursor-toggle-up, select-toggletab, shift+tab, tabDocuments with multi-select
cursor-search-start, cursor-search-next, cursor-search-prev, search-cancel/, n, shift+n, escapeEvery document with search
copy-line, copy-selectiony y, y vEvery document
copyy gView, and any screen that calls useCopyCommand
quitqView, Ask, Choose, DocumentScreen, and useQuitCommand
cycle-themetThe same screens, through useThemeCommands
toggle-line-numbersshift+lView
toggle-debug-consolectrl+shift+jEvery app
command-palette:Every app
overlay.close-topescapeEvery app, while an overlay that allows Escape is open
overlay.close-selfescapeAn overlay with ownCommands that allows Escape
outline.toggleg oView with Markdown content, heading outline
fold.toggle, fold.close, fold.open, fold.toggle-block, fold.close-all, fold.open-allz a, z c, z o, z z, z shift+m, z shift+rView with Markdown content, fold sections
outline.fold.toggle, outline.fold.close, outline.fold.open, outline.fold.toggle-block, outline.fold.close-all, outline.fold.open-allThe same as the fold.* keysThe heading outline, while it has the focus
view.follow-linkenterView with Markdown content, follow local links
block-scroll-left, block-scroll-righth, lView, when the cursor is on a wide code block in Markdown
dir.next-file, dir.prev-fileg n, g pView, directory view
paste-clipboard, paste-primaryp, noneAsk. paste-primary reads the primary selection on Linux. Without a key, it runs from the palette as "Paste from selection".
context-menu:select, context-menu:move-up, context-menu:move-down, context-menu:move-up-vim, context-menu:move-down-vimenter, up, down, k, jContext menus
diff.toggle-layout, diff.toggle-wrap, diff.next-file, diff.prev-file, diff.file-picker, diff.scroll-left, diff.scroll-rights, w, ], [, f, h, lView: diffs
router.backbackspaceRouting
panels.next, panels.previoustab, shift+tabPanels

Commands of your own remap by the id you gave them. The deploy console on Commands and modes registers deploy.run on d, and { "keys": { "deploy.run": "shift+d" } } moves it to D.

The remap changes the key that runs the command. The palette and the which-key bar show the new key. Hints that your app draws itself must read the config, as the next example does.

Read the config in your app

deploy.tsx
import { useCommand } from "@tooee/commands";
import { useKeymapConfig } from "@tooee/config";
import { AppLayout } from "@tooee/layout";
import { launchCli, useQuitCommand } from "@tooee/shell";
import { useState } from "react";
import type { ReactNode } from "react";

const Deploy = function Deploy(): ReactNode {
  const keymap = useKeymapConfig();
  const [status, setStatus] = useState("idle");
  useQuitCommand();
  useCommand({
    handler: () => {
      setStatus("deployed");
    },
    hotkey: "d",
    id: "deploy.run",
    title: "Deploy",
  });
  const hints = `${keymap["deploy.run"] ?? "d"} deploy  ${keymap.quit ?? "q"} quit`;

  return (
    <AppLayout statusBar={{ items: [{ label: "", value: hints }] }}>
      <box paddingLeft={1}>
        <text content={`status: ${status}`} />
      </box>
    </AppLayout>
  );
};

await launchCli(<Deploy />, {
  provider: { config: { keys: { "deploy.run": "shift+d" } } },
});

Run it from the folder that holds the config file at the top of this page. The status bar reads shift+d deploy ctrl+x quit: the deploy.run key comes from the overrides and the quit key from the project file. D deploys and ctrl+x quits.

useConfig() returns the merged TooeeConfig. useKeymapConfig() returns keys, or an empty object. useThemeConfig() returns theme. All three come from @tooee/config and read the ConfigProvider that TooeeProvider mounts, so they work in any app started with launchCli or runCliSession. Outside React, loadConfig(overrides) reads the same layers and returns the merged result.

What the theme picker writes

Enter in the theme picker calls writeGlobalConfig({ theme: { mode, name } }) from @tooee/config. The function reads the global file, merges the new theme into it, and writes the file back with two-space indentation. The project file and the overrides are left alone, so a theme.name in .tooee/config.json still wins over the saved choice. The write merges into the raw JSON, so keys that Tooee does not know stay in the file, at the top level and inside theme, keys, and view. When the global file is not valid JSON, the write leaves it unchanged.

Next

On this page