// plugin · v0.1.1 · herdr ≥ 0.9.5 · macOS & Linux

Space Herder

Herds Herdr's spaces sidebar: keeps it sorted into groups, gives every space of one customer the same colour, and replaces Herdr's new-space and rename prompts with dialogs that show the result as you type.

herdr plugin install MrBogomips/herdr-tools/space-herder
Herdr with Space Herder: a sidebar where every customer has its own colour, ACME spaces in blue next to each other, Initech in mauve, LUMON pinned on top and SYS kept at the bottom, with agents working and waiting below
Herdr with Space Herder and auto-tab-name, on fictional customers.
// 01

A sidebar that sorts itself

A suffix in the space name picks its group. Groups come in this order, and inside each one spaces sort by name with the suffix removed, ignoring case. Worktree children follow their parent and sit right under it.

GroupName conventionExample
homethe name ~~, always first
headends with a space and +LUMON +
defaultno suffixACME - api
bottomends with a space and -SYS -

The space before the suffix is required, so C++ stays in the default group. Sort on a key, or turn on autosort and let the sidebar sort itself after every new or renamed space:

auto_sortSorts after
"off" (default)nothing: only the sort key sorts
"created"a space is created, a new worktree space included
"renamed"a space is renamed
"both"either

The focused space stays focused, sorting a sorted sidebar changes nothing, and space numbers and next/previous-space navigation follow the new order.

// 02

A colour per customer

The key is the part of the name before the first -: ACME - api, ACME - web and ACME + all share ACME, so they share a colour. The colour is chosen in this order:

  1. Rules first. A regular expression matched against the name; the first match picks the colour.
  2. Then a colour picked in a dialog for that key.
  3. Otherwise the key's colour, by assign:
    • "hash" (default): a stable SHA-256 hash of the key. The same customer gets the same colour on every machine, with nothing stored.
    • "sticky": a new key starts from its hash colour but takes the least-used colour when that one is taken, and keeps it. No two customers share a colour until there are more customers than colours.
  4. Worktree children take their parent's colour, so a repo's checkouts match it.

With hashing alone and 15 colours, the odds that some two of six customers share a colour are about 2 in 3. Use "assign": "sticky", or pin a customer to a colour with a rule.

9 preset palettes

Accent colours of popular themes, the most distinct first, up to the 15 a sidebar row can hold. Or bring your own list of hex colours.

// 03

Dialogs that show the result

Herdr's own prompts ask only for a name. Space Herder's dialogs open in a popup and show the sidebar as it will look: the name with its group suffix, the space in its place and in its colour.

The new-space dialog over a Herdr layout: folder ~/git/initech-crm, name Initech - billing becoming Initech - billing + in the head group, mauve picked in the colour row, and a sidebar preview with Initech - billing + at the top and both Initech spaces in mauve
New space: folder, name, group and colour, with the sidebar preview on the right.
FieldKeysWhat it does
Folder (new space)type, Tab completes, ↑ ↓Where the space starts: recent folders, open panes' folders and, with zoxide, its best-ranked ones
Nametype, Ctrl+W, Ctrl+UEnding it with + or - picks the group
Group← →, + - =head, default or bottom
Colour← →, a for autoA palette colour for every space of the key, or auto
The rename dialog on ACME - api: blue is picked in the colour row, and the sidebar preview shows ACME - api, its feature-checkout worktree and ACME - web all in blue
Renaming ACME - api: picking blue recolours every ACME space at once.
// 04

Set it up in five steps

  1. Install the plugin:
    herdr plugin install MrBogomips/herdr-tools/space-herder
  2. Optionally create config.json in herdr plugin config-dir mrbogomips.space-herder. This one sorts after every new or renamed space and keeps customers' colours apart:
    {
      "auto_sort": "both",
      "assign": "sticky"
    }
  3. Generate the sidebar rows; the path shows in a toast:
    herdr plugin action invoke mrbogomips.space-herder.snippet
  4. In ~/.config/herdr/config.toml, set rows of your [ui.sidebar.spaces] table to the value from that file, and bind the sort and the dialogs:
    [keys]
    new_workspace = "prefix+ctrl+n"    # Herdr's own prompts, still reachable
    rename_workspace = "prefix+ctrl+w"
    
    [[keys.command]]
    key = "prefix+shift+s"
    type = "plugin_action"
    command = "mrbogomips.space-herder.sort"
    
    [[keys.command]]
    key = "prefix+shift+n"
    type = "plugin_action"
    command = "mrbogomips.space-herder.new-space"
    
    [[keys.command]]
    key = "prefix+shift+w"
    type = "plugin_action"
    command = "mrbogomips.space-herder.rename-space"
  5. Check, then reload:
    herdr config check && herdr server reload-config

Never paste a second [ui.sidebar.spaces] table: a duplicate table makes the whole config invalid and Herdr falls back to its defaults, key bindings included.

// 05

Configuration

Every key is optional. The file is read on every run, so auto_sort changes apply at once.

Changed palette, palette_size or a rule's colour? The colours live in config.toml: run the snippet action again, put the new rows in config.toml, run herdr server reload-config, then the recolor action. The first comment line of the rows carries a fingerprint of the colours, so you can tell whether yours are current.

KeyDefaultMeaning
auto_sort"off""off", "created", "renamed" or "both"
palette"catppuccin"A preset name, or your own list of hex colours
palette_sizeallUse only the first N colours, to leave slots for rule colours
assign"hash""hash" or "sticky"
key"prefix""prefix", "suffix" or "whole"
separator" -"Splits prefix from suffix
marker"▌"Drawn before the name in the same colour
rules[]{"match": "<regex>", "color": ...}, checked before the key's colour

The README documents every key, the colour slots and the sticky assignments file.

// 06

Good to know

  • Herdr styles a token's foreground only, so there is no background colour: the marker before the name stands in for a swatch.
  • At most 15 colours, the tokens one sidebar row holds next to the agent-state dot.
  • The colours are 24-bit, like the dialogs' swatches: they need a terminal with truecolor support (iTerm2, Ghostty, WezTerm and kitty have it).
  • The colours show in the expanded sidebar; the collapsed rail and the mobile layout keep Herdr's own rendering.
  • ACME-api does not split on -: keep the space before the dash, or change separator.
  • A space dragged by hand goes back to its group at the next sort.