diff --git a/lib/clipboard.zsh b/lib/clipboard.zsh new file mode 100644 index 000000000..7e86814ea --- /dev/null +++ b/lib/clipboard.zsh @@ -0,0 +1,10 @@ +# function to send text to primary and secondary clipboards +sendtoclip() { + if (( $+commands[xclip] )); then + echo -n $@ | xclip -sel primary + echo -n $@ | xclip -sel clipboard + elif (( $+commands[xsel] )); then + echo -n $@ | xsel -ip # primary + echo -n $@ | xsel -ib # clipboard + fi +} diff --git a/plugins/sprunge/sprunge.plugin.zsh b/plugins/sprunge/sprunge.plugin.zsh index d080ff4c7..f1bf38785 100644 --- a/plugins/sprunge/sprunge.plugin.zsh +++ b/plugins/sprunge/sprunge.plugin.zsh @@ -67,11 +67,5 @@ sprunge() { [[ ! -t 1 ]] && return 0 # copy urls to primary and secondary clipboards - if (( $+commands[xclip] )); then - echo -n $urls | xclip -sel primary - echo -n $urls | xclip -sel clipboard - elif (( $+commands[xsel] )); then - echo -n $urls | xsel -ip # primary - echo -n $urls | xsel -ib # clipboard - fi + sendtoclip $urls }