summaryrefslogtreecommitdiff
path: root/tmuxsh/_bluepill,--.copy.a.codeblock
blob: 70ec1fc596df4d1abf422ab6eb925810dab5b598 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env sh
selected="$(find ~/.config/bluepill/ -type f | sort | fzf -e -i --delimiter / --with-nth -1 --preview 'cat {}' --prompt="Copy a codeblock to clipboard: " --info=default --layout=reverse --tiebreak=index)"
[ -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 codeblock to clipboard"