1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
}
|