Skip to main content

Terminal UI

The Terminal User Interface (TUI) is opencode's primary interface -- a full-featured, keyboard-driven chat application for interacting with AI coding agents.

Starting the TUI

Launch the TUI from any directory:

opencode

Specify a project directory:

opencode /path/to/your/project

Pass an initial prompt to start a conversation immediately:

opencode "Explain the project structure"

Interface Layout

The TUI is divided into several panels:

┌──────────────────────────────────────────────────────┐
│ Session Header (model, session ID, agent mode) │
├──────────────────────────────────────────────────────┤
│ │
│ Conversation History │
│ ┌──────────────────────────────────────────────────┐ │
│ │ User: What does this project do? │ │
│ │ │ │
│ │ Agent: This project is a web application that... │ │
│ │ │ │
│ │ [File: src/index.ts] │ │
│ │ ```typescript │ │
│ │ const app = createApp(); │ │
│ │ ``` │ │
│ └──────────────────────────────────────────────────┘ │
│ │
│ Input Area (type your message here) │
│ [ > @app.ts How does the router work? ] │
│ │
│ Status Bar (provider, mode, connection status) │
├──────────────────────────────────────────────────────┤
│ [Ctrl+P] Palette [Tab] Mode [:@] Files [/?] Cmds │
└──────────────────────────────────────────────────────┘

Messaging

Type your message at the prompt and press Enter to send it.

Multi-line Messages

Use Alt+Enter or Esc+Enter to insert a newline for multi-line prompts.

File References with @

Type @ followed by a filename to trigger a fuzzy file search:

How does the authentication flow work in @auth.

Select the file from the dropdown to include its contents in the conversation context. You can reference multiple files in a single message:

Compare the implementations in @auth.ts and @auth.test.ts

Shell Commands with !

Prefix a message with ! to execute a shell command directly:

!npm test
!git log --oneline -5
!ls -la src/

The command output is captured and displayed in the conversation.

Slash Commands

Prefix a message with / to access built-in commands:

CommandDescription
/connectOpen the provider connection manager
/compactSummarize and compress the current session history
/detailsShow detailed session information
/editorEdit the current prompt in the system $EDITOR
/exitExit opencode
/exportExport the session transcript to a file via $EDITOR
/helpDisplay help information
/initInitialize project context (creates AGENTS.md)
/modelsList and switch between models/providers
/newStart a fresh session
/redoRe-apply the last undone change
/sessionsList all saved sessions
/shareShare the current session
/themesBrowse and select color themes
/thinkingToggle the model's thinking/reasoning display
/undoRevert the last agent modification
/unshareRevoke sharing on the current session

Command Palette

Press Ctrl+P to open the command palette. This is a fuzzy-search interface that lists every available action, command, and setting. Start typing to filter, press Enter to execute.

Available palette entries include:

  • All slash commands
  • Theme switching
  • Config editing
  • Session navigation
  • Agent switching
  • View toggles

Keybinds

Default keyboard shortcuts:

BindingAction
Ctrl+POpen command palette
Ctrl+CCancel current request
Ctrl+DScroll down one page
Ctrl+UScroll up one page
HomeScroll to top of conversation
EndScroll to bottom of conversation
PgUp / PgDnPage up/down
Up / DownNavigate message history (when input is empty)

Actions

BindingAction
Ctrl+X CCompact session
Ctrl+X EOpen prompt in editor
Ctrl+X QExit
Ctrl+X XExport session
Ctrl+X MShow model list
Ctrl+X NNew session
Ctrl+X RRedo
Ctrl+X UUndo
Ctrl+X LList sessions
Ctrl+X TOpen theme selector
Alt+EnterInsert newline

Agent Switching

BindingAction
TabCycle between Build and Plan primary agents
Shift+TabCycle in reverse
BindingAction
Ctrl+FSearch within the current conversation
Ctrl+GFind next search result

Agent Mode Switching

Press Tab to switch between the Build and Plan primary agents:

  • Build mode: The agent actively reads/writes files, runs commands, and applies changes. Use this when you want work done.
  • Plan mode: The agent researches, analyzes, and produces a detailed plan before any code is written. Use this for complex tasks where you want to review the approach first.

The current mode is displayed in the session header. You can also switch agents via the command palette.

Session Management

Child / Parent Sessions

Each conversation creates a parent session. When you send a new message, a child session is created. This creates a tree structure:

Session A (initial)
├── Session B (second message)
│ ├── Session D (fourth message)
│ └── Session E (fifth message)
└── Session C (third message)

Navigate between sessions with /sessions. Select any session to resume it. The tree structure lets you explore different approaches without losing context.

Undo and Redo

opencode creates automatic git snapshots before every file modification:

/undo # Revert the last modification
/redo # Reapply a reverted modification

Snapshots are taken per-file before any edit, write, or patch operation. You can undo multiple steps sequentially.

Session Details

/details

Shows the current session's ID, parent session, creation time, active provider and model, and file change count.

Start Fresh

/new

Creates a new session in the same project. Previous sessions remain available via /sessions.

Editor Integration

/editor Command

Running /editor opens your current message in the system's $EDITOR. This is useful for composing long or complex prompts.

Set the EDITOR environment variable:

