TL;DR:  Every terminal I spawn execs tmux, specifically:

    st -e tmux new-session \; \
        set-option destroy-unattached on \; \
        choose-tree -b "new-session -t "%%"'

and here was how I progressed to that ...

Simplest option, just spawn a new session every time:

    st -e tmux new-session
    st -e tmux new-session \; set-option destroy-unattached on

Conventional spawning of a new terminal.  Converges on unmanagable amount
of sessions without diligent ^D (logout).  The second variant alleviates
this, but can bite you ("destroy-unattached off" is expected, you WILL
accidentally kill windows).


Attach to the last session:

    st -e tmux attach-session
    st -e tmux attach-session \; new-window

This is another way to reduce the amount of left-over sessions. The second
variant is nice for quick commands, a ^D returns other attached clients to
their old state (nearly, see -E).  Terminals are linked so other windows
unexpectedly start changing.  If you are experienced with tmux this is
obvious, but annoying.


Choose a session to "clone", or attach to the last session if cancelled:

    st -e tmux attach-session \; choose-tree -b "new-session -t '%%'"
    st -e tmux new-session \; set-option destroy-unattached on \;
choose-tree -b "new-session -t "%%"'

This works unless the attached window is already in (copy|edit)-mode.  It
also fails unless at least one session is running, or a session is started
in tmux.conf.  The second variant seems to always work and is my current
keybinding (Win+Return) in my window manager.

Comment and improve :-)

Thanks,
Ryan

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to