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

skip existing named windows on tmuxp load -a workspace #872

Open
geraldh opened this issue Mar 21, 2023 · 0 comments
Open

skip existing named windows on tmuxp load -a workspace #872

geraldh opened this issue Mar 21, 2023 · 0 comments

Comments

@geraldh
Copy link

geraldh commented Mar 21, 2023

Step 1: Provide a summary of your problem

  • tmuxp load -a workspace duplicates existing windows in a session, when called a second time inside tmux

Step 2: Provide tmuxp details

tmux version: 3.3
libtmux version: 0.21.0
tmuxp version: 1.27.0

Step 3: Describe the problem:

Running tmuxp load -a workspace inside tmux duplicates existing windows in a session - it would be nice if existing named windows are not recreated.
So - closing a tmux window, updating the tmuxp workspace config file and rerunning tmuxp load -a workspace should recreate the closed window only (if all windows are named)

Steps to reproduce:

Run tmuxp load -a workspace inside tmux a second time - windows are duplicated

Relevant Code:

The following patch to tmuxp/workspace/builder.py skips existing named windows - but I'm new to tmuxp - a option for enabling this behavior would be necessary - and I don't know, if this is even the correct place for this patch.

--- builder.py.orig	2023-03-16 12:59:43.399597590 +0100
+++ builder.py	2023-03-21 20:46:05.998656705 +0100
@@ -346,6 +346,8 @@ class WorkspaceBuilder:
             Newly created window, and the section from the tmuxp configuration
             that was used to create the window.
         """
+        session_window_names = set([w.window_name for w in session.windows if w.window_name])
+
         for window_iterator, window_config in enumerate(
             self.session_config["windows"], start=1
         ):
@@ -353,6 +355,9 @@ class WorkspaceBuilder:
                 window_name = None
             else:
                 window_name = window_config["window_name"]
+                if window_name in session_window_names:
+                    # skip existing window
+                    continue
 
             is_first_window_pass = self.first_window_pass(
                 window_iterator, session, append

Thanks,
Gerald

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

1 participant