From f81bce195c7c6a319020e602ffd06f55b4ed71c2 Mon Sep 17 00:00:00 2001 From: Sainnhe Park Date: Tue, 16 Apr 2024 19:16:40 +0800 Subject: [PATCH] feat(clip): support pbcopy && xsel && wl-copy --- scripts/pb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/pb b/scripts/pb index 9a5a20c..4d21ec6 100755 --- a/scripts/pb +++ b/scripts/pb @@ -26,7 +26,17 @@ _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)." + fi _verbose "'$*' is copied to your clipboard" }