summaryrefslogtreecommitdiff
path: root/internal/tmuxedit/capture.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/tmuxedit/capture.go')
-rw-r--r--internal/tmuxedit/capture.go17
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
+}