Here is a simple example to use this library.
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 25/100
- Issue 类型
- 文档
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- python
调研方向
Start by reviewing the inline Python example, especially its libtmux window and pane commands, and compare it with the repository's existing documentation structure. The requested outcome is unclear: determine whether the project needs a documented libtmux example or guidance to use a bash script, then make the chosen example runnable and clear.
由索引模型根据 Issue 内容生成。
描述
When I use the library to split window, I use win.cmd('split-window', '-h') which let me spend a lot of time.
At last, I suggest to use bash script instead of this library.
#!/usr/bin/env python3
# coding=utf-8
# author: thinkycx
# date: 2018-01-11
# Usage:
# run several commands in tmux panel, every window have 4 panes
# $ pip3 install libtmux
# $ python tmux.py
import libtmux
import math
import os
import logging
def create_session(session_name, commands):
'''
create session with 2*2 panes and run commands
:param session_name: tmux session name
:param commands: bash commands
:return:
'''
logging.info(commands)
# pane_NUM = 3
# WINDOW_NUM = int(math.ceil(len(commands)/4.0)) # in python3, we can use 4 also
server = libtmux.Server()
session = server.new_session(session_name)
# create windows
windows = []
panes = []
for i in range(len(commands)):
# create window to store 4 panes
if i % 4 == 0:
win = session.new_window(attach=False, window_name="win"+str(int(i/4)))
windows.append(win)
# tmux_args = ('-h',)
win.cmd('split-window', '-h')
win.cmd('split-window', '-f')
win.cmd('split-window', '-h')
panes.extend(win.list_panes())
panes[i].send_keys(commands[i])
logging.info(panes)
logging.info(windows)
if __name__ == '__main__':
commands = []
for i in range(10):
commands.append("echo " + str(i))
os.system("tmux kill-session -t session")
create_session("session", commands)

- 主要语言
- Python
- 星标
- 1.2k
- 派生
- 127
- 平均合并
- 2 小时 13 分钟
- 30 天内合并 PR
- 1
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
tmux-python/libtmux 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
tmux-python/libtmux#759 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
tmux-python/libtmux#745 · 2 条评论 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
tmux-python/libtmux#744 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
tmux-python/libtmux#731 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
tmux-python/libtmux#654 ·
查看 tmux-python/libtmux 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/skills#1811 · 1 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
speaches-ai/speaches#678 ·
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
datalayer/mcp-compose#42 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
conda-forge/spacy-feedstock#177 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
UKGovernmentBEIS/inspect_evals#2523 ·