Preserve empty pane titles during save and restore#581
Open
chirayuk wants to merge 5 commits into
tmux-plugins:mastertmux-plugins/tmux-resurrect:masterfrom
chirayuk:fix/empty-pane-titlechirayuk/tmux-resurrect:fix/empty-pane-titleCopy head branch name to clipboard
Open
Preserve empty pane titles during save and restore#581chirayuk wants to merge 5 commits intotmux-plugins:mastertmux-plugins/tmux-resurrect:masterfrom chirayuk:fix/empty-pane-titlechirayuk/tmux-resurrect:fix/empty-pane-titleCopy head branch name to clipboard
chirayuk wants to merge 5 commits into
tmux-plugins:mastertmux-plugins/tmux-resurrect:masterfrom
chirayuk:fix/empty-pane-titlechirayuk/tmux-resurrect:fix/empty-pane-titleCopy head branch name to clipboard
Conversation
When pane_title is empty, the save file contains consecutive tab
delimiters. Bash's IFS=$'\t' read collapses these (POSIX whitespace
IFS behavior), shifting every field after pane_title one position
left. This puts pane_active into the dir field, causing panes to
restore in the wrong directory.
Use tmux conditional format #{?pane_title,#{pane_title},_} to
guarantee a non-empty field, outputting "_" for untitled panes.
Fixes tmux-plugins#437
Use the colon guard proposed in tmux-plugins#570 and retain the Docker regression coverage. Co-authored-by: Mateusz Kozlowski <kooziu@gmail.com>
odj1001extra
pushed a commit
to odj1001extra/tmux-resurrect
that referenced
this pull request
Jul 21, 2026
When pane_title is empty, the tab-delimited save format emits adjacent
tabs. Tab is an IFS-whitespace character, so the `IFS=$d read ...` loops
in dump_panes (save.sh) and restore_pane (restore.sh) collapse the empty
field and shift every later value left by one. dir is then read from the
pane_active column ("1"), remove_first_char reduces it to "", and restore
runs `tmux split-window -c ""`, which falls back to $HOME. Only panes
whose title was empty lose their working directory, which is why this
stays hidden for most users.
Give pane_title the same leading ':' guard already used for the other
optional fields (window_flags, pane_current_path, window_name,
full_command) and strip it back off during restore. The field is never
empty on disk, so it cannot collapse, and a genuinely empty title is
still restored as empty.
The awk parse sites in restore.sh are unaffected: awk with FS="\t" does
not collapse empty fields, and the field count is unchanged.
This is the lossless approach proposed by @mtkozlowski in
tmux-plugins#570 and carried forward in tmux-plugins#581.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pane_titlewith the same leading:used for other optionalsnapshot fields;
title and distinct non-empty titles;
When
pane_titleis empty, the current format emits adjacent tabs. Bashtreats tab as IFS whitespace and collapses that empty field, shifting every
later value left. Restore then reads
pane_activeas the directory and opensthe pane in
$HOMEinstead of its saved working directory.The colon guard makes the field non-empty on disk while still restoring the
original empty value.
Attribution
This uses the lossless approach proposed by @mtkozlowski in #570. That PR was
closed before maintainer review; its author is credited in the implementation
commit. This PR retains that idea and adds automated save/restore regression
coverage in an isolated environment.
Test environment
The Docker runner has no host mounts or network access, runs as a non-root
user with a read-only root filesystem, and verifies exact container ownership
before cleanup. The pinned environment uses Ubuntu 24.04, tmux 3.4, Bash, and
a 200-by-50 pseudo-terminal.
Verification