Skip to content

Commit ce71150

Browse files
committed
tmuxp: Pass -c to execute python directly
1 parent aad1315 commit ce71150

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tmuxp/cli.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,12 @@ def startup(config_dir):
666666
@click.argument('window_name', nargs=1, required=False)
667667
@click.option('-S', 'socket_path', help='pass-through for tmux -S')
668668
@click.option('-L', 'socket_name', help='pass-through for tmux -L')
669-
def command_cli(session_name, window_name, socket_name, socket_path):
669+
@click.option(
670+
'-c',
671+
'command',
672+
help='Instead of opening shell, execute python code in libtmux and exit',
673+
)
674+
def command_cli(session_name, window_name, socket_name, socket_path, command):
670675
server = Server(socket_name=socket_name, socket_path=socket_path)
671676

672677
try:
@@ -693,9 +698,12 @@ def command_cli(session_name, window_name, socket_name, socket_path):
693698
print(e)
694699
return
695700

696-
from ._compat import breakpoint as tmuxp_breakpoint
701+
if command is not None:
702+
exec(command)
703+
else:
704+
from ._compat import breakpoint as tmuxp_breakpoint
697705

698-
tmuxp_breakpoint()
706+
tmuxp_breakpoint()
699707

700708

701709
@cli.command(name='freeze')

0 commit comments

Comments
 (0)