Skip to content

Commit 3c71b20

Browse files
committed
Merge pull request #135 from madprog/pr-multiple-configurations
Allow multiple configuration files on command line
2 parents b3e66e2 + 92be336 commit 3c71b20

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

doc/cli.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ Load session
7373
7474
$ tmuxp load .
7575
76+
Multiple sessions can be loaded at once. The first ones will be created
77+
without being attached. The last one will be attached if there is no
78+
``-d`` flag on the command line.
79+
80+
.. code-block:: bash
81+
82+
$ tmuxp load <filename1> <filename2> ...
83+
7684
.. _cli_import:
7785

7886
Import

tmuxp/cli.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,18 @@ def command_load(args):
399399
"""Load a session from a tmuxp session file."""
400400

401401
if isinstance(args.config, list):
402-
args.config = ' '.join(args.config)
402+
# Load each configuration but the last to the background
403+
for cfg in args.config[:-1]:
404+
new_args = argparse.Namespace(**args.__dict__)
405+
new_args.detached = True
406+
new_args.config = cfg
407+
command_load(new_args)
408+
409+
# The last one will be detached if specified on the command line
410+
new_args = argparse.Namespace(**args.__dict__)
411+
new_args.config = args.config[-1]
412+
command_load(new_args)
413+
return
403414

404415
if '.' == args.config:
405416
if config.in_cwd():
@@ -818,8 +829,9 @@ def get_parser():
818829
load = subparsers.add_parser(
819830
'load',
820831
parents=[server_parser, client_parser],
821-
help='Load a configuration from file. Attach the session. If session '
822-
'already exists, offer to attach instead.'
832+
help='Load configurations from one or more files. '
833+
'Attach to the session described by the last file. '
834+
'If it already exists, offer to attach instead.'
823835
)
824836

825837
load.add_argument(
@@ -836,7 +848,7 @@ def get_parser():
836848
'-d',
837849
dest='detached',
838850
default=None,
839-
help='Load a session without attaching to it.',
851+
help='Load the last session without attaching to it.',
840852
action='store_true'
841853
)
842854

0 commit comments

Comments
 (0)