From e733352ff1002bd9febd3ff688d73982f87338b1 Mon Sep 17 00:00:00 2001 From: Simon Gomizelj Date: Wed, 30 Nov 2011 09:24:40 -0500 Subject: [PATCH] Split out the copy to clipboard functionality into its own function. It is universally useful. --- lib/clipboard.zsh | 10 ++++++++++ plugins/sprunge/sprunge.plugin.zsh | 8 +------- 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 lib/clipboard.zsh 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 }