Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New window is always added when auto restoring tmux environment #50

Open
while0pass opened this issue May 30, 2018 · 16 comments
Open

New window is always added when auto restoring tmux environment #50

while0pass opened this issue May 30, 2018 · 16 comments

Comments

@while0pass
Copy link

Every time I start tmux and it restores the environment, a new additional session with a blank window is added. There is no such a problem if I restore my sessions with tmux-ressurect manually.

@dylan-chong
Copy link

I find this annoying too. I think there should be an option to remove the session that appears when tmux is started up

@AdrienLemaire
Copy link

As a temporary hack, I added tmux kill-session -t 0 before the main() stop_spinner call in .tmux/plugins/tmux-resurrect/scripts/restore.sh:369, since all my sessions are named and the unwanted one is always called 0

@aguytech
Copy link

aguytech commented Dec 8, 2020

Hi,
Here is a possible solution to this issue : pull-request #83

The problem to clean this added session at each restart is that when you are in the process of daemon creation (calling tmux-continuum), you can't kill session.
So i had to externalize the call of tmux daemon in the script to have possibility to kill session after the daemon is started.

@dylan-chong
Copy link

For some reason a new window is no longer created for me now

@aguytech
Copy link

aguytech commented Dec 8, 2020

@dylan-chong Which OS and tmux version do you use ?

@aguytech
Copy link

aguytech commented Dec 8, 2020

For me:
I tried few days ago with a fresh install of tmux-resurrect & tmux-continuum from github
my tmux version are 3.1_c-1
Os: manjaro

Here is my problem:

$ tmux ls
0: 1 windows (created Sun Nov 29 01:04:07 2020)
$ systemctl restart --user tmux.service
$ systemctl restart --user tmux.service
$ systemctl restart --user tmux.service
$ tmux ls
0: 1 windows (created Sun Nov 29 01:14:50 2020)
1: 1 windows (created Sun Nov 29 01:14:50 2020)
2: 1 windows (created Sun Nov 29 01:14:50 2020)
3: 1 windows (created Sun Nov 29 01:14:51 2020)

Something seems to be wrong?

Here is my file .tmux.conf without binds:

# prefix key
set-option -g prefix C-q
# time allowed to repeat key following prefix key
set-option -g repeat-time 500
# set history to 5000
set-option -g history-limit 5000

# tmux-continuum
set -g @continuum-boot 'on'
set -g @continuum-restore 'on'

####  plugins

# resurect plugin
run-shell ~/.tmux/plugins/tmux-resurrect/resurrect.tmux
run-shell ~/.tmux/plugins/tmux-continuum/continuum.tmux

@dylan-chong
Copy link

dylan-chong commented Dec 8, 2020

@dylan-chong Which OS and tmux version do you use ?

> tmux -V
tmux 3.1c

Mac os 10.14.6

My tmux conf is here dylan-chong/dotfiles@0c9a484

@aguytech
Copy link

aguytech commented Dec 8, 2020

Mac os 10.14.6

Ok the problem seems to come from systemd (linux)

@dylan-chong
Copy link

Nevermind. the problem is back for me :(
I swear it was fine in the last few weeks

@austinbutler
Copy link

Yeah this happens for me on MacOS.

@bruno-
Copy link
Member

bruno- commented Dec 15, 2020

Hey guys,
the original problem with session 0 being always present is solved via tmux-plugins/tmux-resurrect@5f5f9d8

About the new problem "session with an increasing session number appears after restart":

  • I confirm we have a bug.
  • I suspect that's a bug in tmux-resurrect, not tmux-continuum (but we can continue the discussion here).
  • I tried reproducing this yesterday, but I was unable to. I'm running tmux next-3.3.
  • Having detailed reproduction steps would be useful at this point. Please ensure you have latest tmux-resurrect and tmux-continuum installed. Please also try with latest tmux version.

@ioogithub
Copy link

What is the current status of this bug?

I am a new user to tmux and tmux-continuum so I am confused at what I was seeing. I expected that I this plugin will being me back to my saved session when I had the following settings:

set -g @continuum-boot 'on'
set -g @continuum-restore 'on'

Instead I always got a new session with a new higher session number that I have to manually get rid of. This actually creates more work than not using the feature at all.

Is this the expected behavior or is this still the bug. From a (confused) new user perspective I wanted the plugin to restore my last saved session. When I launch tmux I wanted it to bring me back to this session. When I started the computer I wanted tmux to return me to the last saved session but it doesn't do this at all.
This bug report was opened almost 3 years ago... is this feature still currently broken? Are there any easy work arounds?

@UbiquitousPhoton
Copy link
Contributor

There is one easy workaround: set @continuum-systemd-start-cmd = 'start-server'

It defaults to new-session -d, which creates the new session each time, then restores the others. I am not entirely sure why.

Note that setting this variable is not enough, you need to force regeneration of your systemd unit file - so either delete ~/.config/systemd/user/tmux.service and the script should recreate it, or just hand edit the aforementioned file manually.

@ioogithub
Copy link

ioogithub commented Aug 29, 2022

There is one easy workaround: set @continuum-systemd-start-cmd = 'start-server'

What does between the " " is this where you place the command you want to start or is this command complete as it is? I tried this but it did not work. When I enable this command and reload tmux I still get the default. I saw the documentation mentioned this as well but I have tried several different attempts and never got it working.

@ioogithub
Copy link

ioogithub commented Aug 29, 2022

the original problem with session 0 being always present is solved via tmux-plugins/tmux-resurrect@5f5f9d8

Has anyone else confirmed this change is working? I am running tmux 3.2a and tmux-restore version 4.0 (as per the CHANGELOG.mg file in my ~.tmux/plugins/tmux-resurrect/ folder) but I get a new 0 session after every restore. I have tested this extensively tonight.

I believe this 0 session is also causing other issues with restoring.

Example after a restore:

user@server:~$ tmux list-session
0: 1 windows (created Sun Aug 28 22:27:48 2022)
test: 7 windows (created Sun Aug 28 22:27:46 2022) (attached)

@kranich
Copy link

kranich commented May 19, 2024

When I installed tmux-continuum via tpm, my stored sessions were restored and I did not get any extra session. When I called tmux-continuum directly from tmux.conf with

run-shell <path to continuum.tmux>

I always ended up with my stored sessions being restored and an extra session.

I believe that the cause for that is the order of execution. In the former case, tmux would source tmux.conf, then create a new session, then tpm would invoke tmux-continuum and it would call tmux-resurrect to correctly restore my stored sessions replacing the existing session. In the latter case, tmux would source tmux.conf, calling tmux-continuum and waiting for it, then tmux-continuum would call tmux-resurrect to restore the stored sessions, and only then tmux would finish its initialization by creating a new session.

I could fix that behaviour by running continuum.tmux in the background at the bottom of tmux.conf with

run-shell -b <path to continuum.tmux>

i.e. by adding the -b flag to run-shell. Like that, tmux does not wait for continuum.tmux and instead finishes its initialization and creates a new session before tmux-continuum calls tmux-resurrect to restore the stored sessions.

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

No branches or pull requests

9 participants