Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add per-session save files/session manager script#557

Open
philippossfrn wants to merge 1 commit into
tmux-plugins:mastertmux-plugins/tmux-resurrect:masterfrom
philippossfrn:feature/per-session-saves-with-managerphilippossfrn/tmux-resurrect:feature/per-session-saves-with-managerCopy head branch name to clipboard
Open

Add per-session save files/session manager script#557
philippossfrn wants to merge 1 commit into
tmux-plugins:mastertmux-plugins/tmux-resurrect:masterfrom
philippossfrn:feature/per-session-saves-with-managerphilippossfrn/tmux-resurrect:feature/per-session-saves-with-managerCopy head branch name to clipboard

Conversation

@philippossfrn

Copy link
Copy Markdown
  • Modified resurrect_file_path() to save sessions using session name
  • Prompts user to name session if using default numeric name
  • Added session manager script to $HOME/bin/ on install
    • Interactive menu to attach, delete, or rename saved sessions
  • Allows multiple distinct session saves instead of single global file

What the change does

This modification enhances tmux-resurrect to save session state on a per-session basis rather than using a single global save file. Additionally, it includes a session manager script that
provides an interactive menu for managing saved sessions.

Core changes:

  • Modifies resurrect_file_path() to use the tmux session name as the save filename (e.g., ~/.tmux/resurrect/dev-project.txt instead of last)
  • Prompts the user to name their session if it still has the default numeric name (e.g., 0, 1)
  • Installs a tmux-session-manager script to $HOME/bin/ that allows users to:
    • Attach to a previously saved session
    • Delete saved session files
    • Rename saved sessions

Why it's useful

  • Multiple project workflows: Keep separate save states for different projects without overwriting each other
  • Cleaner organization: Session saves are named meaningfully instead of using timestamps
  • Easy management: The session manager script provides a simple way to browse, clean up, or reorganize saved sessions without manually navigating the resurrect directory
  • Safer restores: Restoring one session won't accidentally load state from a completely different project

Breaking changes

  • Save file location changed: Existing saves in ~/.tmux/resurrect/last will not be automatically migrated. Users should manually restore their old session once, then save it under the new
    naming scheme.
  • Session naming prompt: Users with default-named sessions will now be prompted to provide a name on first save. This can be skipped by pre-naming sessions with tmux rename-session.

Comment thread resurrect.tmux Outdated
local attach_script="$bin_dir/attach"

# Only create if attach script doesn't already exist
if [ -f "$attach_script" ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't mix posix [] with bash's [[]]. If we're writing bash, let's stay in bash syntax.
This applies not only to this line, but throughout this patch.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed. Replaced all [ ] with [[ ]] for consistent bash syntax throughout the script.

Comment thread resurrect.tmux Outdated

# List saved sessions
echo "Available saved tmux sessions:"
SAVED_SESSIONS=($(ls "$RESURRECT_DIR" | grep -vE 'last|readme'))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ls is generally frowned upon in script usage. Best collect directory contents using find. That way there's also no need for the filtering grep, as find can provide that functionality.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thought, done.

Comment thread resurrect.tmux Outdated
cp "$RESURRECT_DIR/$SELECTED_SESSION" "$RESURRECT_DIR/last"

# Ensure the tmux server is running by creating a detached session
tmux new-session -d -s temp_session 2>/dev/null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm paranoid, but would randomize the temp session name just in case. E.g. temp_session="temp-session-$RANDOM"

@philippossfrn philippossfrn Feb 2, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, also added a timestamp suffix to avoid creating more than one session with the same name

@philippossfrn
philippossfrn force-pushed the feature/per-session-saves-with-manager branch 3 times, most recently from 84cb3b9 to 11c2757 Compare February 2, 2026 21:13
  - Modified resurrect_file_path() to save sessions using session name
  - Prompts user to name session if using default numeric name
  - Added session manager script to $HOME/bin/ on install
    - Interactive menu to attach, delete, or rename saved sessions
  - Allows multiple distinct session saves instead of single global file
  - Randomize temp session name with PID and $RANDOM to avoid collisions
  - Only kill temp session if we successfully created it
  - Use dynamic path for restore.sh based on plugin install location
  - Add Unix timestamp suffix to saved session filenames
  - Add custom keybinding example to README
  - Use find cmd to list saved sessions
@philippossfrn
philippossfrn force-pushed the feature/per-session-saves-with-manager branch from 11c2757 to dc1dd01 Compare March 19, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.