diff options
| author | Paul Buetow <paul@buetow.org> | 2026-04-25 08:49:02 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-04-25 08:49:02 +0300 |
| commit | e33cd60277bc717ad7a8c73cf01c7bedad0d1837 (patch) | |
| tree | cf3e72b6e16223a207883c7049ae200ac57aee2d /internal/tmux | |
| parent | caa7876ac8bdb5cc23e12db4d4cb65cf86861151 (diff) | |
Release v0.35.0: fix-typos action and tmux popup for hexai-tmux-actionv0.35.0
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/tmux')
| -rw-r--r-- | internal/tmux/tmux.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/internal/tmux/tmux.go b/internal/tmux/tmux.go index 6d75a44..9a4f5ee 100644 --- a/internal/tmux/tmux.go +++ b/internal/tmux/tmux.go @@ -53,6 +53,38 @@ func SplitRun(opts SplitOpts, argv []string) error { return c.Run() } +// PopupOpts controls how a tmux display-popup is created for running a command. +type PopupOpts struct { + Target string // optional pane target, e.g. ":." + Width string // popup width, e.g. "80%" or "120"; empty means tmux default + Height string // popup height, e.g. "80%" or "40"; empty means tmux default +} + +// PopupRun opens a tmux display-popup and runs argv inside it. +// The -E flag makes the popup close automatically when the command exits. +// It returns once the popup has closed (blocking call). +func PopupRun(opts PopupOpts, argv []string) error { + if len(argv) == 0 { + return nil + } + args := []string{"display-popup", "-E"} + if cwd, err := os.Getwd(); err == nil && cwd != "" { + args = append(args, "-d", cwd) + } + if strings.TrimSpace(opts.Target) != "" { + args = append(args, "-t", opts.Target) + } + if strings.TrimSpace(opts.Width) != "" { + args = append(args, "-w", strings.TrimSpace(opts.Width)) + } + if strings.TrimSpace(opts.Height) != "" { + args = append(args, "-h", strings.TrimSpace(opts.Height)) + } + cmdStr := shellJoin(argv) + args = append(args, cmdStr) + return command("tmux", args...).Run() +} + // shellJoin quotes argv elements for safe use in a single shell command string. // It avoids interpretation by wrapping in single quotes and escaping embedded single quotes. func shellJoin(argv []string) string { |
