summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-08 11:14:36 +0200
committerPaul Buetow <paul@buetow.org>2026-02-08 11:14:36 +0200
commit5e825543dc55a2c649e68dce6341844ad71fa217 (patch)
treef7aae1c1d130f08c383f95a23413bdde7843dc0f /cmd
parent023ed82e612451caa38ec46106ed9d148ab9a595 (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 'cmd')
-rw-r--r--cmd/hexai-tmux-edit/main.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/cmd/hexai-tmux-edit/main.go b/cmd/hexai-tmux-edit/main.go
new file mode 100644
index 0000000..928a2cd
--- /dev/null
+++ b/cmd/hexai-tmux-edit/main.go
@@ -0,0 +1,48 @@
+// hexai-tmux-edit opens a tmux popup with $EDITOR for composing AI agent
+// prompts. It captures existing prompt text from the target pane, pre-fills
+// the editor, and sends the edited text back via tmux send-keys.
+//
+// Usage:
+//
+// hexai-tmux-edit [--config <path>] [--agent <name>] [--pane <id>]
+//
+// Tmux keybinding (add to ~/.tmux.conf):
+//
+// bind e run-shell -b "hexai-tmux-edit --pane '#{pane_id}'"
+package main
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "strings"
+
+ "codeberg.org/snonux/hexai/internal/appconfig"
+ "codeberg.org/snonux/hexai/internal/tmuxedit"
+)
+
+func main() {
+ defaultPath := defaultConfigPath()
+ configPath := flag.String("config", "", fmt.Sprintf("path to config file (default: %s)", defaultPath))
+ agent := flag.String("agent", "", "AI agent name (auto-detected if omitted)")
+ pane := flag.String("pane", "", "tmux target pane ID (e.g. %%5)")
+ flag.Parse()
+
+ opts := tmuxedit.Options{
+ ConfigPath: strings.TrimSpace(*configPath),
+ Agent: strings.TrimSpace(*agent),
+ Pane: strings.TrimSpace(*pane),
+ }
+ if err := tmuxedit.Run(opts); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ os.Exit(1)
+ }
+}
+
+func defaultConfigPath() string {
+ path, err := appconfig.ConfigPath()
+ if err != nil {
+ return "$XDG_CONFIG_HOME/hexai/config.toml"
+ }
+ return path
+}