From f2a21afb123e96f6ae0f5bac5d9a37edf926d04b Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Sun, 28 Jan 2024 21:05:42 +0100 Subject: [PATCH 1/2] Add a colon to the end of the target session when creating windows Otherwise the target might get interpreted wrong resulting in the window not being created. --- catmux/window.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catmux/window.py b/catmux/window.py index 18e1488..eae77e0 100644 --- a/catmux/window.py +++ b/catmux/window.py @@ -77,7 +77,7 @@ def create(self, first=False): tmux_wrapper = tmux.TmuxWrapper(server_name=self.server_name) target_window = ":".join([self.session_name, getattr(self, "name")]) if not first: - tmux_wrapper.tmux_call(["new-window", "-t", self.session_name]) + tmux_wrapper.tmux_call(["new-window", "-t", self.session_name + ":"]) tmux_wrapper.tmux_call( ["rename-window", "-t", f"{self.session_name}:$", getattr(self, "name")] ) From a2613434d93d80dac172e56bbd50d6560bfc22a9 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Sun, 28 Jan 2024 21:09:31 +0100 Subject: [PATCH 2/2] Update test according to change. --- test/test_run.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/test/test_run.py b/test/test_run.py index 8011524..c320afc 100644 --- a/test/test_run.py +++ b/test/test_run.py @@ -57,11 +57,11 @@ def test_full_circle(mock_popen): show_layouts: true windows: - - name: foo + - name: foobar if: show_layouts commands: - echo "${replacement_param}" - - name: bar + - name: hello layout: tiled delay: 1 splits: @@ -71,23 +71,23 @@ def test_full_circle(mock_popen): - echo "second_split" """ server_name = "my_server" - session_name = "my_session" + session_name = "foo" session = Session(server_name=server_name, session_name=session_name) session.init_from_yaml(yaml.safe_load(CONFIG)) session.run(debug=True) calls = [ - ["rename-window", "-t", "my_session:$", "foo"], - ["send-keys", "-t", "my_session:foo", 'echo "hello"', "C-m"], - ["send-keys", "-t", "my_session:foo", 'echo "world"', "C-m"], - ["send-keys", "-t", "my_session:foo", 'echo "schubidoo"', "C-m"], - ["select-window", "-t", "my_session:foobar"], - ["new-window", "-t", "my_session"], - ["rename-window", "-t", "my_session:$", "bar"], - ["send-keys", "-t", "my_session:bar", 'echo "first_split"', "C-m"], - ["split-window", "-t", "my_session:bar"], - ["send-keys", "-t", "my_session:bar", 'echo "second_split"', "C-m"], - ["select-layout", "-t", "my_session:bar", "tiled"], + ["rename-window", "-t", "foo:$", "foobar"], + ["send-keys", "-t", "foo:foobar", 'echo "hello"', "C-m"], + ["send-keys", "-t", "foo:foobar", 'echo "world"', "C-m"], + ["send-keys", "-t", "foo:foobar", 'echo "schubidoo"', "C-m"], + ["select-window", "-t", "foo:foobar"], + ["new-window", "-t", "foo:"], + ["rename-window", "-t", "foo:$", "hello"], + ["send-keys", "-t", "foo:hello", 'echo "first_split"', "C-m"], + ["split-window", "-t", "foo:hello"], + ["send-keys", "-t", "foo:hello", 'echo "second_split"', "C-m"], + ["select-layout", "-t", "foo:hello", "tiled"], ] for call in calls: mock_popen.assert_any_call(["tmux", "-L", server_name] + call)