Skip to content

Commit a257dd9

Browse files
sainnheSharzyL
authored andcommitted
feat(clip): support pbcopy && xsel && wl-copy
1 parent 8e7fbf5 commit a257dd9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

scripts/pb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@ _verbose() {
2626
}
2727

2828
_clip() {
29-
echo "$@" | xclip -selection clipboard
29+
if [ -x "$(command -v pbcopy)" ]; then
30+
echo "$@" | pbcopy
31+
elif [ -x "$(command -v xclip)" ]; then
32+
echo "$@" | xclip -selection clipboard
33+
elif [ -x "$(command -v xsel)" ]; then
34+
echo "$@" | xsel -b
35+
elif [ -x "$(command -v wl-copy)" ]; then
36+
echo "$@" | wl-copy
37+
else
38+
_verbose "Cannot find a clipboard tool. Requires one of 'pbcopy' (macOS), 'xclip' (xorg), 'xsel' (xorg) or 'wl-copy' (wayland)."
39+
return
40+
fi
3041
_verbose "'$*' is copied to your clipboard"
3142
}
3243

0 commit comments

Comments
 (0)