Skip to content

Instantly share code, notes, and snippets.

@gwpl
Last active May 7, 2026 16:46
Show Gist options
  • Select an option

  • Save gwpl/a4263cedda11c9720490aecaaa39b197 to your computer and use it in GitHub Desktop.

Select an option

Save gwpl/a4263cedda11c9720490aecaaa39b197 to your computer and use it in GitHub Desktop.
Tmux Tab signaling and KDE Konsole Adjustements for better... TODO: better concise desrciption
title tmux session/window names → KDE Konsole tabs (incl. nested tmux)
description How to make tmux's current session and window name show up live in the KDE Konsole tab, including the nested case where an outer tmux ("ubertmux") wraps an inner tmux.
last-updated 2026-05-07

TL;DR

Make Konsole's tab text track the current tmux session | window, live, even when an outer tmux (e.g. ubertmux) wraps an inner tmux.

Outcome

  • Konsole tab shows e.g. work | editor instead of bash / tmux / a stale program name.
  • Switching session or window inside (inner) tmux updates the Konsole tab immediately.
  • Works through one layer (Konsole → tmux) and through two layers (Konsole → outer tmux → inner tmux).

Minimum setup

1. Inner tmux~/.tmux.conf:

set -g set-titles on
set -g set-titles-string "#S | #W"

2. Outer / nested tmux (only if you run tmux-inside-tmux, e.g. ubertmux) — its config:

set -g set-titles on
set -g set-titles-string "#T"
set -g automatic-rename-format '#{?#{==:#{pane_title},},#{pane_current_command},#{pane_title}}'

3. Konsole — Settings → Edit Current Profile → Tabs:

  • Tab title format: %w : %d : %n
  • Remote tab title format: %w (%H/%u)

%w is the placeholder for the OSC title that tmux sends. Without %w Konsole silently ignores everything tmux emits.

Sanity check (run from a shell)

printf '\e]2;HELLO_KONSOLE\a'

If the tab does not change to HELLO_KONSOLE, your Konsole profile is missing %w — fix that before debugging tmux.

Why this works (one paragraph)

tmux emits an OSC escape (ESC ] 2 ; <text> BEL) whenever its rendered set-titles-string changes. Konsole captures that as the window title and renders it in the tab via %w. In the nested case, an outer tmux also captures the inner OSC as the pane's pane_title (#T) — so the outer can re-emit #T upward and reuse #T as its own window-tab name, preserving the inner identity through both layers.

More detail

See also

  • shibuido/ubertmux — the outer-tmux setup this gist's nested case is written for. The 20-outer-tmux-nested.md file documents the OSC-propagation config that pairs with it.
title Inner tmux — emit session/window as OSC title
description tmux config that makes (inner) tmux send its current session and window name as an OSC 2 escape sequence so the surrounding terminal (Konsole, or an outer tmux) can pick it up.
last-updated 2026-05-07

Inner tmux: emit OSC title

The job of the inner tmux is to push its current identity outward as a standard terminal title escape. Everything downstream (Konsole, an outer tmux) just consumes it.

Config

set -g set-titles on
set -g set-titles-string "#S | #W"

That's it. With set-titles on, tmux writes the rendered set-titles-string as ESC ] 2 ; <text> BEL (OSC 2 — set window title) to whatever PTY this tmux server is connected through.

Format choice

#S | #W is a good default:

  • #S — session name (most identifying piece).
  • #W — current window name (which window is focused when the session has several).
  • The literal | survives as plain text through both an outer tmux and Konsole's tab rendering.

Useful alternatives:

  • "#S" — session only, shortest.
  • "#S:#I.#P #W" — session:window.pane plus window name (info-dense).
  • "tmux: #S — #W" — prefix so you can tell tmux tabs apart from non-tmux ones at a glance.

Reload

tmux source-file ~/.tmux.conf

Existing windows pick up the new format on the next rename trigger (process change, focus change, etc.). For a clean slate, detach and reattach the session.

Watch out: shells racing tmux for the title

If your shell prompt code also writes OSC titles, you'll see the tab flicker between the tmux-set value and user@host: ~/path:

  • bashPROMPT_COMMAND setting \033]0;...\007 (common in distro defaults).
  • zshprecmd hooks; oh-my-zsh themes do this aggressively.

Either disable the shell's title-setting, or accept that the shell updates the title on each prompt while tmux updates it on session/window change. Pick one writer.

Verify tmux is actually emitting

Inside tmux:

tmux show-options -g | grep set-titles

Should show set-titles on and your format string. To see what Konsole would receive, attach cat -v to a pipe and trigger a rename — but the simplest end-to-end check is the manual OSC test in 00-README.md.

