Finders - tmuxp.workspace.finders#

Workspace (configuration file) finders for tmuxp.

tmuxp.workspace.finders.is_workspace_file(filename, extensions=None)[source]#

Return True if file has a valid workspace file type.

Return type:

bool

Parameters:
  • filename (str) – filename to check (e.g. mysession.json).

  • extensions (str or list) – filetypes to check (e.g. ['.yaml', '.json']).

Return type:

bool

tmuxp.workspace.finders.in_dir(workspace_dir=None, extensions=None)[source]#

Return a list of workspace_files in workspace_dir.

Return type:

List[str]

Parameters:
  • workspace_dir (str) – directory to search

  • extensions (list) – filetypes to check (e.g. ['.yaml', '.json']).

Return type:

list

tmuxp.workspace.finders.in_cwd()[source]#

Return list of workspace_files in current working directory.

If filename is .tmuxp.py, .tmuxp.json, .tmuxp.yaml.

Return type:

List[str]

Returns:

workspace_files in current working directory

Return type:

list

Examples

>>> sorted(in_cwd())
['.tmuxp.json', '.tmuxp.yaml']
tmuxp.workspace.finders.get_workspace_dir()[source]#

Return tmuxp workspace directory.

TMUXP_CONFIGDIR environmental variable has precedence if set. We also evaluate XDG default directory from XDG_CONFIG_HOME environmental variable if set or its default. Then the old default ~/.tmuxp is returned for compatibility.

Return type:

str

Returns:

absolute path to tmuxp config directory

Return type:

str

tmuxp.workspace.finders.find_workspace_file(workspace_file, workspace_dir=None)[source]#

Return the real config path or raise an exception.

If workspace file is directory, scan for .tmuxp.{yaml,yml,json} in directory. If one or more found, it will warn and pick the first.

If workspace file is “.”, “./” or None, it will scan current directory.

If workspace file is has no path and only a filename, e.g. “my_workspace.yaml” it will search workspace dir.

If workspace file has no path and no extension, e.g. “my_workspace”, it will scan for file name with yaml, yml and json. If multiple exist, it will warn and pick the first.

Return type:

str

Parameters:

workspace_file (str) –

workspace file, valid examples:

  • a file name, my_workspace.yaml

  • relative path, ../my_workspace.yaml or ../project

  • a period, .

tmuxp.workspace.finders.is_pure_name(path)[source]#

Return True if path is a name and not a file path.

Return type:

bool

Parameters:

path (str) – Path (can be absolute, relative, etc.)

Returns:

True if path is a name of workspace in workspace dir, not file path.

Return type:

bool