diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-08 11:14:36 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-08 11:14:36 +0200 |
| commit | 5e825543dc55a2c649e68dce6341844ad71fa217 (patch) | |
| tree | f7aae1c1d130f08c383f95a23413bdde7843dc0f /internal/tmuxedit/capture.go | |
| parent | 023ed82e612451caa38ec46106ed9d148ab9a595 (diff) | |
add hexai-tmux-edit: tmux popup editor for AI agent prompts
New tool that opens $EDITOR in a tmux popup for composing longer prompts
when working with AI CLI agents (Claude Code, Cursor, Amp, Aider, etc.).
Captures existing prompt text from the target pane, pre-fills the editor,
and sends edited text back via tmux send-keys. Config-driven agent
detection via regex patterns in [tmux_edit] config section.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tmuxedit/capture.go')
| -rw-r--r-- | internal/tmuxedit/capture.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/internal/tmuxedit/capture.go b/internal/tmuxedit/capture.go new file mode 100644 index 0000000..2af5698 --- /dev/null +++ b/internal/tmuxedit/capture.go @@ -0,0 +1,17 @@ +package tmuxedit + +import ( + "fmt" + "strings" +) + +// capturePane retrieves the visible content of a tmux pane via +// `tmux capture-pane -p -t <paneID>`. The -p flag prints to stdout +// instead of to a paste buffer. +var capturePane = func(paneID string) (string, error) { + out, err := runCommand("tmux", "capture-pane", "-p", "-t", paneID) + if err != nil { + return "", fmt.Errorf("capture-pane failed for %s: %w", paneID, err) + } + return strings.TrimRight(string(out), "\n"), nil +} |
