aboutsummaryrefslogtreecommitdiff
path: root/tmuxrdr/plugin/bin/paste-buffer
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-10-05 11:27:00 +0300
committerIgor Soarez <igor@soarez.org>2026-10-05 11:27:00 +0300
commit986e760687a2d34051934d410bec71fa2efc349b (patch)
treef57dcc4ba0d7690fdf90eeb2f0970a8ebbefc45a /tmuxrdr/plugin/bin/paste-buffer
parent7b116c05bfda646af39d2524c54e70c751f57ee8 (diff)
tmuxrdr: tmux-mode plugin
The tmux default prefix bindings herdr has no built-in action for, as a herdr plugin built on its CLI and socket: break-pane, swap-pane and rotate-window by pane order (focus behaviour measured on tmux 3.7c), mark/clear-mark, last-window and switch-client -l (from focus events, per session), select-window and move-window by index, paste-buffer -p, display-message in tmux's default format, select-layout -E, kill-pane and kill-window behind tmux's y/n prompts, a command prompt taking tmux's commands, clock-mode, show-messages, and automatic-rename. Also a .gitignore for secrets scoped to tmuxrdr/, leaving herdr's own untouched.
Diffstat (limited to 'tmuxrdr/plugin/bin/paste-buffer')
-rwxr-xr-xtmuxrdr/plugin/bin/paste-buffer20
1 files changed, 20 insertions, 0 deletions
diff --git a/tmuxrdr/plugin/bin/paste-buffer b/tmuxrdr/plugin/bin/paste-buffer
new file mode 100755
index 00000000..c5c16844
--- /dev/null
+++ b/tmuxrdr/plugin/bin/paste-buffer
@@ -0,0 +1,20 @@
+#!/bin/sh
+# tmux prefix+] (paste-buffer -p): paste the most recent copy into the current
+# pane. Herdr copies to the system clipboard, so that is the buffer. -p means
+# bracketed paste when the application asked for it, and that is what herdr's
+# send-text already does (src/app/api_helpers.rs: encode_api_text).
+. "$(dirname "$0")/../lib.sh"
+
+if command -v pbpaste >/dev/null 2>&1; then
+ buf="$(pbpaste; printf x)"
+elif command -v wl-paste >/dev/null 2>&1; then
+ buf="$(wl-paste --no-newline; printf x)"
+elif command -v xclip >/dev/null 2>&1; then
+ buf="$(xclip -o -selection clipboard; printf x)"
+else
+ fail "no buffers"
+fi
+# The x keeps trailing newlines that $(...) would strip; tmux pastes verbatim.
+buf="${buf%x}"
+[ -n "$buf" ] || fail "no buffers"
+"$H" pane send-text "$(active_pane)" "$buf" >/dev/null