1
- """Command line tool for managing tmux workspaces and tmuxp configurations .
1
+ """Command line tool for managing tmuxp workspaces .
2
2
3
3
tmuxp.cli.load
4
4
~~~~~~~~~~~~~~
@@ -109,7 +109,7 @@ def set_layout_hook(session: Session, hook_name: str) -> None:
109
109
110
110
def load_plugins (sconf : t .Any ) -> t .List [t .Any ]:
111
111
"""
112
- Load and return plugins in config
112
+ Load and return plugins in workspace
113
113
"""
114
114
plugins = []
115
115
if "plugins" in sconf :
@@ -173,7 +173,7 @@ def _reattach(builder: WorkspaceBuilder):
173
173
174
174
def _load_attached (builder : WorkspaceBuilder , detached : bool ) -> None :
175
175
"""
176
- Load config in new session
176
+ Load workspace in new session
177
177
178
178
Parameters
179
179
----------
@@ -206,7 +206,7 @@ def _load_attached(builder: WorkspaceBuilder, detached: bool) -> None:
206
206
207
207
def _load_detached (builder : WorkspaceBuilder ) -> None :
208
208
"""
209
- Load config in new session but don't attach
209
+ Load workspace in new session but don't attach
210
210
211
211
Parameters
212
212
----------
@@ -223,7 +223,7 @@ def _load_detached(builder: WorkspaceBuilder) -> None:
223
223
224
224
def _load_append_windows_to_current_session (builder : WorkspaceBuilder ) -> None :
225
225
"""
226
- Load config as new windows in current session
226
+ Load workspace as new windows in current session
227
227
228
228
Parameters
229
229
----------
@@ -289,29 +289,29 @@ def load_workspace(
289
289
Notes
290
290
-----
291
291
292
- tmuxp will check and load a configuration file. The file will use ConfigReader
292
+ tmuxp will check and load a workspace file. The file will use ConfigReader
293
293
to load a JSON/YAML into a :py:obj:`dict`. Then :func:`config.expand` and
294
294
:func:`config.trickle` will be used to expand any shorthands, template
295
295
variables, or file paths relative to where the config/script is executed
296
296
from.
297
297
298
298
:func:`config.expand` accepts the directory of the config file, so the
299
- user's configuration can resolve absolute paths relative to where the
300
- config file is. In otherwords, if a config file at */var/moo/hi.yaml*
301
- has *./* in its configs , we want to be sure any file path with *./* is
299
+ user's workspace can resolve absolute paths relative to where the
300
+ workspace file is. In otherwords, if a workspace file at */var/moo/hi.yaml*
301
+ has *./* in its workspaces , we want to be sure any file path with *./* is
302
302
relative to */var/moo*, not the user's PWD.
303
303
304
304
A :class:`libtmux.Server` object is created. No tmux server is started yet,
305
305
just the object.
306
306
307
- The prepared configuration and the server object is passed into an instance
307
+ The prepared workspace and its server object is passed into an instance
308
308
of :class:`~tmuxp.workspace.builder.WorkspaceBuilder`.
309
309
310
310
A sanity check against :meth:`libtmux.common.which` is ran. It will raise
311
311
an exception if tmux isn't found.
312
312
313
313
If a tmux session under the same name as ``session_name`` in the tmuxp
314
- configuration exists, tmuxp offers to attach the session. Currently, tmuxp
314
+ workspace exists, tmuxp offers to attach the session. Currently, tmuxp
315
315
does not allow appending a workspace / incremental building on top of a
316
316
current session (pull requests are welcome!).
317
317
@@ -365,15 +365,19 @@ def load_workspace(
365
365
)
366
366
367
367
# ConfigReader allows us to open a yaml or json file as a dict
368
- raw_config = config_reader .ConfigReader ._from_file (workspace_file ) or {}
368
+ raw_workspace = config_reader .ConfigReader ._from_file (workspace_file ) or {}
369
369
370
- # shapes configurations relative to config / profile file location
371
- sconfig = config .expand (raw_config , cwd = os .path .dirname (workspace_file ))
372
- # Overwrite session name
370
+ # shapes workspaces relative to config / profile file location
371
+ expanded_workspace = config .expand (
372
+ raw_workspace , cwd = os .path .dirname (workspace_file )
373
+ )
374
+
375
+ # Overridden session name
373
376
if new_session_name :
374
- sconfig ["session_name" ] = new_session_name
375
- # propagate config inheritance (e.g. session -> window, window -> pane)
376
- sconfig = config .trickle (sconfig )
377
+ expanded_workspace ["session_name" ] = new_session_name
378
+
379
+ # propagate workspace inheritance (e.g. session -> window, window -> pane)
380
+ expanded_workspace = config .trickle (expanded_workspace )
377
381
378
382
t = Server ( # create tmux server object
379
383
socket_name = socket_name ,
@@ -384,15 +388,15 @@ def load_workspace(
384
388
385
389
shutil .which ("tmux" ) # raise exception if tmux not found
386
390
387
- try : # load WorkspaceBuilder object for tmuxp config / tmux server
391
+ try : # load WorkspaceBuilder object for tmuxp workspace / tmux server
388
392
builder = WorkspaceBuilder (
389
- sconf = sconfig , plugins = load_plugins (sconfig ), server = t
393
+ sconf = expanded_workspace , plugins = load_plugins (expanded_workspace ), server = t
390
394
)
391
395
except exc .EmptyWorkspaceException :
392
- tmuxp_echo ("%s is empty or parsed no config data" % workspace_file )
396
+ tmuxp_echo ("%s is empty or parsed no workspace data" % workspace_file )
393
397
return None
394
398
395
- session_name = sconfig ["session_name" ]
399
+ session_name = expanded_workspace ["session_name" ]
396
400
397
401
# if the session already exists, prompt the user to attach
398
402
if builder .session_exists (session_name ) and not append :
@@ -465,7 +469,7 @@ def load_workspace(
465
469
466
470
467
471
def workspace_file_completion (ctx , params , incomplete ):
468
- config_dir = pathlib .Path (get_workspace_dir ())
472
+ workspace_dir = pathlib .Path (get_workspace_dir ())
469
473
choices : t .List [pathlib .Path ] = []
470
474
471
475
# CWD Paths
@@ -480,8 +484,8 @@ def workspace_file_completion(ctx, params, incomplete):
480
484
for p in pathlib .Path .cwd ().glob ("*/.tmuxp.*" )
481
485
]
482
486
483
- # Project configs
484
- choices += sorted ((config_dir / c ).stem for c in in_dir (str (config_dir )))
487
+ # Project workspace
488
+ choices += sorted ((workspace_dir / c ).stem for c in in_dir (str (workspace_dir )))
485
489
486
490
return sorted (str (c ) for c in choices if str (c ).startswith (incomplete ))
487
491
@@ -491,7 +495,7 @@ def create_load_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
491
495
"workspace_files" ,
492
496
nargs = "+" ,
493
497
metavar = "workspace-file" ,
494
- help = "filepath to session or filename of session if in tmuxp config directory" ,
498
+ help = "filepath to session or filename of session in tmuxp workspace directory" ,
495
499
)
496
500
parser .add_argument (
497
501
"-L" ,
@@ -539,7 +543,7 @@ def create_load_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentP
539
543
"--append" ,
540
544
dest = "append" ,
541
545
action = "store_true" ,
542
- help = "load configuration , appending windows to the current session" ,
546
+ help = "load workspace , appending windows to the current session" ,
543
547
)
544
548
colorsgroup = parser .add_mutually_exclusive_group ()
545
549
@@ -583,25 +587,25 @@ def command_load(
583
587
args : CLILoadNamespace ,
584
588
parser : t .Optional [argparse .ArgumentParser ] = None ,
585
589
) -> None :
586
- """Load a tmux workspace from each CONFIG .
590
+ """Load a tmux workspace from each WORKSPACE_FILE .
587
591
588
- CONFIG is a specifier for a configuration file.
592
+ WORKSPACE_FILE is a specifier for a workspace file.
589
593
590
- If CONFIG is a path to a directory, tmuxp will search it for
594
+ If WORKSPACE_FILE is a path to a directory, tmuxp will search it for
591
595
".tmuxp.{yaml,yml,json}".
592
596
593
- If CONFIG is has no directory component and only a filename, e.g.
594
- "myconfig .yaml", tmuxp will search the users's config directory for that
597
+ If WORKSPACE_FILE is has no directory component and only a filename, e.g.
598
+ "myworkspace .yaml", tmuxp will search the users's workspace directory for that
595
599
file.
596
600
597
- If CONFIG has no directory component, and only a name with no extension,
598
- e.g. "myconfig ", tmuxp will search the users's config directory for any
601
+ If WORKSPACE_FILE has no directory component, and only a name with no extension,
602
+ e.g. "myworkspace ", tmuxp will search the users's workspace directory for any
599
603
file with the extension ".yaml", ".yml", or ".json" that matches that name.
600
604
601
- If multiple configuration files that match a given CONFIG are found, tmuxp
605
+ If multiple workspace files that match a given WORKSPACE_FILE are found, tmuxp
602
606
will warn and pick the first one found.
603
607
604
- If multiple CONFIGs are provided, workspaces will be created for all of
608
+ If multiple WORKSPACE_FILEs are provided, workspaces will be created for all of
605
609
them. The last one provided will be attached. The others will be created in
606
610
detached mode.
607
611
"""
0 commit comments