title Outer tmux — propagate inner tmux title through a wrapping tmux
description How to configure an outer (wrapping) tmux so that the inner tmux's session/window name shows on both the outer tmux's window tab and the surrounding Konsole tab.
last-updated 2026-05-07

Outer tmux: propagate the inner title

You only need this file if you run tmux inside another tmux — e.g. ubertmux, an outer-tmux setup whose panes each launch their own inner tmux. With a single tmux layer, the 10-inner-tmux.md config plus a %w-aware Konsole profile is enough.

The propagation chain

inner tmux  ──OSC 2──▶  outer tmux  ──OSC 2──▶  Konsole tab (%w)
                  (captured as #T)        (re-emitted as #T)

Three things have to happen:

  1. Inner tmux emits its session/window as an OSC title (see 10-inner-tmux.md).
  2. Outer tmux captures that automatically as the pane's pane_title (#T) — no config flag controls this; it's built-in tmux behavior.
  3. Outer tmux then has to do two things explicitly:
    • Re-emit #T as its own OSC title so Konsole sees the inner identity (not the outer tmux's session name).
    • Use #T as its window-tab name so each outer-tab shows the inner session it's hosting (instead of all tabs collapsing to the same wrapper command name).

Config

In the outer tmux's config:

set -g set-titles on
set -g set-titles-string "#T"

set -g automatic-rename-format '#{?#{==:#{pane_title},},#{pane_current_command},#{pane_title}}'

What each line does:

  • set-titles on + set-titles-string "#T" — outer tmux emits the captured inner title upward to Konsole.
  • automatic-rename-format — outer tmux's window tab name. Default is pane_current_command, which collapses every tab to the wrapper binary name (e.g. tmux, bash, or whatever launches the inner tmux). The ternary uses #T when it's set, falling back to pane_current_command for raw shells / panes without a TUI title.

Gotchas

  • automatic-rename auto-disables the moment you (or a script) call rename-window on a window. To bulk re-enable:

    for w in $(tmux list-windows -t OUTER_SESSION -F '#{window_index}'); do
      tmux setw -t OUTER_SESSION:$w automatic-rename on
    done
  • Format changes don't apply retroactively. tmux only re-evaluates automatic-rename-format on rename triggers (process change, title change). After editing the format string, existing windows keep their old names until the next trigger. Toggle automatic-rename off→on to force a refresh.

  • Bare-bash panes (no inner tmux, no TUI setting a title) leave pane_title empty. The ?: fallback uses pane_current_command so the tab isn't blank.

  • Konsole still needs %w in the profile (see 30-konsole-profile.md). The propagation chain is complete only if every layer participates.

End-to-end verification

From a shell inside the inner tmux:

printf '\e]2;HELLO_INNER\a'

You should see:

  • The outer tmux's window-tab change to HELLO_INNER.
  • The Konsole tab change to HELLO_INNER (assuming your Konsole profile uses %w).

If only the outer tab updates but Konsole doesn't, check Konsole's tab title format. If neither updates, recheck set-titles on in both tmux configs and automatic-rename-format in the outer.

title KDE Konsole — tab title format codes
description Konsole profile tab title format codes and recommended formats for displaying the OSC title that tmux (or any program) emits.
last-updated 2026-05-07
sources

Konsole profile — make %w visible

For tmux's OSC title to actually appear on the Konsole tab, the Konsole profile's Tab title format must include %w.

Where

Settings → Edit Current Profile → Tabs:

  • Tab title format (used for local sessions)
  • Remote tab title format (Konsole auto-switches to this when an ssh foreground process is detected)

You can also reach a temporary version by double-clicking a tab or pressing Ctrl+Alt+S, but that change does not persist unless the profile is saved.

Recommended formats

Tab title format:        %w : %d : %n
Remote tab title format: %w (%H/%u)

Why this composition:

  • %w is what tmux just sent; it's the load-bearing piece.
  • %d (cwd basename) and %n (program name) give you readable fallback content when nothing has set a title yet (e.g. before tmux starts).
  • On remote sessions, %H/%u tells you which host/user you're on at a glance.

Format codes

Both Tab title and Remote tab title fields support:

Code Meaning
%w OSC window title (what tmux / TUIs send)
%n Program name (e.g. bash, tmux, ssh)
%d Current working directory, basename
%D Current working directory, full path
%u User name (remote user in the remote format)
%h Local host name (short)
%H Remote host name (populated in remote format)
%B "on <host>" remote indicator
%# Konsole session number

Common Konsole defaults are %d : %n (local) and (%u) %H (remote) — neither contains %w, which is why OSC titles silently appear unused until you add %w.

Sanity check

From any shell inside Konsole:

printf '\e]2;HELLO_KONSOLE\a'

If the tab does not change to HELLO_KONSOLE, the profile is dropping the OSC. Add %w.

title KDE Konsole tab naming — Claude conversation source
description Original Claude conversation that seeded the single-layer (Konsole → tmux) recipe. Kept for provenance; the cleaned-up version lives in 10-inner-tmux.md and 30-konsole-profile.md.
source https://claude.ai/share/898decfb-acb2-4e60-b068-9ba5395ffe62
timestamp 2026-05-05

Yes, absolutely — and it's a clean setup once you know which knobs to turn.

Why it works

There's a chain of three actors:

  1. tmux can emit OSC (Operating System Command) terminal escape sequences — specifically ESC ] 0 ; <text> BEL — which is the standard "set window title" sequence going back to xterm.
  2. Konsole, the terminal emulator, listens for those sequences and stores the value as the window title of that pty.
  3. Konsole's tab title format can be configured to display that window title in the tab.

