aspire terminal attach command
aspire terminal attach - Attach the local terminal to an interactive PTY session for a resource.
Synopsis
Section titled “Synopsis”aspire terminal attach <resource> [options]Description
Section titled “Description”The aspire terminal attach command connects your local terminal to the interactive pseudo-terminal (PTY) session of a resource that was registered with WithTerminal(). Once attached, you interact with the resource’s terminal, as if it were running directly in your console. For example, you can drive its TUI or type into its shell.
The command discovers the running AppHost, verifies it supports the terminals.v1 capability, looks up the resource, and connects to one of its terminal replicas. A singleton resource accepts its display name or exact instance ID. A replicated resource requires an exact instance ID. Run aspire describe and use the desired replica’s value in the Name column. If a display name matches multiple instances, the command fails and lists their instance IDs instead of prompting for a replica.
Multiple peers can attach to the same session at once. By default, attach takes the primary role and drives the terminal’s dimensions. Pass --viewer to join as a passive viewer instead. This technique is useful when another peer, such as the dashboard, is currently driving the session.
While attached, the following hotkeys are available:
| Hotkey | Action |
|---|---|
Ctrl+B D | Detach from the session and exit cleanly. |
Ctrl+B T | Take control (request the primary role). |
If the selected replica has already exited, the command attaches to the historical output buffer; no live input is sent.
Arguments
Section titled “Arguments”The following arguments are available:
-
<resource>The resource display name for a singleton, or the exact resource instance ID for a replica. Use
aspire describeto discover instance IDs. The resource must have been registered with.WithTerminal().
Options
Section titled “Options”The following options are available:
-
--apphost <apphost>The path to the Aspire AppHost file or project file, such as
apphost.mts,apphost.cs, or an AppHost.csproj. -
--viewerConnect as a viewer (secondary) instead of taking primary control. Viewers see the terminal output but do not drive its dimensions. This option is useful when another peer (for example, the dashboard) is currently driving the session. Take control later with
Ctrl+B T. -
-?, -h, --helpPrints help and usage documentation for the available commands and options.
-
-l, --log-level <Critical|Debug|Error|Information|None|Trace|Warning>Set the minimum log level for console output. Use this option to increase diagnostics while troubleshooting or reduce output in scripted runs.
-
--non-interactiveRun the command in non-interactive mode, disabling all interactive prompts and spinners.
-
--nologoSuppress the startup banner and telemetry notice.
-
--bannerDisplay the animated Aspire CLI welcome banner.
-
--wait-for-debuggerWait for a debugger to attach before running a command.
Examples
Section titled “Examples”-
Attach to a resource’s terminal:
Aspire CLI aspire terminal attach agent -
Attach to an exact instance of a replicated resource. Replace
agent-abc123with an instance ID fromaspire describe:Aspire CLI aspire terminal attach agent-abc123 -
Join an existing session as a passive viewer:
Aspire CLI aspire terminal attach agent --viewer