tui.mdx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. ---
  2. title: TUI
  3. description: Using the opencode terminal user interface.
  4. ---
  5. import { Tabs, TabItem } from "@astrojs/starlight/components"
  6. opencode provides an interactive terminal interface or TUI for working on your projects with an LLM.
  7. Running opencode starts the TUI for the current directory.
  8. ```bash
  9. opencode
  10. ```
  11. Or you can start it for a specific working directory.
  12. ```bash
  13. opencode /path/to/project
  14. ```
  15. Once you're in the TUI, you can prompt it with a message.
  16. ```text
  17. Give me a quick summary of the codebase.
  18. ```
  19. :::tip
  20. You can also use `@` to reference files in your messages.
  21. :::
  22. ```text "@packages/functions/src/api/index.ts"
  23. How is auth handled in @packages/functions/src/api/index.ts?
  24. ```
  25. ---
  26. ## Commands
  27. When using the opencode TUI, you can type `/` followed by a command name to quickly execute actions. For example:
  28. ```bash frame="none"
  29. /help
  30. ```
  31. Most commands also have keybind using `ctrl+x` as the leader key, where `ctrl+x` is the default leader key. [Learn more](/docs/keybinds).
  32. Here are all available slash commands:
  33. ---
  34. ### compact
  35. Compact the current session. _Alias_: `/summarize`
  36. ```bash frame="none"
  37. /compact
  38. ```
  39. **Keybind:** `ctrl+x c`
  40. ---
  41. ### details
  42. Toggle tool execution details.
  43. ```bash frame="none"
  44. /details
  45. ```
  46. **Keybind:** `ctrl+x d`
  47. ---
  48. ### editor
  49. Open external editor for composing messages. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
  50. ```bash frame="none"
  51. /editor
  52. ```
  53. **Keybind:** `ctrl+x e`
  54. ---
  55. ### exit
  56. Exit opencode. _Aliases_: `/quit`, `/q`
  57. ```bash frame="none"
  58. /exit
  59. ```
  60. **Keybind:** `ctrl+x q`
  61. ---
  62. ### export
  63. Export current conversation to Markdown and open in your default editor. Uses the editor set in your `EDITOR` environment variable. [Learn more](#editor-setup).
  64. ```bash frame="none"
  65. /export
  66. ```
  67. **Keybind:** `ctrl+x x`
  68. ---
  69. ### help
  70. Show the help dialog.
  71. ```bash frame="none"
  72. /help
  73. ```
  74. **Keybind:** `ctrl+x h`
  75. ---
  76. ### init
  77. Create or update `AGENTS.md` file. [Learn more](/docs/rules).
  78. ```bash frame="none"
  79. /init
  80. ```
  81. **Keybind:** `ctrl+x i`
  82. ---
  83. ### models
  84. List available models.
  85. ```bash frame="none"
  86. /models
  87. ```
  88. **Keybind:** `ctrl+x m`
  89. ---
  90. ### new
  91. Start a new session. _Alias_: `/clear`
  92. ```bash frame="none"
  93. /new
  94. ```
  95. **Keybind:** `ctrl+x n`
  96. ---
  97. ### redo
  98. Redo a previously undone message. Only available after using `/undo`.
  99. :::tip
  100. Any file changes will also be restored.
  101. :::
  102. ```bash frame="none"
  103. /redo
  104. ```
  105. **Keybind:** `ctrl+x r`
  106. ---
  107. ### sessions
  108. List and switch between sessions. _Aliases_: `/resume`, `/continue`
  109. ```bash frame="none"
  110. /sessions
  111. ```
  112. **Keybind:** `ctrl+x l`
  113. ---
  114. ### share
  115. Share current session. [Learn more](/docs/share).
  116. ```bash frame="none"
  117. /share
  118. ```
  119. **Keybind:** `ctrl+x s`
  120. ---
  121. ### themes
  122. List available themes.
  123. ```bash frame="none"
  124. /themes
  125. ```
  126. **Keybind:** `ctrl+x t`
  127. ---
  128. ### undo
  129. Undo last message in the conversation. Removes the most recent user message, all subsequent responses, and any file changes.
  130. :::tip
  131. Any file changes made will also be reverted.
  132. :::
  133. ```bash frame="none"
  134. /undo
  135. ```
  136. **Keybind:** `ctrl+x u`
  137. ---
  138. ### unshare
  139. Unshare current session. [Learn more](/docs/share#un-sharing).
  140. ```bash frame="none"
  141. /unshare
  142. ```
  143. ---
  144. ## Bash commands
  145. Start a message with `!` to run a shell command.
  146. ```bash frame="none"
  147. !ls -la
  148. ```
  149. The output of the command is added to the conversation as a tool result.
  150. ---
  151. ## Editor setup
  152. Both the `/editor` and `/export` commands use the editor specified in your `EDITOR` environment variable.
  153. <Tabs>
  154. <TabItem label="Linux/macOS">
  155. ```bash
  156. export EDITOR=nano # or vim, code, etc.
  157. ```
  158. To make it permanent, add this to your shell profile;
  159. `~/.bashrc`, `~/.zshrc`, etc.
  160. </TabItem>
  161. <TabItem label="Windows (CMD)">
  162. ```bash
  163. set EDITOR=notepad # or code, vim, etc.
  164. ```
  165. To make it permanent, use **System Properties** > **Environment
  166. Variables**.
  167. </TabItem>
  168. <TabItem label="Windows (PowerShell)">
  169. ```bash
  170. $env:EDITOR = "notepad" # or "code", "vim", etc.
  171. ```
  172. To make it permanent, add this to your PowerShell
  173. profile.
  174. </TabItem>
  175. </Tabs>
  176. Popular editor options include:
  177. - `code` - Visual Studio Code
  178. - `vim` - Vim editor
  179. - `nano` - Nano editor
  180. - `notepad` - Windows Notepad
  181. - `subl` - Sublime Text