tmux脚本库/orm
libtmux的Python项目详细描述
libtmux-tmux脚本库
libtmux是python中tmux工作区管理器tmuxp背后的工具。
它基于tmux的target和formats来创建一个对象 映射以遍历、检查和与实时tmux会话交互。
查看documentation主页、API信息和architectural details。
安装
$ [sudo] pip install libtmux
打开TMUX会话
会话名foo,窗口名bar
$ tmux new-session -s foo -n bar
通过python引导tmux会话
$ python
# or for nice autocomplete and syntax highlighting
$ pip install ptpython
$ ptpython
连接到实时tmux会话:
>>>importlibtmux>>>server=libtmux.Server()>>>server<libtmux.server.Serverobjectat0x7fbd622c1dd0>
列出会话:
>>>server.list_sessions()[Session($3foo),Session($1libtmux)]
查找会话:
>>>server.get_by_id('$3')Session($3foo)
通过dict查找查找会话:
>>>server.find_where({"session_name":"foo"})Session($3foo)
将会话分配给session:
>>>session=server.find_where({"session_name":"foo"})
播放会话:
>>>session.new_window(attach=False,window_name="ha in the bg")Window(@82:hainthebg,Session($3foo))>>>session.kill_window("ha in")
在后台创建新窗口(不要切换到该窗口):
>>>w=session.new_window(attach=False,window_name="ha in the bg")Window(@113:hainthebg,Session($3foo))
直接杀死窗口对象:
>>>w.kill_window()
抓取剩余的tmux窗口:
>>>window=session.attached_window>>>window.split_window(attach=False)Pane(%23Window(@101:bar,Session($3foo)))
重命名窗口:
>>>window.rename_window('libtmuxower')Window(@101:libtmuxower,Session($3foo))
通过拆分窗口创建窗格:
>>>pane=window.split_window()>>>pane=window.split_window(attach=False)>>>pane.select_pane()>>>window=session.new_window(attach=False,window_name="test")>>>pane=window.split_window(attach=False)
将关键笔划发送到窗格:
>>>pane.send_keys('echo hey send now')>>>pane.send_keys('echo hey',enter=False)>>>pane.enter()
获取窗格的输出:
>>>pane.clear()# clear the pane>>>pane.send_keys('cowsay hello')>>>print('\n'.join(pane.cmd('capture-pane','-p').stdout))
sh-3.2$ cowsay 'hello' _______ < hello > ------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || ||
强大的遍历功能:
>>> pane.window Window(@10 1:libtmuxower, Session($3 foo)) >>> pane.window.session Session($3 foo)
捐款
你的捐赠基金开发新功能,测试和支持。 你的钱将直接用于项目的维护和开发。 如果你是一个个体,你可以自由地付出一切 从项目中获得的价值。
请参阅https://git-pull.com/support.html上的捐赠选项。
项目详细信息
tmux support | 1.8, 1.9a, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 |
python support | 2.7, >= 3.3, pypy, pypy3 |
Source | https://github.com/tmux-python/libtmux |
Docs | https://libtmux.git-pull.com |
API | https://libtmux.git-pull.com/en/latest/api.html |
Changelog | https://libtmux.git-pull.com/en/latest/history.html |
Issues | https://github.com/tmux-python/libtmux/issues |
Travis | http://travis-ci.org/tmux-python/libtmux |
Test Coverage | https://codecov.io/gh/tmux-python/libtmux |
pypi | https://pypi.python.org/pypi/libtmux |
Open Hub | https://www.openhub.net/p/libtmux-python |
License | MIT. |
git repo | ^{pr 19}$ |
install stable | ^{pr 20}$ |
install dev | ^{pr 21}$
See the developing and testing page in the docs for more. |
tests | ^{pr 22}$ |