TUI
Using the opencode terminal user interface.
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.
opencode
Or you can start it for a specific working directory.
opencode /path/to/project
Once you’re in the TUI, you can prompt it with a message.
Give me a quick summary of the codebase.
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:
/help
Most commands also have keybind using ctrl+x
as the leader key, where ctrl+x
is the default leader key. Learn more.
Here are all available slash commands:
compact
Compact the current session. Alias: /summarize
/compact
Keybind: ctrl+x c
details
Toggle tool execution details.
/details
Keybind: ctrl+x d
editor
Open external editor for composing messages. Uses the editor set in your EDITOR
environment variable. Learn more.
/editor
Keybind: ctrl+x e
exit
Exit opencode. Aliases: /quit
, /q
/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.
/export
Keybind: ctrl+x x
help
Show the help dialog.
/help
Keybind: ctrl+x h
init
Create or update AGENTS.md
file. Learn more.
/init
Keybind: ctrl+x i
models
List available models.
/models
Keybind: ctrl+x m
new
Start a new session. Alias: /clear
/new
Keybind: ctrl+x n
redo
Redo a previously undone message. Only available after using /undo
.
/redo
Keybind: ctrl+x r
sessions
List and switch between sessions. Aliases: /resume
, /continue
/sessions
Keybind: ctrl+x l
share
Share current session. Learn more.
/share
Keybind: ctrl+x s
themes
List available themes.
/themes
Keybind: ctrl+x t
undo
Undo last message in the conversation. Removes the most recent user message, all subsequent responses, and any file changes.
/undo
Keybind: ctrl+x u
unshare
Unshare current session. Learn more.
/unshare
Bash commands
Start a message with !
to run a shell command.
!ls -la
The output of the command is added to the conversation as a tool result.
Editor setup
Both the /editor
and /export
commands use the editor specified in your EDITOR
environment variable.
export EDITOR=nano # or vim, code, etc.
To make it permanent, add this to your shell profile;
~/.bashrc
, ~/.zshrc
, etc.
set EDITOR=notepad # or code, vim, etc.
To make it permanent, use System Properties > Environment Variables.
$env:EDITOR = "notepad" # or "code", "vim", etc.
To make it permanent, add this to your PowerShell profile.
Popular editor options include:
code
- Visual Studio Codevim
- Vim editornano
- Nano editornotepad
- Windows Notepadsubl
- Sublime Text