Skip to content

Commit

Permalink
Add a colon to the end of the target session when creating windows (#38)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fmauch authored Jan 29, 2024
1 parent f8b837f commit 21a9eb7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion catmux/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
)
Expand Down
28 changes: 14 additions & 14 deletions test/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

0 comments on commit 21a9eb7

Please sign in to comment.