tmux-continuum icon indicating copy to clipboard operation
tmux-continuum copied to clipboard

can I only save the last tmux environment file?

Open ii0 opened this issue 10 years ago • 5 comments

It's good to save all tmux environment files in ~/.tmux/resurrect/ directory. but for people like me who only need the last one file, saving other files maybe not useful.

Can you tmux hero add a switch or other method to only save the last tmux environment file? such as: set -g @continuum-save-only-one-file 'on'

many thanks. ^_^

ii0 avatar Jul 23 '15 05:07 ii0

Hey, I never thought of doing that. What are the specific downsides of current implementation (just keeping all the files)? I'm using this and disk space overhead is negligible.

bruno- avatar Jul 23 '15 11:07 bruno-

While not exactly what @wakeid suggested, I implemented this by adding a simple cron job to delete old files but the latest 10 using something like ls ~/.tmux/resurrect/* -1dtr | head -n -10 | xargs -d '\n' rm -f. Having said that, a configuration setting would also be a nice-to-have feature.

gdebat avatar Aug 30 '15 23:08 gdebat

@gdebat thanks for sharing the snippet, I will likely use it in my install.
I accept that tmux-continuum's disk space consumption is probably negligible but the current implementation doesn't seem robust, e.g. what if users turned up the save rate? What about on a server with limited HD space? I know it would allow restoring historical sessions, but personally I can't see myself needed that - so I have been trying to think of a similar solution that could be implemented within tmux continuum itself - rather than a cron job - and offering as a pull request. I just haven't had time to look into it.

michael-coleman avatar Nov 21 '15 01:11 michael-coleman

similar solution that could be implemented within tmux continuum itself - rather than a cron job - and offering as a pull request

PR for this would be great.

bruno- avatar Nov 21 '15 16:11 bruno-

Cool, By the way thanks for your great work on tmux-resurrect and continuum! Heres what I've done to add a cron job on my system

# create cron job to delete old tmux-continuum save files
cat <<- EOF > /etc/cron.hourly/remove_old_tmux_continuum_saves
#! /bin/bash
ls ~/.tmux/resurrect/* -1dtr | head -n -10 | xargs -d '\n' rm -f
EOF
chmod +x /etc/cron.hourly/remove_old_tmux_continuum_saves

But it needs to be run as root to establish the cron job - so I think it would be better if it was managed inside the plugin - where the current behaviour is retained, but those who want to limit the amount of save files can toggle it on somehow.
Regarding adding something into the plugin itself, I took a look the continuum code today - and it looks like the logic/function for establishing how long has passed since the last save and deciding if a save should be made or not is in continuum. But I couldn't find the where the call to that function is located?
I'm wondering if the call to make the save is made inside tmux-resurrect ? And what event triggers the call?

michael-coleman avatar Nov 21 '15 16:11 michael-coleman