termtitle

package
v0.95.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package termtitle formats and emits the terminal window/tab title.

Two titles carry a name, and terminals disagree about which one labels a tab: most (Ghostty, WezTerm, kitty, Alacritty, Terminal.app) follow the window title, while iTerm2 labels tabs from the icon name. Set writes OSC 0, which sets both at once.

Sidecar deliberately does not route this through charm.land/bubbletea/v2.View.WindowTitle. Bubble Tea clears a title it owns whenever the renderer stops — including for the length of every tea.ExecProcess child — which would blank the terminal title for as long as the user stays attached to a session. Owning the sequence here means the title simply persists across those handoffs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(tmpl string, v Vars) string

Render expands tmpl and sanitizes the result. An empty tmpl renders an empty title, which is how the feature is turned off.

{worktree} expands with its own leading space and brackets (" [branch]") so that the default template, "{project}{worktree}", collapses to just the project name when there is no linked worktree.

func Restore

func Restore() string

Restore pops the titles saved by Save.

func Save

func Save() string

Save pushes the current titles onto the terminal's title stack, and Restore pops them back.

The parameter is 0 — icon name *and* window title, matching what Set writes — rather than 2, which would cover only the window title and leave the iTerm2 tab label pointing at the wrong project after exit. Terminals that don't implement the XTWINOPS title stack ignore both, and keep the last title sidecar set.

func Set

func Set(s string) string

Set returns the sequence naming the terminal (OSC 0), which sets the icon name and the window title together — between them they cover the tab label of every terminal sidecar targets.

Types

type Vars

type Vars struct {
	Project  string // repo name, e.g. "sidecar"
	Worktree string // branch of a linked worktree, empty on the main worktree
	Plugin   string // active plugin/tab name, e.g. "workspaces"
	Dir      string // base name of the working directory
}

Vars holds the substitutions available to a title template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL