portable-pty

Cross-platform Rust API for pseudo-terminals, with runtime-selectable implementations

Library
Cargo
v0.9.0
29,043 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
90 /100 Excellent
Development Activity 96
Maintenance 96
Community 68
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 86
Code Quality 80
Innovation 82
Learning Curve 76

portable-pty is the cross-platform pseudo-terminal (pty) abstraction extracted from the WezTerm terminal emulator’s monorepo. It provides PtySystem/PtyPair traits for opening a pty and spawning a child process attached to it, unifying Unix openpty/forkpty semantics and the Windows ConPTY API behind one interface, with an additional serial module for talking to physical or virtual serial ports using the same pty-like traits.

Unlike most pty crates that hard-code a single platform backend, portable-pty is explicitly designed to let callers select an implementation at runtime via trait objects (Box<dyn PtySystem>), which is what lets WezTerm itself support Unix ptys, Windows ConPTY, and even serial-port ‘ptys’ through the same terminal-multiplexer code paths. It’s published independently on crates.io and widely reused by other terminal and shell-integration tooling beyond WezTerm itself.

What You Get

  • native_pty_system() to get the right pty backend (Unix pty, Windows ConPTY) for the current platform behind a common trait object
  • PtyPair with master/slave handles for reading/writing pty output and spawning a command into the slave side
  • CommandBuilder for constructing the child process command, arguments, environment, and working directory to spawn into the pty
  • A serial module exposing the same pty-like read/write traits over physical or virtual serial ports
  • Optional serde_support feature for serializing pty configuration types

Common Use Cases

  • Building a terminal emulator or terminal multiplexer that needs to spawn and manage shell processes across Unix and Windows
  • Writing a Rust-based shell integration, REPL wrapper, or automation tool that needs true pty semantics (not just piped stdio) for interactive programs
  • Testing CLI tools that behave differently under a tty versus a pipe, by driving them through a real pseudo-terminal
  • Implementing serial-port communication tooling that can share code paths with pty-based terminal logic

Under The Hood

Architecture - lib.rs defines the platform-agnostic PtySystem/PtyPair/MasterPty/SlavePty trait hierarchy and a native_pty_system() factory that returns the appropriate backend; unix.rs implements the Unix side via openpty/fork-style syscalls (through nix/libc), a win/ module implements the Windows ConPTY backend, and cmdbuilder.rs provides a cross-platform command/argument/environment builder used to spawn the child process into the pty. Tech Stack - Rust 2018 edition with nix (term/fs features) and libc for Unix syscalls, winapi/winreg/shared_library for the Windows ConPTY path, filedescriptor for cross-platform fd handling, serial2 for the serial-port module, and workspace-inherited dependency versions shared across the wider wezterm monorepo. Code Quality - The crate ships runnable examples/ (bash.rs, whoami.rs, whoami_async.rs, narrow.rs) demonstrating real spawn/read/write usage across sync and async (via smol) code paths, and benefits from WezTerm’s very active, heavily-tested monorepo CI (21+ commits/month, 435 contributors) even though the crate itself has no dedicated unit-test directory — correctness is largely validated through WezTerm’s own end-to-end usage. API Design - The runtime-selectable trait-object design (Box<dyn PtySystem>) is the crate’s key differentiator versus compile-time-only pty bindings, and the doc-comment example at the top of lib.rs covers the full open-spawn-read-write lifecycle in under 15 lines, keeping the common case simple despite the cross-platform abstraction underneath.

Used by 5 apps in this directory

TypeScript
90%
Other

FastGPT

AI Agents · AI Development

29,758

Build, debug, and deploy knowledge-based AI agents with a visual workflow editor, RAG retrieval, and support for any OpenAI-compatible LLM.

View details
93
Repo Health
84
Technical
66
Dependency
Built with
TypeScript 90%
Updated 4 days ago
Rust
88%
GPL 2.0

Fresh

Code Editors · Developer Tools

9,052

A zero-configuration terminal text editor with familiar keybindings, full mouse support, LSP-powered IDE features, and a built-in orchestrator for running multiple coding agents in parallel worktrees.

View details
86
Repo Health
88
Technical
71
Dependency
Built with
Rust 88%
Updated 5 days ago
Rust
94%
Apache 2.0

herdr

AI Agents · Developer Tools

41,057

A terminal-native agent multiplexer that runs Claude, Codex, Gemini, and other coding agents side by side in real, persistent panes you can detach from and reattach to from anywhere.

View details
84
Repo Health
84
Technical
72
Dependency
Built with
Rust 94%
Updated 5 days ago
TypeScript
88%
MIT

Mistle

AI Agents · Developer Tools

93

Self-hostable platform for running autonomous coding agents in isolated, credentialless sandboxes with brokered credentials, reusable snapshots, and event-driven triggers.

View details
68
Repo Health
76
Technical
70
Dependency
Built with
TypeScript 88%
Rust 11%
Updated 2 months ago
Rust
50%
Apache 2.0

Vibe Kanban

AI Agents · AI Code Assistants · Project Management

28,209

A kanban board for planning work and dispatching Claude Code, Codex, Gemini CLI, and eight other coding agents into isolated git worktrees, then reviewing and merging their diffs from one UI.

View details
75
Repo Health
75
Technical
64
Dependency
Built with
Rust 50%
TypeScript 46%
Updated 1 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers