summaryrefslogtreecommitdiff
path: root/tmuxsh/_snippetmulti,--.copy.a.snippet.textblock
diff options
context:
space:
mode:
Diffstat (limited to 'tmuxsh/_snippetmulti,--.copy.a.snippet.textblock')
-rwxr-xr-xtmuxsh/_snippetmulti,--.copy.a.snippet.textblock28
1 files changed, 28 insertions, 0 deletions
diff --git a/tmuxsh/_snippetmulti,--.copy.a.snippet.textblock b/tmuxsh/_snippetmulti,--.copy.a.snippet.textblock
new file mode 100755
index 0000000..7b5525c
--- /dev/null
+++ b/tmuxsh/_snippetmulti,--.copy.a.snippet.textblock
@@ -0,0 +1,28 @@
+#!/usr/bin/env sh
+# AUTHOR: gotbletu (@gmail|twitter|youtube|github|lbry)
+# https://www.youtube.com/user/gotbletu
+# DESC: copy textblock to clipboard
+# DEMO: https://www.youtube.com/watch?v=Zew0mgJwAh8
+
+DIR="$HOME/.config/snippetmulti"
+FZF_ARG() {
+ fzf -e -i --delimiter / --with-nth -1 --preview 'cat {}' --prompt="Copy textblock to clipboard: " --info=hidden --layout=reverse --tiebreak=index
+}
+selected="$(find "$DIR"/ -type f | sort | FZF_ARG)"
+[ -z "$selected" ] && exit
+
+# copy to X11 (linux,bsd)
+xsel -b < "$selected" || xclip -selection clipboard "$selected"
+# copy to Wayland (linux,bsd)
+wl-copy < "$selected"
+# copy to WindowsOS (Vista+)
+clip < "$selected"
+# copy to Cygwin (WindowsOS)
+cat "$selected" > /dev/clipboard
+# copy to MacOS
+pbcopy < "$selected"
+# copy to Termux (Android)
+cat "$selected" | termux-clipboard-set
+# copy to tmux
+tmux load-buffer "$selected"
+tmux display-message "Copied contents to clipboard"