Here is a simple example to use this library.
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 25/100
- Tipo di issue
- Documentazione
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- documentation
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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)

- Lingua principale
- Python
- Stelle
- 1.2k
- Fork
- 127
- Merge medio
- 2h 13m
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di tmux-python/libtmux
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
tmux-python/libtmux#759 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tmux-python/libtmux#745 · 2 commenti ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
tmux-python/libtmux#744 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
tmux-python/libtmux#731 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tmux-python/libtmux#654 ·
Tutte le issue di tmux-python/libtmux
Issue simili
-
bug confirmed issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
open-webui/open-webui#30750 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
OpenwaterHealth/openmotion-bloodflow-app#604 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100