Skip to content

Commit

Permalink
feat(clip): support pbcopy && xsel && wl-copy
Browse files Browse the repository at this point in the history
  • Loading branch information
sainnhe committed Apr 16, 2024
1 parent 8e7fbf5 commit b26574d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/pb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ _verbose() {
}

_clip() {
echo "$@" | xclip -selection clipboard
if [ -x "$(command -v pbcopy)" ]; then
echo "$@" | pbcopy
elif [ -x "$(command -v xclip)" ]; then
echo "$@" | xclip -selection clipboard
elif [ -x "$(command -v xsel)" ]; then
echo "$@" | xsel -b
elif [ -x "$(command -v wl-copy)" ]; then
echo "$@" | wl-copy
else
_verbose "Cannot find a clipboard tool. Requires one of 'pbcopy' (macOS), 'xclip' (xorg), 'xsel' (xorg) or 'wl-copy' (wayland)."
return
fi
_verbose "'$*' is copied to your clipboard"
}

Expand Down

0 comments on commit b26574d

Please sign in to comment.