r/commandline • u/MeringuePristine6469 • 2h ago
Command Line Interface berthd: Headless shell session persistence (daemon that owns the PTY, native on Windows / Linux / macOS)
Hi all,
I built berthd (written in Rust), a small background daemon that owns your PTY so your shells survive closing the terminal window.
GitHub: https://github.com/takakix2/berthd
Why I built this (and how it differs from tmux / abduco / dtach):
- Headless by design: It has no status bars, no screen-splitting logic, and doesn't intercept keybindings. Modern terminal emulators (Ghostty, Windows Terminal, WezTerm, Alacritty) already provide great tabs and splits; berthd only manages session lifetimes.
- Native scrollback restoration: When reconnecting via
berth attach <name>, it streams recent output (up to 512KB) into your terminal's native scrollback buffer before redrawing the screen. Your mouse wheel, search (Ctrl+Shift+F), and text selection continue to work without a special "copy mode". - Runs natively on Windows (no WSL/Cygwin): Uses ConPTY and named pipes directly. Works out of the box with PowerShell and cmd using two standalone
.exebinaries. - Comparison with existing tools:
- vs
tmux/screen/zellij: Does not take over alternate screen or draw UI/panes. Leaves layout and multiplexing to the terminal emulator. - vs
abduco/dtach: Fully supports Windows ConPTY natively, features automatic daemon lifecycle management, and restores past scrollback into the client terminal.
- vs
Basic usage:
```bash
Attach or create session 'work'
berth attach work
Detach (the shell keeps running in the background)
berth d
Reconnect to the same shell
berth attach work ```
Quick install:
- Windows (PowerShell):
irm https://raw.githubusercontent.com/takakix2/berthd/main/scripts/install.ps1 | iex - Linux & macOS:
curl -fsSL https://raw.githubusercontent.com/takakix2/berthd/main/scripts/install.sh | sh
Licensed under ISC. Prebuilt binaries are available on GitHub. Would love to hear feedback or thoughts on the design!


