Skip to content

auto-tab-name: Herdr tabs that name themselves

Plugin · v0.3.0 · Herdr 0.9.5 or newer · macOS and Linux

auto-tab-name gives each Herdr tab the name of its pane’s current folder, keeps it in sync as you and your agents move around, and leaves manually named tabs untouched.

herdr plugin install MrBogomips/herdr-tools/auto-tab-name
Before: tabs named 1, 2, 3. After: each tab shows where its pane is working, including the worktree branch.

By default, Herdr labels an unnamed tab with its position number. auto-tab-name renames those tabs after their pane’s folder, updating a tab only when its name changes. For ~/tools/initech/sort, inside the repository initech on branch main:

format Name Outside a repository
basename (default) sort Same
repo initech/sort Same as basename
last_n initech/sort (last depth folders) Same
home_path ~/tools/initech/sort Same
repo_branch initech@main (or the short hash when detached) Same as basename

In a linked worktree, the tab shows the main repository’s name. auto-tab-name finds the repository by reading .git directly, without running a git process.

By default, the tab name comes from the foreground program’s folder rather than the shell’s. When an agent starts in ~/tools/initech and moves into the .worktrees/login worktree, the tab reflects the change:

format "cwd" (shell) "foreground_cwd" (default)
basename initech login
repo_branch initech@main initech@feature/login

Because Herdr has no event for a folder change, the tab name updates at the agent’s next state change: when it becomes ready, and at the latest when the turn that moved it ends.

  • A new tab starts with its position number, so it follows its folder from the start.
  • Renaming a tab manually stops it from following, so your name stays.
  • Running follow makes it follow again, as does renaming the tab back to its position number.
  • Restarting Herdr changes nothing: any tab whose name already matches its folder is treated as followed.

Bind the actions you want in ~/.config/herdr/config.toml, then run herdr server reload-config:

[[keys.command]]
key = "prefix+alt+c"
type = "plugin_action"
command = "mrbogomips.auto-tab-name.configure"
[[keys.command]]
key = "prefix+alt+t"
type = "plugin_action"
command = "mrbogomips.auto-tab-name.toggle"
[[keys.command]]
key = "prefix+alt+f"
type = "plugin_action"
command = "mrbogomips.auto-tab-name.follow"

On macOS, an alt binding reaches Herdr only if your terminal sends Option as Alt. In iTerm2, set Profiles › Keys › Left Option key to “Esc+”; in Ghostty, set macos-option-as-alt = left. That leaves the right Option key free for characters your keyboard layout types with it (such as ~, @ and # on an Italian keyboard). Terminal’s “Use Option as Meta key” takes both Option keys; in Terminal, or if you prefer not to change your terminal settings, bind prefix+<letter> keys instead.

Each action uses the mrbogomips.auto-tab-name. prefix shown above:

Action What it does
configure Opens the configuration popup
toggle Turns auto_sync on or off
sync Renames every followed tab immediately
follow / unfollow Makes the current tab follow its folder, or keeps its current name
refresh Runs quietly, intended for shell integration

Without shell integration, a tab name catches up at the next focus or tab change. To rename the tab as soon as you run cd, add this hook to ~/.zshrc (bash and fish versions are in the README):

~/.zshrcShell
if [[ $HERDR_ENV == 1 && -n $HERDR_BIN_PATH ]]; then
autoload -Uz add-zsh-hook
_auto_tab_name_chpwd() { "$HERDR_BIN_PATH" plugin action invoke mrbogomips.auto-tab-name.refresh >/dev/null 2>&1 &! }
add-zsh-hook chpwd _auto_tab_name_chpwd
fi

The hook runs only inside Herdr and in the background, so your prompt never waits.

The configure popup updates config.json for you; auto-tab-name reads the file on every run.

Key Default Meaning
auto_sync true Automatically rename tabs from hooks
format "basename" What the name shows (see formats)
depth 2 Number of folders shown by last_n
max_length 24 Maximum name length before truncating with …; 0 disables the limit
source "foreground_cwd" Folder of the foreground program, or "cwd" for the shell’s folder
home_tilde true Write the home folder as ~
  • Herdr fires no event on cd: without shell integration, a tab name updates at the next focus or tab change.
  • In a tab with several panes, auto-tab-name uses the pane you last focused.
  • With repo or repo_branch, a Git repository in your home folder (such as dotfiles) supplies the name for every folder under home that is not inside another repository.

Install · Full README on GitHub