2 changed files with 67 additions and 0 deletions
@ -0,0 +1,66 @@ |
|||||||
|
# OpenCode Cheat Sheet & Setup Notes |
||||||
|
|
||||||
|
## Environment & Config Paths |
||||||
|
|
||||||
|
- **Terminal / OS:** Alacritty on macOS |
||||||
|
- **Shell environment:** `~/.zshrc` (`GEMINI_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY`, `OPENROUTER_API_KEY`, `GROQ_API_KEY`) |
||||||
|
- **Global config:** `~/.config/opencode/opencode.json` |
||||||
|
- **Global rules:** `~/.config/opencode/AGENTS.md` |
||||||
|
- **Logs:** `~/.local/share/opencode/log/` |
||||||
|
|
||||||
|
## TUI Keyboard Shortcuts |
||||||
|
|
||||||
|
- **Leader key:** `Ctrl+X` (press and release, then press the next key within 2 seconds) |
||||||
|
|
||||||
|
| Action | Shortcut | Notes | |
||||||
|
| :--------------------------- | :------------------------------------ | :---------------------------------------------- | |
||||||
|
| Cycle agents | `Tab` / `Shift+Tab` | Switch between primary agents (`Plan`, `Build`) | |
||||||
|
| Cycle recent models | `F2` / `Shift+F2` | Switch models mid-thread without losing context | |
||||||
|
| Open model picker | `Ctrl+X` then `M` | Browse available models across providers | |
||||||
|
| Cycle model variant / effort | `Ctrl+T` | Adjust reasoning/thinking effort when supported | |
||||||
|
| Command palette | `Ctrl+P` | Searchable list of TUI actions and commands | |
||||||
|
| New session | `Ctrl+X` then `N` | Start a new conversation thread | |
||||||
|
| List / switch sessions | `Ctrl+X` then `L` | Browse or resume prior sessions | |
||||||
|
| Compact session | `Ctrl+X` then `C` | Summarize context to save tokens | |
||||||
|
| Undo / Redo message | `Ctrl+X` then `U` / `Ctrl+X` then `R` | Step back or forward after edits | |
||||||
|
| Copy last message | `Ctrl+X` then `Y` | Copy output to clipboard | |
||||||
|
| Interrupt / cancel turn | `Esc` | Stop an in-flight response or shell input | |
||||||
|
| New line in prompt | `Shift+Enter` or `Ctrl+J` | Insert a line break without submitting | |
||||||
|
| Exit OpenCode | `Ctrl+X` then `Q` (or `Ctrl+C`) | Quit the TUI cleanly | |
||||||
|
|
||||||
|
## Prompt Prefixes & Slash Commands |
||||||
|
|
||||||
|
- `@path/to/file` — attach a file into prompt context |
||||||
|
- `!command` — run a shell command directly (e.g., `!magick -version`) and include its output |
||||||
|
- `/init` — generate or update a project-level `AGENTS.md` |
||||||
|
- `/models` — open the model selector |
||||||
|
- `/compact` (or `/summarize`) — compress older session context |
||||||
|
- `/undo` — revert the last message/turn |
||||||
|
- `/sessions` — list and switch sessions |
||||||
|
- `/connect` — configure provider credentials |
||||||
|
- `/details` — toggle tool output details |
||||||
|
- `/export` — export session transcript to Markdown |
||||||
|
- `/help` — display built-in help |
||||||
|
- `/exit` (aliases: `/quit`, `/q`) — exit OpenCode |
||||||
|
|
||||||
|
## CLI Commands & Flags |
||||||
|
|
||||||
|
```bash |
||||||
|
# Launch interactive TUI |
||||||
|
opencode |
||||||
|
opencode /path/to/project |
||||||
|
|
||||||
|
# Run a single non-interactive prompt |
||||||
|
opencode run "your prompt" |
||||||
|
opencode run -m provider/model "your prompt" |
||||||
|
|
||||||
|
# Inspect models and authentication |
||||||
|
opencode models [provider] |
||||||
|
opencode models --refresh |
||||||
|
opencode auth list |
||||||
|
opencode auth login |
||||||
|
|
||||||
|
# Reload shell environment after editing ~/.zshrc |
||||||
|
source ~/.zshrc |
||||||
|
|
||||||
|
``` |
||||||
Loading…
Reference in new issue