From 43eb1f816716e5d79d6ac082a387de11fcfc8a1c Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Tue, 10 Dec 2024 11:37:07 -0700 Subject: [PATCH] tmxrun: Add support for 'split-window' Signed-off-by: Nathan Chancellor --- fish/functions/tmxrun.fish | 2 +- python/scripts/tmxrun.py | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/fish/functions/tmxrun.fish b/fish/functions/tmxrun.fish index 6c984b4e..665e38b0 100644 --- a/fish/functions/tmxrun.fish +++ b/fish/functions/tmxrun.fish @@ -6,7 +6,7 @@ function tmxrun -d "Wrapper for tmxrun.py" # The duplication is sad but it is so much better to handle adding -- in the wrapper function for arg in $argv switch $arg - case -c -d -H --container --detach --host + case -c -d -H -s -v --container --detach --host --split-horizontal --split-vertical if not set -q pos_args set -a py_args $arg else diff --git a/python/scripts/tmxrun.py b/python/scripts/tmxrun.py index b5712859..3cbd94ed 100755 --- a/python/scripts/tmxrun.py +++ b/python/scripts/tmxrun.py @@ -11,8 +11,7 @@ # pylint: enable=wrong-import-position parser = ArgumentParser( - description= - 'Run command in "tmux new-window" with proper quoting to run in either host or container') + description='Run command in tmux with proper quoting to run in either host or container') parser.add_argument('-c', '--container', action='store_const', @@ -26,16 +25,32 @@ dest='mode', help='Run command on the host') parser.add_argument('-d', '--detach', action='store_true', help='Do not switch to created window') +parser.add_argument('-s', + '--split-horizontal', + action='store_const', + const=['split-window', '-v'], + dest='cmd', + help='Split command in a horizontal pane') +parser.add_argument('-v', + '--split-vertical', + action='store_const', + const=['split-window', '-H'], + dest='cmd', + help='Split command in a vertical pane') parser.add_argument('args', nargs='+', help='Command and any arguments to run') args = parser.parse_args() mode = args.mode if args.mode else 'container' if lib.utils.in_container() else 'host' -tmx_cmd = ['tmux', 'new-window'] +tmx_cmd = ['tmux'] +if args.cmd: + tmx_cmd += args.cmd +else: + tmx_cmd.append('new-window') if args.detach: tmx_cmd.append('-d') -CMD_STR = ' '.join(map(str, args.args)) +CMD_STR = ' '.join(args.args) if mode == 'container': CMD_STR = f"dbxe -- fish -c '{CMD_STR}'" tmx_cmd.append(CMD_STR)