|
#!/usr/bin/env python
|
|
|
|
import argparse
|
|
import libtmux
|
|
import os
|
|
import tmuxp
|
|
|
|
def build_parser():
|
|
parser = argparse.ArgumentParser(
|
|
'make.py',
|
|
description="Start two 'make' processes in adjacent termux panes.",
|
|
)
|
|
|
|
parser.add_argument(
|
|
'--kill-only', action="store_true",
|
|
help="Don't create new windows; just nix the ones we have.",
|
|
)
|
|
|
|
parser.add_argument(
|
|
'--window-name', type=str, default='make',
|
|
help="The name of the window to match (default: 'make').",
|
|
)
|
|
|
|
return parser
|
|
|
|
def main():
|
|
args = build_parser().parse_args()
|
|
|
|
server = libtmux.Server()
|
|
this_pane = pane = tmuxp.util.get_current_pane(server)
|
|
if not pane:
|
|
raise RuntimeError('not within tmux')
|
|
|
|
if pane.window.name != 'make':
|
|
raise RuntimeError("Please rename this window to 'make' to proceed.")
|
|
|
|
for p in pane.window.panes:
|
|
if p != pane:
|
|
p.kill()
|
|
|
|
if args.kill_only:
|
|
return this_pane
|
|
|
|
for command in [
|
|
"make continuous",
|
|
"make serve",
|
|
]:
|
|
pane = pane.split()
|
|
pane.window.select_layout('even-vertical')
|
|
pane.send_keys(command)
|
|
|
|
return this_pane
|
|
|
|
if __name__ == "__main__":
|
|
main()
|