export EDITOR="code --wait" # VS Code
export EDITOR="nvim" # Neovim
export EDITOR="vim" # Vim
export EDITOR="nano" # Nano

The --wait flag is important for GUI editors -- it makes the editor block until the file is closed.

/export Command

Running /export opens the full session transcript in $EDITOR for saving. The transcript is written to a temporary file. Save it to your desired location.

Theme System

Browse and apply themes:

/themes

Built-in themes include:

  • catppuccin-latte, catppuccin-mocha, catppuccin-frappe, catppuccin-macchiato
  • dracula, dracula-pro
  • nord, nord-light
  • one-dark, one-light
  • tokyo-night, tokyo-night-light
  • gruvbox, gruvbox-light
  • solarized-dark, solarized-light
  • monokai
  • github-dark, github-light

TUI Configuration

The TUI is configured via tui.json, located at ~/.config/opencode/tui.json. This file controls theme, keybinds, scrolling behavior, mouse support, notifications, and diff display.

Example tui.json

{
"theme": "catppuccin-mocha",
"keybinds": [],
"scroll_speed": 3,
"scroll_acceleration": true,
"mouse": true,
"attention": {
"notifications": true,
"sound": "chime"
},
"diff_style": "unified",
"leader_timeout": 1000,
"showUsername": false
}

Options

OptionTypeDefaultDescription
themestring"catppuccin-latte"Theme name or path to custom theme
keybindsarray[]Custom keybinding overrides
scroll_speednumber3Lines per scroll step
scroll_accelerationbooleantrueAccelerate scrolling with duration
mousebooleantrueEnable mouse support
attention.notificationsbooleanfalseDesktop notifications on agent actions
attention.soundstring / nullnullSound file to play on attention events
diff_stylestring"unified"Diff display style ("unified" or "split")
leader_timeoutnumber1000Timeout in ms for leader key sequences (e.g., Ctrl+X)
showUsernamebooleantrueShow username in the UI

Attention Feature

When attention.notifications is enabled, opencode sends desktop notifications when the agent takes an action. This is useful when you're context-switching or waiting for a long-running task.

Configure notification sounds by setting attention.sound to a path to a .wav or .mp3 file:

{
"attention": {
"notifications": true,
"sound": "/path/to/chime.wav"
}
}

Image Support

If your configured model supports vision (e.g., Claude, GPT-4o, Gemini), you can include images in your prompts:

  • Drag and drop: Drag an image file from your file manager onto the TUI to attach it
  • Clipboard: Copy an image and paste it into the input area

Images are displayed inline in the conversation and sent to the model as part of your message.

Customization

Custom Themes

Create a custom theme by defining a JSON file:

{
"name": "my-theme",
"type": "dark",
"colors": {
"background": "#1e1e2e",
"foreground": "#cdd6f4",
"primary": "#89b4fa",
"secondary": "#a6e3a1",
"error": "#f38ba8",
"warning": "#fab387",
"success": "#a6e3a1",
"border": "#313244",
"selection": "#45475a",
"inputBackground": "#181825",
"inputForeground": "#cdd6f4",
"codeBackground": "#181825",
"linkColor": "#89b4fa"
}
}

Load the theme in your config:

{
"theme": "/path/to/my-theme.json"
}

Custom Keybinds

Override or add keybindings:

{
"keybinds": [
{
"key": "ctrl+shift+p",
"command": "commandPalette"
},
{
"key": "alt+1",
"command": "switchAgent",
"args": { "agent": "build" }
},
{
"key": "alt+2",
"command": "switchAgent",
"args": { "agent": "plan" }
},
{
"key": "ctrl+enter",
"command": "sendMessage"
}
]
}

Available modifiers: ctrl, alt, shift, meta.

Available commands: commandPalette, sendMessage, insertNewline, cancelRequest, newSession, undo, redo, compact, exportSession, openEditor, listSessions, listModels, themeSelector, exit, switchAgent, scrollUp, scrollDown, scrollToTop, scrollToBottom, search, findNext.

Username Toggle

Toggle username display via the command palette:

  1. Press Ctrl+P
  2. Type "Toggle Username"
  3. Press Enter

Alternatively, set it in tui.json:

{
"showUsername": false
}

Troubleshooting

TUI Doesn't Render

If the TUI displays garbled output or doesn't render at all:

  1. Ensure TERM is set correctly:

    export TERM=xterm-256color
  2. Run in pure mode:

    opencode --pure
  3. Check your terminal emulator supports true color:

    echo $COLORTERM
    # Should output: truecolor or 24bit
  4. Use a recommended terminal (WezTerm, Alacritty, Ghostty, Kitty)

Keyboard Shortcuts Not Working

Some terminal emulators or window managers intercept certain key combinations:

  • Ctrl+X sequences may conflict with tmux (use Ctrl+X twice in tmux, or rebind in tui.json)
  • Alt keybinds may conflict with menu accelerators in some terminals
  • Ctrl+P for command palette may conflict with some shells

Use the command palette (Ctrl+P) as a fallback for any action.

Slow Performance

If the TUI feels sluggish:

  1. Reduce scroll_speed in tui.json
  2. Disable scroll_acceleration
  3. Use /compact to compress long sessions
  4. Start a fresh session with /new

What's Next