Skip to content

Commit fa1e043

Browse files
committed
New command: tmuxp cli (drop into pdb with server and local session)
1 parent 5c716c4 commit fa1e043

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tmuxp/cli.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,46 @@ def startup(config_dir):
661661
os.makedirs(config_dir)
662662

663663

664+
@cli.command(name='cli')
665+
@click.argument('session_name', nargs=1, required=False)
666+
@click.argument('window_name', nargs=1, required=False)
667+
@click.option('-S', 'socket_path', help='pass-through for tmux -S')
668+
@click.option('-L', 'socket_name', help='pass-through for tmux -L')
669+
def command_cli(session_name, window_name, socket_name, socket_path):
670+
server = Server(socket_name=socket_name, socket_path=socket_path)
671+
672+
try:
673+
if session_name:
674+
session = server.find_where({'session_name': session_name})
675+
else:
676+
session = server.list_sessions()[0]
677+
678+
if not session:
679+
raise exc.TmuxpException('Session not found.')
680+
except exc.TmuxpException as e:
681+
print(e)
682+
return
683+
684+
try:
685+
if window_name:
686+
window = session.find_where({'window_name': window_name})
687+
if not window:
688+
raise exc.TmuxpException('Window not found.')
689+
else:
690+
window = session.list_windows()[0]
691+
692+
except exc.TmuxpException as e:
693+
print(e)
694+
return
695+
696+
try:
697+
breakpoint()
698+
except Exception: # Python 3.7+
699+
import pdb
700+
701+
pdb.set_trace()
702+
703+
664704
@cli.command(name='freeze')
665705
@click.argument('session_name', nargs=1, required=False)
666706
@click.option('-S', 'socket_path', help='pass-through for tmux -S')

0 commit comments

Comments
 (0)