Workspace ManagerstableAPI Reference

Choose documentation 3

stable

Current version

stable
English

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

tmuxp.cli.search.find_search_matches

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]

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
Returns

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

Esc

Type to search.

Reference preview Open reference