theniceboy/tmux/scripts/copy_to_clipboard.sh
David Chen 1a8e4cf560 tmux: clipboard integration
- copy-mode-vi: map  to copy-pipe-and-cancel -> ~/.config/tmux/scripts/copy_to_clipboard.sh
- add C-S-v and M-V to paste from system clipboard (works over SSH)
- add scripts: paste_from_clipboard.sh, copy_to_clipboard.sh

Only staged clipboard-related changes; other edits remain unstaged.
2025-09-23 16:41:23 -07:00

22 lines
787 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
content=$(cat | tr -d '\r')
# Update tmux buffer and system clipboard (uses tmux set-clipboard setting)
tmux set-buffer -w -- "$content"
# Best-effort: also call platform clip utilities when available
if command -v pbcopy >/dev/null 2>&1; then
printf '%s' "$content" | pbcopy || true
elif command -v wl-copy >/dev/null 2>&1; then
printf '%s' "$content" | wl-copy --type text || wl-copy || true
elif command -v xclip >/dev/null 2>&1; then
printf '%s' "$content" | xclip -selection clipboard || true
elif command -v xsel >/dev/null 2>&1; then
printf '%s' "$content" | xsel --clipboard --input || true
elif command -v powershell.exe >/dev/null 2>&1; then
powershell.exe -NoProfile -Command Set-Clipboard -Value @"
${content}
"@ || true
fi