> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/sinelaw/fresh/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrated Terminal

> Built-in terminal emulator with advanced scrollback, keyboard capture, and persistence features

Fresh includes a powerful built-in terminal emulator that seamlessly integrates with your editing workflow.

## Opening a Terminal

<Steps>
  <Step title="Via Command Palette">
    Press `Ctrl+P` and search for **"Open Terminal"**
  </Step>

  <Step title="Multiple Terminals">
    You can open multiple terminal tabs and switch between them like regular file buffers
  </Step>
</Steps>

## Terminal Modes

The terminal has two modes, indicated in the status bar:

<Tabs>
  <Tab title="Terminal Mode">
    **Status bar shows:** `Terminal`

    Your keyboard input goes directly to the shell. This is the default mode for interacting with the terminal.
  </Tab>

  <Tab title="Scrollback Mode">
    **Status bar shows:** `Terminal (read only)`

    The terminal output becomes a read-only buffer that you can scroll through, search, and copy text from.
  </Tab>
</Tabs>

## Switching Between Modes

Toggle between terminal mode and scrollback mode:

<CodeGroup>
  ```text Primary Toggle theme={null}
  Ctrl+Space   Toggle between terminal and scrollback mode
  ```

  ```text Alternative theme={null}
  Ctrl+]       Exit terminal mode (same as Ctrl+Space)
  ```
</CodeGroup>

## Keyboard Capture

By default, most editor keybindings (like `Ctrl+P` for command palette) still work in terminal mode. If you need to send these keys to the terminal instead:

<Steps>
  <Step title="Enable Keyboard Capture">
    Press **F9** to toggle keyboard capture mode
  </Step>

  <Step title="Captured Mode Behavior">
    When keyboard capture is enabled:

    * Status bar shows **"Terminal \[capture]"**
    * All keys except `F9` are sent to the terminal
    * The UI dims (menu bar, status bar, other splits) to clearly show focus is exclusively on the terminal
  </Step>

  <Step title="Disable Capture">
    Press **F9** again to return to normal terminal mode
  </Step>
</Steps>

<Warning>
  In keyboard capture mode, all editor shortcuts are disabled except F9. This ensures commands like `Ctrl+C` are sent to the terminal process instead of the editor.
</Warning>

## Scrollback Navigation

In scrollback mode, you can use standard editor navigation:

| Key                              | Action                                      |
| -------------------------------- | ------------------------------------------- |
| Arrow keys / Page Up / Page Down | Scroll through output                       |
| `Ctrl+Home`                      | Jump to the beginning of scrollback history |
| `Ctrl+End`                       | Jump to the end                             |
| `Ctrl+F`                         | Search through terminal output              |

## Tips and Features

<AccordionGroup>
  <Accordion title="Workspace Persistence">
    Terminal scrollback is preserved across editor restarts, but running processes are terminated.
  </Accordion>

  <Accordion title="Session Persistence (Experimental)">
    Use `fresh -a` to start in session mode, then detach with `Ctrl+Shift+D` to keep terminal processes running in the background. Reattach with `fresh -a`.

    See [Session Persistence](./session-persistence.mdx) for details.
  </Accordion>

  <Accordion title="Automatic Scroll">
    When new output arrives while you're in scrollback mode, the terminal automatically returns to terminal mode to show the latest output.

    <Note>
      Disable this behavior with the `terminal.jump_to_end_on_output` config option.
    </Note>
  </Accordion>

  <Accordion title="Automatic Resizing">
    The terminal automatically resizes when you resize the editor or split panes.
  </Accordion>
</AccordionGroup>

## Windows Support

Fresh supports full terminal emulation on Windows 10 (1809+) via ConPTY.

<Info>
  * PowerShell is preferred over cmd.exe
  * Stdin piping works: `type file | fresh`
</Info>
