Skip to content

[Bug] Lost CWD and duplicated command prompts on restore with pane contents enabled #555

@szfkamil

Description

@szfkamil

When using tmux-resurrect with restore-pane-contents enabled, restoring a session results in two issues:

  1. Lost CWD: The pane's working directory resets to $HOME.
  2. Ghost prompts: 2 (or more) empty command prompts are printed to stdout upon restore. Over several days/restores, these empty prompts
    accumulate (e.g., 9+ lines), pushing actual content off-screen.

Screencast of the issue

Environment

  • OS: Debian GNU/Linux 13 (trixie)
  • Kernel: 6.12.38+deb13-amd64
  • Tmux Version: 3.5a
  • Shell: Zsh
  • Plugins: tmux-sensible, tmux-continuum, tmux-pain-control, tmux-sessionist, tmux-open
  • TPM: Up-to-date

Configuration
Here is my full .tmux.conf. Note that I use tmux-sensible.

# Use Ctrl-Space as prefix
unbind-key C-b
set-option -g prefix C-Space
bind-key C-Space send-prefix

set -s prefix-timeout 1000
set -g status-style bg=red,fg=white

# make page up/down just work
set -g mouse on
setw -g mode-keys vi
#bind -n PageUp copy-mode -u
#bind -n PageDown send-keys PageDown

# sets zsh as default tmux shell
set-option -g default-shell /bin/zsh

# sets up right status bar
set -g status-right 'Continuum status: #{continuum_status}#{?client_prefix, #[fg=00ff00][PFX],}'
# sets up left status bar to remove [username]
set -g status-left-length 30
set -g status-left ' [#S]'

# Format for inactive windows (just the name)
setw -g window-status-format ' #{window_name} '

# Format for the currently active window (styled name)
# Using #[reverse] is a common way to highlight
setw -g window-status-current-format ' #[reverse] #{window_name} '

set -g status-justify centre

# Cyberpunk status bar
set -g status-style bg='#111111',fg='#00ff00'
#set -g status-left '#[fg=#ff00ff,bold]#S #[fg=#00ffff]#I:#P #[default]| '
#set -g status-right '#[fg=#ffff00]%H:%M #[fg=#ff00ff,bold]#H'
set -g window-status-current-style 'fg=#00ff00,bg=#000000,bold'
#set -g window-status-current-format '#I:#W#F'
set -g window-status-style 'fg=#555555,bg=#000000'
#set -g window-status-format '#I:#W#F'


# Plugin options set before initialising them
set -g @continuum-save-interval 15
set -g @continuum-restore 'on'
set -g @resurrect-capture-pane-contents 'on'

##### Always keep this at EOF #####

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-sessionist'
set -g @plugin 'tmux-plugins/tmux-open'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'

#run-shell ~/Repositories/Misc/tmux-pain-control/pain-control.tmux
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.config/tmux/plugins/tpm/tpm'

Observation

  • The issue seems slightly arbitrary; sometimes it prints the 2 lines, other times it doesn't, but after a few days of continuum saves it can accumulate to 9+ lines. The older the window, the more lines it accumulates.
  • I tested if a new command prompt line is printed with each restore inside every window of every session, but that is not the case. Not even just for the active session (currently focused, or the one which of which focus was restored).
  • The issue stops when restore pane contents is disabled, so it is specific to it.

Hypothesis
I suspect this might be related to how tmux handles login vs. non-login shells.

  • default-shell is /bin/zsh.
  • default-command is unset (so tmux spawns a login shell).
  • My .zshrc does not contain any cd commands that would force a reset to $HOME.

Has anyone encountered this specific conflict between restore-pane-contents and login shells?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions