From 89145e6a552c439e86d725fc04603ff6bc4fc852 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 19 Aug 2025 21:44:20 +0530 Subject: [PATCH] Allow using --match=session:. to match windows in the currently active session --- kitty/rc/base.py | 6 ++++-- kitty/tabs.py | 2 ++ kitty/window.py | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/kitty/rc/base.py b/kitty/rc/base.py index 7d5b38282..4a88f0060 100644 --- a/kitty/rc/base.py +++ b/kitty/rc/base.py @@ -113,7 +113,8 @@ The field :code:`neighbor` refers to a neighbor of the active window in the spec :code:`left`, :code:`right`, :code:`top` or :code:`bottom`. The field :code:`session` matches windows that were created in the specified session. -Use the expression :code:`^$` to match windows that were not created in a session. +Use the expression :code:`^$` to match windows that were not created in a session and +:code:`.` to match the currently active session. When using the :code:`env` field to match on environment variables, you can specify only the environment variable name or a name and value, for example, :code:`env:MY_ENV_VAR=2`. @@ -159,7 +160,8 @@ The :code:`recent` number matches recently active tabs in the currently active O active tab, one the previously active tab and so on. The field :code:`session` matches tabs that were created in the specified session. -Use the expression :code:`^$` to match tabs that were not created in a session. +Use the expression :code:`^$` to match tabs that were not created in a session and +:code:`.` to match the currently active session. When using the :code:`env` field to match on environment variables, you can specify only the environment variable name or a name and value, for example, :code:`env:MY_ENV_VAR=2`. Tabs containing any window with the specified environment diff --git a/kitty/tabs.py b/kitty/tabs.py index 5941a10b0..e1f08c691 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -957,6 +957,8 @@ class Tab: # {{{ return active_tab_manager is not None and self.tab_manager_ref() is active_tab_manager and self.os_window_id == last_focused_os_window_id() return False if field == 'session': + if query == '.': + return self.created_in_session_name == get_boss().active_session return re.search(query, self.created_in_session_name) is not None return False diff --git a/kitty/window.py b/kitty/window.py index f7a94f1ea..096078985 100644 --- a/kitty/window.py +++ b/kitty/window.py @@ -910,6 +910,8 @@ class Window: return True return False if field == 'session': + if pat.pattern == '.': + return self.created_in_session_name == get_boss().active_session return pat.search(self.created_in_session_name) is not None return False