8000 Allow multiple configuration files on command line by madprog · Pull Request #135 · tmux-python/tmuxp · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ Load session

$ tmuxp load .

Multiple sessions can be loaded at once. The first ones will be created
without being attached. The last one will be attached if there is no
``-d`` flag on the command line.

.. code-block:: bash

$ tmuxp load <filename1> <filename2> ...

.. _cli_import:

Import
Expand Down
20 changes: 16 additions & 4 deletions tmuxp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,18 @@ def command_load(args):
"""Load a session from a tmuxp session file."""

if isinstance(args.config, list):
args.config = ' '.join(args.config)
# Load each configuration but the last to the background
for cfg in args.config[:-1]:
new_args = argparse.Namespace(**args.__dict__)
new_args.detached = True
new_args.config = cfg
command_load(new_args)

# The last one will be detached if specified on the command line
new_args = argparse.Namespace(**args.__dict__)
new_args.config = args.config[-1]
command_load(new_args)
return

if '.' == args.config:
if config.in_cwd():
Expand Down Expand Up @@ -818,8 +829,9 @@ def get_parser():
load = subparsers.add_parser(
'load',
parents=[server_parser, client_parser],
help='Load a configuration from file. Attach the session. If session '
'already exists, offer to attach instead.'
help='Load configurations from one or more files. '
'Attach to the session described by the last file. '
'If it already exists, offer to attach instead.'
)

load.add_argument(
Expand All @@ -836,7 +848,7 @@ def get_parser():
'-d',
dest='detached',
default=None,
help='Load a session without attaching to it.',
help='Load the last session without attaching to it.',
action='store_true'
)

Expand Down
0