Feature Proposal: Terminal CLI for Programmatic Terminal Control #45557
rabsef-bicrym
started this conversation in
Feature Requests
Replies: 2 comments 2 replies
-
|
|
Beta Was this translation helpful? Give feedback.
1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
This proposal introduces a Terminal CLI to Zed that enables programmatic control of the integrated terminal—creating, managing, reading, and organizing terminal panes from the command line. A working implementation is ready for review.
Demo
Screen.Recording.2025-12-22.at.9.20.57.PM.mov
Motivation
Many developer workflows benefit from programmatic control of terminals inside the editor:
AI assistants are one use case for this, but the core value is broader automation and scripting around terminals in the workspace.
Complementing the Agent Panel's Terminal Tool
Zed's Agent Panel terminal tool is intentionally one-shot and stateless. It cannot run long-lived processes and does not preserve terminal state between calls. The Terminal CLI fills that gap by enabling:
Possible Follow-ups (Non-blocking)
If this CLI is accepted, a future Zed extension could wrap these commands in an MCP server to expose persistent terminals to the Agent Panel. This would allow agents to create visible terminals and monitor long-running tasks without blocking on one-shot commands.
Prior Art
iTerm2 provides similar functionality through its Python API, gated behind an experimental feature flag.
Groundwork PRs
Over the past week, I submitted three PRs as groundwork for this feature:
#45180 (merged) - Fixed
RevealStrategy::NoFocusso terminals can be created without stealing focus. Closes RevealStrategy::NoFocus and RevealStrategy::Never do not respect focus settings when terminal pane has focus #45179.#45282 (merged) - Fixed scrollbar arithmetic underflow panics with
saturating_sub. Closes Terminal scrollbar panics on arithmetic underflow #45281.#45280 (closed) - Added
Pane::add_item_behindfor background tab creation. Closes Pane::add_item lacks API for adding items without tab activation #45279. This was closed by @probably-neb with the feedback: "without usage code, I can't test that it works and I don't see the benefit in merging code that is just unused." I responded that I'd return with a CLI PR providing that usage—this is that PR.The Feature
A
zed terminalsubcommand with the following operations:createsendkeyreadlistclosesplitmovelayoutfocusidlecwdtitleSecurity: Disabled by default. Users must explicitly enable with:
{ "terminal": { "cli_enabled": true } }ZED_TERM_IDis always present in terminals; the CLI uses it when enabled.Demo
Here's a demo script that creates a spiral of numbered terminal panes, animates movement through them, and showcases layout reorganization:
Click to expand demo script
Implementation
The PR is ready for review. It includes:
docs/src/command-line-interface.mdadd_item_behindmethod, now with concrete usagePR link: #45558
Beta Was this translation helpful? Give feedback.
All reactions