libtmux

⚙️ Python API / wrapper for tmux

https://github.com/tmux-python/libtmux

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary

Keywords

api cli library python python-3 terminal tmux

Keywords from Contributors

astronomy unit-testing cryptocurrency static-analysis solar interactome yolov5s developer-tools energy-systems mesh
Last synced: 4 months ago · JSON representation ·

Repository

⚙️ Python API / wrapper for tmux

Basic Info
Statistics
  • Stars: 1,066
  • Watchers: 16
  • Forks: 111
  • Open Issues: 82
  • Releases: 118
Topics
api cli library python python-3 terminal tmux
Created over 9 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog Contributing License Citation

README.md

libtmux

libtmux is a typed Python library that provides a wrapper for interacting programmatically with tmux, a terminal multiplexer. You can use it to manage tmux servers, sessions, windows, and panes. Additionally, libtmux powers tmuxp, a tmux workspace manager.

Python Package Docs Build Status Code Coverage License

libtmux builds upon tmux's target and formats to create an object mapping to traverse, inspect and interact with live tmux sessions.

View the documentation, API information and architectural details.

Install

console $ pip install --user libtmux

Open a tmux session

Session name foo, window name bar

console $ tmux new-session -s foo -n bar

Pilot your tmux session via python

console $ python

Use ptpython, ipython, etc. for a nice shell with autocompletions:

console $ pip install --user ptpython

console $ ptpython

Connect to a live tmux session:

```python

import libtmux svr = libtmux.Server() svr Server(socket_path=/tmp/tmux-.../default) ```

Tip: You can also use tmuxp's tmuxp shell to drop straight into your current tmux server / session / window pane.

Run any tmux command, respective of context:

Honors tmux socket name and path:

```python

server = Server(socketname='libtmuxdoctest') server.cmd('display-message', 'hello world') ```

New session:

```python

server.cmd('new-session', '-d', '-P', '-F#{session_id}').stdout[0] '$2' ```

```python

session.cmd('new-window', '-P').stdout[0] 'libtmux...:2.0' ```

