在特定的Python文件上自动化TMUX会话创建。 (bash?)

发布于 2025-01-20 07:49:07 字数 211 浏览 1 评论 0原文

我是所有这些服务器端内容的新手,并且我有一台服务器需要多次使用相同的Python脚本启动多个TMUX会话。

我如何自动化此过程(USIGN BASH等) 这是我目前要做的:

tmux / cd python /pyhon3 xshares.py / ctrl-b / d / tmux ...

一再,这需要大量时间,感谢您的帮助。

I am new to all this server side stuff, and I have a server on which I need to start up multiple tmux sessions with the same python script multiple times.

How can I automate this process,( usign bash etc)
This is what I do currently:

tmux / cd python /pyhon3 xshares.py / ctrl-b / d / tmux ...

Repeatedly, which takes a lot of time, thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拔了角的鹿 2025-01-27 07:49:07

我是2个开源的创建者,基于python的tmux(1)工具: libtmux tmuxp

tmux会话经理

如果我不得不猜测“自动化”,您正在寻找“ tmux Session Manager”。其中一些包括(非偏心):

这些工具的要旨是有一个声明性 yaml 配置封装了tmux会话它的窗户和窗格。

为了更好地了解这是什么样子,假设mySession.yaml

session_name: my session
windows:
  - window_name: another window
    panes:
    - shell_command:
      - python3 ./myscript.py
    - shell_command: python3 ./myscript2.py
  - window_name: another window
    panes:
    - shell_command:
      - pane
    - pane

然后可以通过命令启动它(假设您通过pip install -user tmuxp )启动它:

tmuxp load ./mysession.yaml

这将创建并自动将您启动到YAML文件中声明的TMUX会话中。这是一些示例以获取灵感。

脚本脚本tmux

我误解了我误解的外部机会 - 例如,您想以编程方式驾驶tmux,您可以通过shell命令执行此操作,以tmux本身或libtmux。最好问一个针对手册脚本控制Tmux的问题。我也可以帮忙。 :)

I'm creator of 2 open source, python-based tmux(1) tools: libtmux and tmuxp.

tmux session managers

If I had to guess, by "automate" you are looking for a "tmux session manager". Some of those include (non-exhaustively):

The gist of these tools is there's a declarative YAML configuration encapsulating a tmux session, and its windows and panes.

To get a better idea what this looks like, assume mysession.yaml:

session_name: my session
windows:
  - window_name: another window
    panes:
    - shell_command:
      - python3 ./myscript.py
    - shell_command: python3 ./myscript2.py
  - window_name: another window
    panes:
    - shell_command:
      - pane
    - pane

You could then launch it via command (assuming you have tmuxp installed via pip install --user tmuxp):

tmuxp load ./mysession.yaml

This will create and automatically launch you into the tmux session declared in the YAML file. Here are some examples for inspiration.

Scripting tmux

On the outside chance I misunderstood - e.g. you want to pilot tmux programmatically, you could do this through shell commands to tmux itself or libtmux. It could be better to ask a question pivoted toward manual, scripted control of tmux. I can help with that, too. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文