So tmux "tells" Konsole what to show, and Konsole renders it on the tab. When you switch sessions inside tmux (prefix + s, :switch-client, etc.), tmux re-emits the OSC sequence with the new session name, and the tab updates live.

By default, tmux either doesn't set titles at all or passes through whatever the inner program sets — which is why your tab probably shows something stale like bash or the last vim filename.

How to wire it up

1. tmux side — in ~/.tmux.conf:

set -g set-titles on
set -g set-titles-string "#S"

#S is the session name. Useful alternatives:

  • "#S | #W" — session + current window name
  • "#S:#I.#P #W" — session:window.pane window-name (more info-dense, fits your style)
  • "tmux: #S — #W" — prefixed so you can tell tmux tabs apart from non-tmux ones

Reload with tmux source-file ~/.tmux.conf and detach/reattach existing sessions for it to take effect cleanly.

2. Konsole side — Settings → Edit Current Profile → Tabs → Tab title format:

%w

%w is the placeholder for the window title set by the terminal program (i.e. what tmux just sent). If you want a fallback so the tab isn't blank before tmux starts, use something like:

%w

and set Remote tab title format to whatever you want when SSH'd. Konsole also supports combining: %n: %w shows the program name and the tmux-set title.

3. Make sure nothing is fighting tmux for the title. If your shell PROMPT_COMMAND (bash) or precmd (zsh) also writes OSC 0 sequences (oh-my-zsh themes love to do this), they'll race tmux and you'll see the title flicker between the session name and user@host: ~/path. Either disable that in your shell rc, or accept that the shell sets it inside tmux while tmux sets it on session/window change — your call.

Quick sanity check

After reloading, run this from inside tmux to see the raw escape sequence tmux is producing:

tmux show-options -g | grep set-titles

And to manually verify Konsole reacts at all, outside tmux:

printf '\033]0;hello-from-osc\007'

If your tab changes to hello-from-osc, the Konsole side is wired correctly and any remaining issue is on the tmux config.

Error in user YAML: (<unknown>): mapping values are not allowed in this context at line 2 column 75
---
title: KDE Konsole tab naming — Perplexity source
description: Original Perplexity search that produced the recommended `%w : %d : %n` / `%w (%H/%u)` Konsole tab title formats. Kept for provenance; the cleaned-up version lives in 30-konsole-profile.md.
source: https://www.perplexity.ai/search/76833ad8-5d4a-4533-a395-1942d9ad1aeb
timestamp: 2026-05-05
---

Prompt:

How to make on KDE Konsole so default tab title setting
becomes `%w : %d : %n`
and remote tab setting becomes `%w (%H/%u)`

Open Konsole, go to Settings -> Edit Current Profile... -> Tabs, then set Tab title format to %w : %d : %n and Remote tab title format to %w (%H/%u). docs.kde

Profile settings

Those fields are the permanent profile settings for local and remote tab titles, while the rename-tab dialog only changes them temporarily unless you save the profile. You can also reach the temporary dialog by double-clicking a tab or pressing Ctrl+Alt+S, but for a persistent default you should edit the profile itself. docs.kde

Token meanings

For local tabs, %w is the window title set by the shell, %d is the current directory in short form, and %n is the program name. For remote tabs, %H is the remote host in long form and %u is the user name, so %w (%H/%u) shows the shell-set title plus host/user. docs.kde

Exact values

Use these exact strings in the two boxes: docs.kde

  • Local Tab title format: %w : %d : %n docs.kde
  • Remote Remote tab title format: %w (%H/%u) docs.kde

If the menu wording on your version says Configure Konsole -> Profiles -> your profile -> Edit -> Tabs, that is the same place. blog.jj5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment