# Terminals and commands

Open shells, save the terminals you reopen often, and run a project's dev servers and watchers.

You open shells, run a project's dev servers and work with your agents in terminals, each one a real
terminal opened in its project's folder. Rundesk passes a program's output to the screen unread, and
**stopping a terminal stops everything it started**, a dev server's child processes included.

## Open a shell

Press ⌘T (Ctrl+Shift+T on Windows) to open your login shell in a project, or PowerShell on Windows.
The terminal is named after the title its program sets, such as a shell's `make; make install`, or `Terminal 2` and so on, until you rename it
by double-clicking its name.

A terminal shows **Running** while a program is running in it and **Ready** at the prompt. A shell's
row is still there after you quit and reopen Rundesk. When the shell ends, its last screen remains, read-only, and **Start** opens a new
shell with that history drawn above it. ⌘W closes the shell shown for good.

The footer under a terminal shows its state, CPU and memory, and a count of the processes under it,
each with **Kill** to stop that one process without stopping the rest.

## Commands

A command is a named command line, such as a dev server or a watcher, listed in a project's
**Commands** section. It comes from the project's `desk.yml`, or it is a personal command you saved
for yourself in Rundesk.

- **Start**, **Stop** and **Restart** act on one command; **Start all** and **Stop all** on the whole
  project.
- Nothing starts on its own: a command runs only when you, or an agent you allow, start it.
- A command that fails on its own raises an alert; one you stop shows **Stopped**, not a failure.

[Run a dev stack](/docs/run-a-dev-stack.md) sets up a project's commands from start to finish.

### Add a command

Click **+** beside **Commands**:

- **Add for me** stores the command in Rundesk, for you alone.
- **Add to project file** writes it into the [project command file](/docs/desk-yml.md), so everyone with the project gets
  it. Every other line of the file is left as it was.

Shared commands live under `processes:` in the project command file. Edit the file by hand and Rundesk reads the
change within two seconds; [desk.yml](/docs/desk-yml.md) covers every key.

A stopped command's menu offers **Edit** and **Duplicate**, and **Delete** asks first. **Copy command name** copies the name an agent uses to type into a running command, such as a key a dev server reads, while **Commands: Type commands** is on in Settings › MCP.

## Save a terminal you reopen often

A saved terminal is a name and one command line, such as `ssh deploy@web-1`, that you open whenever
you want. Rundesk stores it, never in the project's files, and never stores a password.

1. Click **+** beside **Terminals** and choose **Save a terminal**.
2. Give it a name and, optionally, a command line.
3. Choose it from the same menu, under **Saved**, then press **Start**.

Each time you pick it, Rundesk adds a new terminal row, which starts nothing until you press **Start**. When the command
exits, as an ssh does when it disconnects, **Start** runs it again.

## Write notes for a terminal

Every terminal has **Terminal** and **Notes** tabs. The note is markdown for the commands, hosts and
how-tos that go with it. A saved terminal's note is shared by every terminal opened from it; any
other terminal's note lasts until you close it.

A note with something in it opens locked, to read and copy from: hold **Hold to unlock** for a second
to edit. It saves itself a second after your last change. To open a plain terminal again later, choose
**Save terminal** on the bar above it, and it becomes a saved terminal, its note coming along if it has one.

## Pop a terminal out into its own window

The button at the far right of the bar above a terminal, **Pop out into its own window**, moves an
agent, shell or command into a window of its own, on a second screen if you like. ⌘W in that window, or
**Pop back into the main window**, brings it back. A terminal is live in one window at a time.

## Keys that go to the terminal

Every key goes to the terminal, Ctrl and Option included, except the app's [short list of shortcuts](/docs/keyboard-shortcuts.md).

- **Shift+Enter** types a new line in an agent's prompt instead of submitting it.
- **Use Option as Meta key**, in Settings' **Terminal** tab, makes Option send Esc and the key, for word
  jumps and Emacs-style shortcuts (macOS only).
- **⌘-click** (Ctrl-click on Windows) opens a web address in your browser, or a file path, as the next
  section describes.
- **Dropping files** on a terminal pastes their paths.

Settings' **Terminal** tab also sets the font size, the cursor and how much scrollback each terminal
holds.

## Open a file from a path in a terminal

When an agent tells you it changed `src/App.tsx` or wrote up `docs/plan.md`, you don't have to go
looking. ⌘-click (Ctrl-click on Windows) the path and the file opens right in that terminal's own bar,
as a tab next to its **Agent**, **Terminal** or **Command** tab (and **Notes**, where it has one), so
it sits beside the work that produced it. Markdown is drawn as a page (unless you switched it to source), a CSV shows as
a table and code is colored, and you can edit and save it there with ⌘S, or choose **Open in editor**
for your own editor. A path with a line, such as `src/App.tsx:42`, opens at that line and marks it.

A command that runs in a subfolder, set by its `working_dir` in [desk.yml](/docs/desk-yml.md), prints paths
from that folder, so that's where Rundesk looks for them: `src/server.ts:12` in a command running in
`api` opens `api/src/server.ts`. If a path or link can't be opened, say the file was deleted since,
the error bar says why.

When you're done, close the tab with its X, a middle click or ⌘W.

Pop the terminal out and its file tabs come with it, into that window's bar. Nothing you type there
is lost: it's saved through the main window, and if both windows change the same file, you choose
which text to use.

Anything Rundesk can't show in a tab opens outside it. A file outside the project, or a
video, PDF, archive or any file too large to show, opens in its default app; a folder opens in Finder
(File Explorer on Windows), and a web address in your browser.

## Related pages

- [Run a dev stack](/docs/run-a-dev-stack.md): write a `desk.yml` for a real project and start its commands.
- [desk.yml](/docs/desk-yml.md): every key of the command file, with examples.
- [Coding agents](/docs/agents.md): start a coding agent in its own terminal.
