Split out the copy to clipboard functionality into its own function. It is universally useful.

This commit is contained in:
Simon Gomizelj 2011-11-30 09:24:40 -05:00
commit e733352ff1
2 changed files with 11 additions and 7 deletions

10
lib/clipboard.zsh Normal file
View file

@ -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
}

View file

@ -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
}