From raw command output, to a rich Window object (in practice and as shown later, you'd use Session.new_window()):

```python

Window.fromwindowid(windowid=session.cmd('new-window', '-P', '-F#{windowid}').stdout[0], server=session.server) Window(@2 2:..., Session($1 libtmux_...)) ```

Create a pane from a window:

```python

window.cmd('split-window', '-P', '-F#{pane_id}').stdout[0] '%2' ```

Raw output directly to a Pane:

```python

Pane.frompaneid(paneid=window.cmd('split-window', '-P', '-F#{paneid}').stdout[0], server=window.server) Pane(%... Window(@1 1:..., Session($1 libtmux_...))) ```

List sessions:

```python

server.sessions [Session($1 ...), Session($0 ...)] ```

Filter sessions by attribute:

```python

server.sessions.filter(history_limit='2000') [Session($1 ...), Session($0 ...)] ```

Direct lookup:

```python

server.sessions.get(session_id="$1") Session($1 ...) ```

Filter sessions:

```python

server.sessions[0].renamesession('foo') Session($1 foo) server.sessions.filter(sessionname="foo") [Session($1 foo)] server.sessions.get(session_name="foo") Session($1 foo) ```

Control your session:

```python

session Session($1 ...)

session.rename_session('my-session') Session($1 my-session) ```

Create new window in the background (don't switch to it):

```python

bgwindow = session.newwindow(attach=False, windowname="ha in the bg") bgwindow Window(@... 2:ha in the bg, Session($1 ...))

Session can search the window

session.windows.filter(windowname_startswith="ha") [Window(@... 2:ha in the bg, Session($1 ...))]

Directly

session.windows.get(windowname_startswith="ha") Window(@... 2:ha in the bg, Session($1 ...))

Clean up

bg_window.kill() ```

Close window:

```python

w = session.active_window w.kill() ```

Grab remaining tmux window:

```python

window = session.active_window window.split(attach=False) Pane(%2 Window(@1 1:... Session($1 ...))) ```

Rename window:

```python

window.rename_window('libtmuxower') Window(@1 1:libtmuxower, Session($1 ...)) ```

Split window (create a new pane):

```python

pane = window.split() pane = window.split(attach=False) pane.select() Pane(%3 Window(@1 1:..., Session($1 ...))) window = session.newwindow(attach=False, windowname="test") window Window(@2 2:test, Session($1 ...)) pane = window.split(attach=False) pane Pane(%5 Window(@2 2:test, Session($1 ...))) ```

Type inside the pane (send key strokes):

```python

pane.send_keys('echo hey send now')

pane.send_keys('echo hey', enter=False) pane.enter() Pane(%1 ...) ```

Grab the output of pane:

```python

pane.clear() # clear the pane Pane(%1 ...) pane.send_keys("cowsay 'hello'", enter=True) print('\n'.join(pane.cmd('capture-pane', '-p').stdout)) # doctest: +SKIP $ cowsay 'hello'


< hello >


    \   ^__^
     \  (oo)\_______
        (__)\       )\/\
            ||----w |
            ||     ||

... ```

Traverse and navigate:

```python

pane.window Window(@1 1:..., Session($1 ...)) pane.window.session Session($1 ...) ```

Python support

Unsupported / no security releases or bug fixes:

  • Python 2.x: The backports branch is v0.8.x.

Donations

Your donations fund development of new features, testing and support. Your money will go directly to maintenance and development of the project. If you are an individual, feel free to give whatever feels right for the value you get out of the project.

See donation options at https://tony.sh/support.html.

Project details

Owner

  • Name: python utilities for tmux
  • Login: tmux-python
  • Kind: organization
  • Email: team@git-pull.com

permissively licensed. for the public good.

Citation (CITATION.cff)

cff-version: 1.2.0
message: >-
  If you use this software, please cite it as below.
  NOTE: Change "x.y" by the version you use. If you are unsure about which version
  you are using run: `pip show libtmux`."
authors:
- family-names: "Narlock"
  given-names: "Tony"
  orcid: "https://orcid.org/0000-0002-2568-415X"
title: "libtmux"
type: software
version: x.y
url: "https://libtmux.git-pull.com"

GitHub Events

Total
  • Issues event: 4
  • Watch event: 71
  • Delete event: 2
  • Issue comment event: 78
  • Pull request review event: 28
  • Pull request review comment event: 80
  • Pull request event: 9
  • Fork event: 9
  • Create event: 2
Last Year
  • Issues event: 4
  • Watch event: 71
  • Delete event: 2
  • Issue comment event: 78
  • Pull request review event: 28
  • Pull request review comment event: 80
  • Pull request event: 9
  • Fork event: 9
  • Create event: 2

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 2,004
  • Total Committers: 43
  • Avg Commits per committer: 46.605
  • Development Distribution Score (DDS): 0.093
Past Year
  • Commits: 283
  • Committers: 6
  • Avg Commits per committer: 47.167
  • Development Distribution Score (DDS): 0.025
Top Committers
Name Email Commits
Tony Narlock t****y@g****m 1,817
pyup-bot g****t@p****o 97
otherJL0 j****z@g****m 16
dependabot-preview[bot] 2****] 11
rockandska y****d@h****m 7
ritiek r****3@g****m 3
Peter Pentchev r****m@r****t 3
Misha Wolfson m****a@g****m 3
Gil Obradors g****s@g****m 3
Bjoern Hiller b****r@g****m 3
Abraham Toriz c****o@g****m 2
Chung Tran c****n@g****m 2
Kaushal Modi k****i@g****m 2
Steven Joseph s****n@s****n 2
Steven Loria s****1@g****m 2
pre-commit-ci[bot] 6****] 2
tek t****s@g****m 2
Timoses t****u@g****m 2
David Sternlicht d****t@i****m 1
John de Largentaye j****e@a****m 1
Jinank Jain j****j@a****e 1
ksc k****0@q****m 1
Xiaokui Shu s****e@g****m 1
Wenchao Hu z****c@g****m 1
Travis Dart t****t@t****m 1
Sorin Sbarnea s****a@g****m 1
Rémi NICOLE m****n 1
Ricardo Oliva r****a@g****m 1
Patrick Huesmann p****n@d****e 1
Nitin Kumar 5****e 1
and 13 more...

