diff --git a/docs/changelog.rst b/docs/changelog.rst index 7324f45f1..d3ab35362 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -90,6 +90,9 @@ To update |kitty|, :doc:`follow the instructions `. `_ font (requires Iosevka >= 7.0.4) (:iss:`297`) +- Remote control: Allow matching tabs by index number in currently active OS + Window (:iss:`3708`) + 0.20.3 [2021-05-06] ---------------------- diff --git a/kitty/boss.py b/kitty/boss.py index cc5e5fb22..e1b0485b0 100755 --- a/kitty/boss.py +++ b/kitty/boss.py @@ -299,6 +299,12 @@ class Boss: if q: found = True yield q + elif field == 'index': + tm = self.active_tab_manager + if tm is not None and len(tm.tabs) > 0: + idx = (int(pat.pattern) + len(tm.tabs)) % len(tm.tabs) + found = True + yield tm.tabs[idx] if not found: tabs = {self.tab_for_window(w) for w in self.match_windows(match)} for q in tabs: diff --git a/kitty/rc/base.py b/kitty/rc/base.py index d41396a2f..0d214b64c 100644 --- a/kitty/rc/base.py +++ b/kitty/rc/base.py @@ -90,13 +90,14 @@ MATCH_TAB_OPTION = '''\ --match -m The tab to match. Match specifications are of the form: :italic:`field:regexp`. Where field can be one of: -id, title, window_id, window_title, pid, cwd, env, cmdline. +id, index, title, window_id, window_title, pid, cwd, env, cmdline. You can use the :italic:`ls` command to get a list of tabs. Note that for -numeric fields such as id and pid the expression is interpreted as a number, +numeric fields such as id, index and pid the expression is interpreted as a number, not a regular expression. When using title or id, first a matching tab is looked for and if not found a matching window is looked for, and the tab for that window is used. You can also use window_id and window_title to match -the tab that contains the window with the specified id or title. +the tab that contains the window with the specified id or title. The index number +is used to match the nth tab in the currently active OS window. '''