|
|
@@ -0,0 +1,280 @@
|
|
|
+---
|
|
|
+title: TUI
|
|
|
+description: Using the opencode terminal user interface.
|
|
|
+---
|
|
|
+
|
|
|
+import { Tabs, TabItem } from "@astrojs/starlight/components"
|
|
|
+
|
|
|
+opencode provides an interactive terminal interface or TUI for working on your projects with an LLM.
|
|
|
+
|
|
|
+Running opencode starts the TUI for the current directory.
|
|
|
+
|
|
|
+```bash
|
|
|
+opencode
|
|
|
+```
|
|
|
+
|
|
|
+Or you can start it for a specific working directory.
|
|
|
+
|
|
|
+```bash
|
|
|
+opencode /path/to/project
|
|
|
+```
|
|
|
+
|
|
|
+Once you're in the TUI, you can prompt it with a message.
|
|
|
+
|
|
|
+```text
|
|
|
+Give me a quick summary of the codebase.
|
|
|
+```
|
|
|
+
|
|
|
+:::tip
|
|
|
+You can also use `@` to reference files in your messages.
|
|
|
+:::
|
|
|
+
|
|
|
+```text "@packages/functions/src/api/index.ts"
|
|
|
+How is auth handled in @packages/functions/src/api/index.ts?
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## Commands
|
|
|
+
|
|
|
+When using the opencode TUI, you can type `/` followed by a command name to quickly execute actions. For example:
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/help
|
|
|
+```
|
|
|
+
|
|
|
+Most commands also have keybind using `ctrl+x` as the leader key, where `ctrl+x` is the default leader key. [Learn more](/docs/keybinds).
|
|
|
+
|
|
|
+Here are all available slash commands:
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### compact
|
|
|
+
|
|
|
+Compact the current session. _Alias_: `/summarize`
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/compact
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x c`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### details
|
|
|
+
|
|
|
+Toggle tool execution details.
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/details
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x d`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### editor
|
|
|
+
|
|
|
+Open external editor for composing messages. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/editor
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x e`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### exit
|
|
|
+
|
|
|
+Exit opencode. _Aliases_: `/quit`, `/q`
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/exit
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x q`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### export
|
|
|
+
|
|
|
+Export current conversation to Markdown and open in your default editor. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/export
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x x`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### help
|
|
|
+
|
|
|
+Show the help dialog.
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/help
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x h`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### init
|
|
|
+
|
|
|
+Create or update `AGENTS.md` file. [Learn more](/docs/rules).
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/init
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x i`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### models
|
|
|
+
|
|
|
+List available models.
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/models
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x m`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### new
|
|
|
+
|
|
|
+Start a new session. _Alias_: `/clear`
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/new
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x n`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### redo
|
|
|
+
|
|
|
+Redo a previously undone message. Only available after using `/undo`. **Any file changes that were reverted will also be restored.**
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/redo
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x r`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### sessions
|
|
|
+
|
|
|
+List and switch between sessions. _Aliases_: `/resume`, `/continue`
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/sessions
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x l`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### share
|
|
|
+
|
|
|
+Share current session. [Learn more](/docs/share).
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/share
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x s`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### themes
|
|
|
+
|
|
|
+List available themes.
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/themes
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x t`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### undo
|
|
|
+
|
|
|
+Undo last message in the conversation. Removes the most recent user message and all subsequent responses. **Any file changes made during the undone messages will also be reverted.**
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/undo
|
|
|
+```
|
|
|
+
|
|
|
+**Keybind:** `ctrl+x u`
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+### unshare
|
|
|
+
|
|
|
+Unshare current session. [Learn more](/docs/share#un-sharing).
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+/unshare
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## Bash commands
|
|
|
+
|
|
|
+Start a line with `!` to run a shell command. The output is added to the conversation as a tool result.
|
|
|
+
|
|
|
+```bash frame="none"
|
|
|
+!ls -la
|
|
|
+```
|
|
|
+
|
|
|
+---
|
|
|
+
|
|
|
+## Editor setup
|
|
|
+
|
|
|
+Both the `/editor` and `/export` commands use the editor specified in your `EDITOR` environment variable.
|
|
|
+
|
|
|
+<Tabs>
|
|
|
+ <TabItem label="Linux/macOS">
|
|
|
+ ```bash
|
|
|
+ export EDITOR=nano # or vim, code, etc.
|
|
|
+ ```
|
|
|
+
|
|
|
+ To make it permanent, add this to your shell profile;
|
|
|
+ `~/.bashrc`, `~/.zshrc`, etc.
|
|
|
+
|
|
|
+ </TabItem>
|
|
|
+ <TabItem label="Windows (CMD)">
|
|
|
+ ```bash
|
|
|
+ set EDITOR=notepad # or code, vim, etc.
|
|
|
+ ```
|
|
|
+
|
|
|
+ To make it permanent, use **System Properties** > **Environment
|
|
|
+ Variables**.
|
|
|
+
|
|
|
+ </TabItem>
|
|
|
+ <TabItem label="Windows (PowerShell)">
|
|
|
+ ```bash
|
|
|
+ $env:EDITOR = "notepad" # or "code", "vim", etc.
|
|
|
+ ```
|
|
|
+
|
|
|
+ To make it permanent, add this to your PowerShell
|
|
|
+ profile.
|
|
|
+
|
|
|
+ </TabItem>
|
|
|
+</Tabs>
|
|
|
+
|
|
|
+Popular editor options include:
|
|
|
+
|
|
|
+- `code` - Visual Studio Code
|
|
|
+- `vim` - Vim editor
|
|
|
+- `nano` - Nano editor
|
|
|
+- `notepad` - Windows Notepad
|
|
|
+- `subl` - Sublime Text
|