| applyTo | adapters/editor/**/*.sh |
|---|
Most editors are defined as registry entries in lib/adapters.sh — no adapter file needed.
Only create an adapter file in adapters/editor/ for editors that need custom behavior beyond what the standard/terminal builders provide (see nano.sh for an example).
Add a line to _EDITOR_REGISTRY in lib/adapters.sh:
yourname|yourcmd|standard|EditorName not found. Install from https://...|flags
Format: name|cmd|type|err_msg|flags
type:standard(GUI app) orterminal(runs in terminal)flags: comma-separated —workspace(supports .code-workspace),background(terminal bg)
Create adapters/editor/<name>.sh implementing:
#!/usr/bin/env bash
# EditorName adapter
editor_can_open() {
command -v editor-cli >/dev/null 2>&1
}
editor_open() {
local path="$1"
if ! editor_can_open; then
log_error "EditorName not found. Install from https://..."
return 1
fi
editor-cli "$path"
}File-based adapters take precedence over registry entries of the same name.
Also update:
- README.md (setup instructions)
- All three completion files:
completions/gtr.bash,completions/_git-gtr,completions/gtr.fish - Help text in
lib/commands/help.sh(cmd_helpfunction)
- Required functions:
editor_can_open(probe viacommand -v),editor_open <path>. - Quote all paths; support spaces. Avoid changing PWD globally—no subshell needed (editor opens path).
- Use
log_errorwith actionable install guidance if command missing. - Keep adapter lean: no project scans, no blocking prompts.
- Naming: file/registry name = tool name (
zed→zedflag). Avoid uppercase. - Update: README editor list, completions (bash/zsh/fish), help (
Available editors:), optional screenshots. - Fallback behavior: if editor absent, fail clearly; do NOT silently defer to file browser.
- Inspect function definition if needed:
declare -f editor_open.