Last active
August 31, 2020 09:28
Generate command in Python to launch multiple commands in tmux via 1 step.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# parse multiple CL commands into a single tmux command | |
# each line = 1 command = 1 tmux tab | |
commands = """ | |
nvidia-smi -l 1 | |
htop | |
python myprogram.py --trials 10 --expid 502 | |
python myprogram.py --trials 10 --expid 554 | |
python myprogram.py --trials 10 --expid 574 | |
""" | |
comms = commands.split("\n") | |
for d in comms: | |
if d == '': comms.remove(d) | |
print(comms) | |
res = ['tmux new-session \; \\'] | |
for c in comms: | |
res.append(" send-keys \'"+c+"\' C-m \; \\") | |
res.append(" neww \; \\") | |
res = res[:-1] | |
print("\n".join(res)) # copy the output into the command line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment