tmux-continuum: Autosave not working

Autosave is not working and I’ve narrowed it down to this piece of code:

# Advanced edge case handling: start auto-saving only if this is the
# only tmux server. We don't want saved files from more environments to
# overwrite each other.
if ! another_tmux_server_running; then
  # give user a chance to restore previously saved session
  delay_saving_environment_on_first_plugin_load
  add_resurrect_save_interpolation
fi

The problem is that I share my work environment with several co-workers. So, in total we may have > 3 tmux processes. This function grabs all of them:

all_tmux_processes() {
  # ignores `tmux source-file .tmux.conf` command used to reload tmux.conf
  ps -Ao "command pid" |
    \grep "^tmux" |
    \grep -v "^tmux source"
}

Long story short, it seems that add_resurrect_save_interpolation is never called because continuum thinks there are more than one TMUX servers running. Should it not consider only the running user’s processes?

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 6
  • Comments: 19 (2 by maintainers)

Commits related to this issue

Most upvoted comments

I also this problem. It seems that the default interval of 15 min isn’t applied. If I manually set set -g @continuum-save-interval '15' it /seems/ to work.

I judge by the output of scripts/continuum_status.sh which I put into my powerline configuration.

Not sure what exactly caused it but for me the culprit was https://github.com/jimeh/tmux-themepack. When sourcing my plugins with tpm I had to make sure to add the themepack before continuum.

Before (not working):

set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugins 'tmux-plugins/tmux-continuum'

set -g @plugin 'jimeh/tmux-themepack'

After (working):

set -g @plugin 'jimeh/tmux-themepack'

set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugins 'tmux-plugins/tmux-continuum'

Maybe it helps someone else 😃

If you are using “Oh My Tmux” (https://github.com/gpakosz/.tmux):

Open .tmux.conf and find the following line:

#   status_right=$(echo "$status_right" | sed 's%#{circled_session_name}%#(cut -c3- ~/.tmux.conf | sh -s _circled #S)%g')

Add these two lines after the above-mentioned line:

#   continuum_auto_save='#(~/.tmux/plugins/tmux-continuum/scripts/continuum_save.sh)'
#   status_right="$status_right$continuum_auto_save"

Save .tmux.conf and reload tmux configuration by <prefix> r inside a tmux session. Auto save should work now.

The added script doesn’t print anything so there isn’t anything added to your status-right visually. It just uses the refresh of the status line to run the save script.

If you have to modify status-right after tpm and want to use auto save, try adding this to your status-right: #(~/.tmux/plugins/tmux-continuum/scripts/continuum_save.sh)

Holy crap you’re right it is fixed for me now. Thank you so much for investigating this!

Would make sense as the auto save command gets written into status-right. So everything that sets status-right would have to be loaded beforehand.

At least if I got right from reading the code. In my opinion this should be stated in the readme (if correct).

EDIT: Just tested it by echoing from ./scripts/continuum_save.sh main(). The script is the first segment of the right status. So every modification of status-right has to be done before tpm sources continuum.

I had a problem with autosave though I’m using only one tmux server. I use tmux attach to attach the sessions. This gets counted in for all_tmux_processes. So, I added a grep -v for tmux attach in helpers.sh

all_tmux_processes() {
  # ignores `tmux source-file .tmux.conf` command used to reload tmux.conf
  ps -Ao "command pid" |
    \grep "^tmux" |
    \grep -v "^tmux source" |
    \grep -v "^tmux attach"
}

It works now.

Without the setting continuum_status.sh gives this:

./scripts/continuum_status.sh: line 12: [: -gt: unary operator expected
off