Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

tmuxp.cli.search.find_search_matches

Python
  • Python
  • Ruby Unavailable
  • Lua Unavailable
  • TypeScript Unavailable
  • Rust Unavailable
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

API reference · Markdown

tmuxp.cli.search.find_search_matches ( workspaces : list[tuple[pathlib.Path, str]] , patterns : list[SearchPattern] , match_any : bool = False , invert_match : bool = False ) → list[WorkspaceSearchResult]
function [source]
function [source]
tmuxp.cli.search.find_search_matches

Find workspaces matching search patterns.

Examples

>>> import tempfile
>>> import pathlib
>>> import re
>>> content = "session_name: dev-session" + chr(10) + "windows: []"
>>> with tempfile.NamedTemporaryFile(
... suffix='.yaml', delete=False, mode='w'
... ) as f:
... _ = f.write(content)
... temp_path = pathlib.Path(f.name)
>>> pattern = SearchPattern(
... fields=("session_name",),
... raw="dev",
... regex=re.compile("dev"),
... )
>>> results = find_search_matches([(temp_path, "global")], [pattern])
>>> len(results)
1
>>> results[0]["source"]
'global'

Invert match returns non-matching workspaces:

>>> pattern_nomatch = SearchPattern(
... fields=("name",),
... raw="nonexistent",
... regex=re.compile("nonexistent"),
... )
>>> results = find_search_matches(
... [(temp_path, "global")], [pattern_nomatch], invert_match=True
... )
>>> len(results)
1
>>> temp_path.unlink()
Parameters
  • workspaces ( list[tuple[pathlib.Path, str]] ) – List of (filepath, source) tuples to search. Source is "local" or "global".

  • patterns ( list[SearchPattern] ) – Compiled search patterns.

  • match_any ( bool ) – If True, match if ANY pattern matches (OR logic). Default False (AND).

  • invert_match ( bool ) – If True, return workspaces that do NOT match. Default False.

Returns

list[WorkspaceSearchResult] List of matching workspace results with match information.

Esc

Type to search.