From 774a991d6a979afe2739abfdedfb597a51be6c7e Mon Sep 17 00:00:00 2001 From: Ali Ismayilov Date: Wed, 23 Jul 2014 12:18:03 -0300 Subject: [PATCH] Play well with OSX and Linux clipboard servers --- plugins/uplio/uplio.plugin.zsh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/uplio/uplio.plugin.zsh b/plugins/uplio/uplio.plugin.zsh index 46438850..2f76a82e 100644 --- a/plugins/uplio/uplio.plugin.zsh +++ b/plugins/uplio/uplio.plugin.zsh @@ -1,13 +1,18 @@ # Copied from https://gist.github.com/henrique2010/4a474e036f2f1a7de96f by @henrique2010 # This command receives a file as param, upload it to upl.io and copy the url to the clipboard # -# install: copy this code to your .bashrc or .zshrc -# dependencies: curl and xclip +# dependencies: curl and (xclip or pbcopy) # example: $ upload ~/Images/image.png uplio() { echo 'Uploading...' url=`curl http://upl.io -F file=@$1 -s` - echo -n $url | pbcopy + if command -v pbcopy >/dev/null; then + echo -n $url | pbcopy + elif command -v xclip >/dev/null; then + echo -n $url | xclip -sel clip + else + echo 'You need either pbcopy or xclip to copy the url to clipboard' + fi echo $url }