From 3311ca943b319e4c4d395e547b12f490637f3c15 Mon Sep 17 00:00:00 2001 From: Nikos Vasilas Date: Tue, 2 Jul 2019 20:13:07 +0300 Subject: [PATCH] Fix window focus Save attached window before set_layout_hook actually execute the hooks and select the saved after the hooks. --- tmuxp/cli.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tmuxp/cli.py b/tmuxp/cli.py index f74b187c383..41a828a2592 100644 --- a/tmuxp/cli.py +++ b/tmuxp/cli.py @@ -162,6 +162,7 @@ def set_layout_hook(session, hook_name): """ cmd = ['set-hook', '-t', session.id, hook_name] hook_cmd = [] + attached_window = session.attached_window for window in session.windows: # unfortunately, select-layout won't work unless # we've literally selected the window at least once @@ -177,6 +178,7 @@ def set_layout_hook(session, hook_name): target_session=session.id, hook_name=hook_name ) ) + hook_cmd.append('selectw -t {}'.format(attached_window.id)) # join the hook's commands with semicolons hook_cmd = '{}'.format('; '.join(hook_cmd))