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

Systemd: Modifications to remove new session after restoration

Open aguytech opened this issue 5 years ago • 5 comments

The purpose of this modification is to allow session restoration on linux: the way are to :

  • Create a labeled session "${tmux_server_session_temporary}" on start of tmux daemon

Let plugin script "restore.sh" restore tmux session

  • Clean restored session by remove the temporary session "${tmux_server_session_temporary}" which having served to load the tmux daemon

After the start of tmux daemon, start simply tmux with the following command in a terminal console : tmux a / attach / attach-session or automate the start of tmux in terminal with adding line to the .basrhrc user file: type tmux &>/dev/null && tmux ls &>/dev/null && [ -z $TMUX ] && [[ ! $TERM =~ screen ]] && tmux attach-session

;o)

aguytech avatar Nov 21 '20 23:11 aguytech

So, why is new-session -d not doing the trick?

Let plugin script "restore.sh" restore tmux session

Note that if someone is running tmux plugins in the background via run -b (eg run -b '~/.tmux/plugins/tpm/tpm') you may end up killing the temporary session immediately after start, before anything is restored.

bruno- avatar Nov 22 '20 13:11 bruno-

It's doing the trick, it start the daemon with creation of a NEW session. At each restart of daemon a new session is created, saved and restored. x retstarts -> x new sessions. Not so fun ;o) A new named session allows it to be deleted immediately after starting the daemon, so that user have just the exact same sessions he left

aguytech avatar Nov 22 '20 15:11 aguytech

you may end up killing the temporary session immediately after start, before anything is restored.

If you kill the last tmux session, you kill the daemon (on manjaro / ubuntu)

aguytech avatar Nov 22 '20 15:11 aguytech

Sorry, there is an error in my proposal

I'm working on strongly solution in regards to my comment https://github.com/tmux-plugins/tmux-continuum/pull/7#issuecomment-732182110 and my difficulties to kill-session inside the starting script ...

aguytech avatar Nov 23 '20 14:11 aguytech

So, why is new-session -d not doing the trick?

Let plugin script "restore.sh" restore tmux session

Note that if someone is running tmux plugins in the background via run -b (eg run -b '~/.tmux/plugins/tpm/tpm') you may end up killing the temporary session immediately after start, before anything is restored.

You are right about the '-b' option, I made a mistake by forgetting it; o)

aguytech avatar Nov 23 '20 23:11 aguytech