Add per-session save files/session manager script#557
Add per-session save files/session manager script#557philippossfrn wants to merge 1 commit intotmux-plugins:masterfrom
Conversation
resurrect.tmux
Outdated
| local attach_script="$bin_dir/attach" | ||
|
|
||
| # Only create if attach script doesn't already exist | ||
| if [ -f "$attach_script" ]; then |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Good point, fixed. Replaced all [ ] with [[ ]] for consistent bash syntax throughout the script.
resurrect.tmux
Outdated
|
|
||
| # List saved sessions | ||
| echo "Available saved tmux sessions:" | ||
| SAVED_SESSIONS=($(ls "$RESURRECT_DIR" | grep -vE 'last|readme')) |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
Maybe I'm paranoid, but would randomize the temp session name just in case. E.g. temp_session="temp-session-$RANDOM"
There was a problem hiding this comment.
Good catch, also added a timestamp suffix to avoid creating more than one session with the same name
ed75cff to
84cb3b9
Compare
- 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
84cb3b9 to
11c2757
Compare
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:
Why it's useful
Breaking changes
naming scheme.