You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
941 B
Bash
29 lines
941 B
Bash
#!/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"
|