Issues and Pull Requests

Last synced: 4 months ago

All Time
  • Total issues: 74
  • Total pull requests: 140
  • Average time to close issues: 2 months
  • Average time to close pull requests: 26 days
  • Total issue authors: 25
  • Total pull request authors: 21
  • Average comments per issue: 2.01
  • Average comments per pull request: 2.08
  • Merged pull requests: 98
  • Bot issues: 0
  • Bot pull requests: 7
Past Year
  • Issues: 10
  • Pull requests: 42
  • Average time to close issues: about 1 month
  • Average time to close pull requests: 3 days
  • Issue authors: 4
  • Pull request authors: 5
  • Average comments per issue: 0.6
  • Average comments per pull request: 2.5
  • Merged pull requests: 22
  • Bot issues: 0
  • Bot pull requests: 2
Top Authors
Issue Authors
  • tony (39)
  • johanneskastl (7)
  • hongwen000 (2)
  • dvzrv (2)
  • rockandska (2)
  • lazysegtree (2)
  • qwertimer (1)
  • eugene-komar-bmll (1)
  • pu15e (1)
  • nelsonjchen (1)
  • LuPengx (1)
  • shaoran (1)
  • dtrodrigues (1)
  • ssbarnea (1)
  • ghost (1)
Pull Request Authors
  • tony (102)
  • dependabot[bot] (9)
  • ppentchev (6)
  • TravisDart (4)
  • rockandska (4)
  • Ngalstyan4 (2)
  • Xeonacid (2)
  • patrislav1 (2)
  • ssbarnea (2)
  • lazysegtree (2)
  • kianmeng (2)
  • jayaddison (2)
  • zappolowski (2)
  • subbyte (2)
  • Moysenko (1)
Top Labels
Issue Labels
bug (8) enhancement (4) question (2) Packaging (2) pytest-plugin (1) pinned (1)
Pull Request Labels
dependencies (9) github_actions (2) pytest-plugin (1)

Packages

  • Total packages: 2
  • Total downloads:
    • pypi 2,719,694 last-month
  • Total docker downloads: 80,423
  • Total dependent packages: 24
    (may contain duplicates)
  • Total dependent repositories: 154
    (may contain duplicates)
  • Total versions: 242
  • Total maintainers: 1
pypi.org: libtmux

Typed library that provides an ORM wrapper for tmux, a terminal multiplexer.

  • Versions: 141
  • Dependent Packages: 24
  • Dependent Repositories: 154
  • Downloads: 2,719,694 Last month
  • Docker Downloads: 80,423
Rankings
Dependent packages count: 0.7%
Downloads: 1.1%
Dependent repos count: 1.2%
Docker downloads count: 1.2%
Average: 1.8%
Stargazers count: 2.1%
Forks count: 4.6%
Maintainers (1)
Last synced: 4 months ago
proxy.golang.org: github.com/tmux-python/libtmux
  • Versions: 101
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Stargazers count: 2.1%
Forks count: 2.6%
Average: 6.3%
Dependent packages count: 9.6%
Dependent repos count: 10.8%
Last synced: 4 months ago

Dependencies

