有没有办法将会话的TMUX ID获取到该会话中运行的Python程序中?

发布于 2025-02-13 01:34:09 字数 104 浏览 0 评论 0原文

我只是想知道是否可以在tmux会话中运行python脚本并获得其ID-就像我有tmux会话ID:1,我想运行一个Python程序,其中一个变量应为TMUX会话的ID它正在运行,在这种情况下为1。

I just wanted to to know if it is possible to run a python script in a tmux session and get its ID - like if I have a tmux session id: 1, I want to run a python program where one of it's variable should be the ID of the tmux session it is running in, In this case 1.

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

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

发布评论

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

评论(1

香草可樂 2025-02-20 01:34:09

找到了。在键“ TMUX” AS/TMP // TMUX-1000/DEFAULT,4795,0下的环境变量中可用。在我的情况下,最后一个数字是tmux_id。

tmux_id = os.environ["TMUX"][-1]

这就是我目前正在使用的,但是显然有一种更好的方法来拆分字符串以获取ID。

Found it. In it is available in environment variables under key "TMUX" as /tmp//tmux-1000/default,4795,0. Where the last digit is the tmux_id in my case.

tmux_id = os.environ["TMUX"][-1]

This is what I am using for now, but obviously there is a better way to split the string to get the ID.

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