🖥️ PyTerminus: Virtual Multi-Terminal Manager in Python
A powerful, Python-based terminal session manager — split, persist, search.
PyTerminus is a terminal-based multi-shell session manager, built entirely in Python. Inspired by tools like tmux and screen, it allows users to run and manage multiple terminal sessions within a single CLI window using a flexible, modern TUI interface.
With support for split panes, custom shell environments, scrollback logging, and persistent sessions, PyTerminus is perfect for power users, sysadmins, or developers looking for a Python-native solution.
- 🪟 Split Terminal Interface: Horizontally or vertically split your terminal into multiple interactive shells
- 🔄 Persistent Sessions: Powered by Python's pty and os.fork, resume work where you left off
- 🧠 Smart Command Logging: Logs commands and outputs per session with timestamps and optional search
- 🕹️ TUI Navigation (Curses/Urwid): Switch, resize, rename panes via keyboard shortcuts in a responsive terminal UI
- 🔍 Searchable Scrollback: Scroll through terminal history and search across outputs with regex or fuzzy match
- 🎯 Session Profiles: Define and launch sessions with predefined commands (e.g., Python shell, SSH, docker, etc.)
- 🧩 Plugin Architecture (Planned): Add custom panes (e.g., system monitor, Git status, chat, etc.)
| Component | Technology |
|---|---|
| Terminal UI | urwid |
| Pseudo-Terminals | pty, os.fork, subprocess |
| Input Handling | select, termios, tty |
| Logging | JSON or plain text logs |
| Configurations | yaml, argparse, dataclasses |
$ pyterminus
🪟 [Pane 1]: zsh (~/projects)
🪟 [Pane 2]: python3
🪟 [Pane 3]: htop
⎈ Ctrl+n: new pane
⎈ Ctrl+arrows: move
⎈ Ctrl+s: save session
⎈ Ctrl+/: search history$ pyterminus --session dev-work.yaml
✔ Loaded session: 3 terminals (web server, redis, docker shell)git clone https://github.com/yourusername/pyterminus
cd pyterminus
pip install -r requirements.txt
python pyterminus.pypyterminus/
├── tui/
│ ├── layout.py # TUI layout manager
│ ├── keybindings.py # Shortcut config
│ └── main_ui.py # Main UI component
├── core/
│ ├── terminal_pane.py # Pty + input/output piping
│ ├── session_manager.py # Persistent session saving/loading
│ └── logger.py # Smart log writer
├── profiles/
│ ├── sample_session.yaml # Example profile
│ └── web_dev.yaml # Web development profile
├── tests/
│ ├── test_session_manager.py
│ ├── test_logger.py
│ ├── test_keybindings.py
│ └── test_layout.py
├── pyterminus.py # Main entry point
├── requirements.txt
└── README.md
Usage: pyterminus [OPTIONS]
Options:
--session [file.yaml] Load saved session profile
--log-dir [folder/] Specify custom log directory
--theme [dark|light] UI theme
--shell [bash|zsh|fish] Default shell for new panes
--debug Enable debug modename: dev-env
panes:
- name: server
command: python manage.py runserver
cwd: ~/projects/myapp
- name: redis
command: redis-cli
- name: shell
command: zshCtrl+n: New paneCtrl+Tab: Next paneCtrl+Shift+Tab: Previous paneCtrl+1-9: Switch to pane 1-9
Ctrl+x: Close paneCtrl+r: Rename paneCtrl+s: Save sessionCtrl+l: Load session
Ctrl+h: Split horizontalCtrl+v: Split verticalCtrl++: Increase pane sizeCtrl+-: Decrease pane size
Ctrl+/: Search historyCtrl+f: Search outputCtrl+g: Clear search
F1: Show helpF2: Show statusF3: Show logsCtrl+q: QuitCtrl+\: Force quit
Run the test suite:
# Install test dependencies
pip install pytest pytest-cov
# Run all tests
pytest tests/
# Run with coverage
pytest tests/ --cov=core --cov=tui --cov-report=html
# Run specific test file
pytest tests/test_session_manager.py- Windows Support: Limited support due to pty module differences
- Terminal Resizing: May not work perfectly in all terminal emulators
- Shell Integration: Some advanced shell features may not work as expected
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Inspired by tmux and screen
- Built with urwid for TUI
- Uses Python's pty module for pseudo-terminals
- ✅ Core functionality implemented
- ✅ Session management working
- ✅ TUI interface functional
- ✅ Logging system complete
- ✅ Test suite comprehensive
- 🔄 Plugin architecture (planned)
- 🔄 Advanced search features (planned)
- 🔄 Windows compatibility (planned)
Made with ❤️ by @SK8-infi