poetry.lock pypi
  • alabaster 0.7.12 develop
  • astroid 2.11.7 develop
  • atomicwrites 1.4.1 develop
  • attrs 21.4.0 develop
  • babel 2.10.3 develop
  • beautifulsoup4 4.11.1 develop
  • black 22.6.0 develop
  • certifi 2022.6.15 develop
  • charset-normalizer 2.1.0 develop
  • click 8.1.3 develop
  • codecov 2.1.12 develop
  • colorama 0.4.5 develop
  • coverage 6.4.2 develop
  • docutils 0.18.1 develop
  • flake8 3.9.2 develop
  • furo 2022.6.21 develop
  • idna 3.3 develop
  • imagesize 1.4.1 develop
  • importlib-metadata 4.12.0 develop
  • iniconfig 1.1.1 develop
  • isort 5.10.1 develop
  • jinja2 3.1.2 develop
  • lazy-object-proxy 1.7.1 develop
  • livereload 2.6.3 develop
  • markdown-it-py 2.1.0 develop
  • markupsafe 2.1.1 develop
  • mccabe 0.6.1 develop
  • mdit-py-plugins 0.3.0 develop
  • mdurl 0.1.1 develop
  • mypy 0.961 develop
  • mypy-extensions 0.4.3 develop
  • myst-parser 0.18.0 develop
  • packaging 21.3 develop
  • pathspec 0.9.0 develop
  • platformdirs 2.5.2 develop
  • pluggy 1.0.0 develop
  • py 1.11.0 develop
  • pycodestyle 2.7.0 develop
  • pyflakes 2.3.1 develop
  • pygments 2.12.0 develop
  • pyparsing 3.0.9 develop
  • pytest 7.1.2 develop
  • pytest-cov 3.0.0 develop
  • pytest-mock 3.8.2 develop
  • pytest-rerunfailures 10.2 develop
  • pytest-watcher 0.2.3 develop
  • pytz 2022.1 develop
  • pyyaml 6.0 develop
  • requests 2.28.1 develop
  • six 1.16.0 develop
  • snowballstemmer 2.2.0 develop
  • soupsieve 2.3.2.post1 develop
  • sphinx 5.0.2 develop
  • sphinx-autoapi 1.8.4 develop
  • sphinx-autobuild 2021.3.14 develop
  • sphinx-autodoc-typehints 1.18.3 develop
  • sphinx-basic-ng 0.0.1a12 develop
  • sphinx-click 4.3.0 develop
  • sphinx-copybutton 0.5.0 develop
  • sphinx-inline-tabs 2021.4.11b8 develop
  • sphinx-issues 3.0.1 develop
  • sphinxcontrib-applehelp 1.0.2 develop
  • sphinxcontrib-devhelp 1.0.2 develop
  • sphinxcontrib-htmlhelp 2.0.0 develop
  • sphinxcontrib-jsmath 1.0.1 develop
  • sphinxcontrib-qthelp 1.0.3 develop
  • sphinxcontrib-serializinghtml 1.1.5 develop
  • sphinxext-opengraph 0.6.3 develop
  • sphinxext-rediraffe 0.2.7 develop
  • tomli 2.0.1 develop
  • tornado 6.2 develop
  • typed-ast 1.5.4 develop
  • typing-extensions 4.3.0 develop
  • unidecode 1.3.4 develop
  • urllib3 1.26.10 develop
  • watchdog 2.1.9 develop
  • wrapt 1.14.1 develop
  • zipp 3.8.1 develop
pyproject.toml pypi
  • black * develop
  • codecov * develop
  • coverage * develop
  • docutils ~0.18.0 develop
  • flake8 * develop
  • furo * develop
  • isort * develop
  • mypy * develop
  • myst_parser * develop
  • pytest * develop
  • pytest-cov * develop
  • pytest-mock * develop
  • pytest-rerunfailures * develop
  • pytest-watcher ^0.2.3 develop
  • sphinx * develop
  • sphinx-autoapi * develop
  • sphinx-autobuild * develop
  • sphinx-autodoc-typehints * develop
  • sphinx-click * develop
  • sphinx-copybutton * develop
  • sphinx-inline-tabs * develop
  • sphinx-issues * develop
  • sphinxext-opengraph * develop
  • sphinxext-rediraffe * develop
  • python ^3.7
.github/workflows/docs.yml actions
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • dorny/paths-filter v2.7.0 composite
  • jakejarvis/cloudflare-purge-action v0.3.0 composite
  • jakejarvis/s3-sync-action v0.5.1 composite
.github/workflows/tests.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v2 composite
  • pypa/gh-action-pypi-publish release/v1 composite
docs/requirements.txt pypi