From 7a32a98ced7817c4c4f178cb80c2c39d4957ea59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 2 Sep 2016 21:01:31 +0200 Subject: [PATCH] droplr: convert ruby file into zsh --- plugins/droplr/droplr.plugin.zsh | 16 +++++++++++++++- plugins/droplr/droplr.rb | 12 ------------ 2 files changed, 15 insertions(+), 13 deletions(-) delete mode 100755 plugins/droplr/droplr.rb diff --git a/plugins/droplr/droplr.plugin.zsh b/plugins/droplr/droplr.plugin.zsh index 2a2ec227c..296a8b98b 100644 --- a/plugins/droplr/droplr.plugin.zsh +++ b/plugins/droplr/droplr.plugin.zsh @@ -1 +1,15 @@ -alias droplr=$ZSH/plugins/droplr/droplr.rb +# Only compatible with MacOS +[[ "$OSTYPE" == darwin* ]] || return + +droplr() { + if [[ $# -eq 0 ]]; then + echo You need to specify a parameter. >&2 + return 1 + fi + + if [[ "$1" =~ ^http[|s]:// ]]; then + osascript -e "tell app 'Droplr' to shorten '$1'" + else + open -ga /Applications/Droplr.app "$1" + fi +} diff --git a/plugins/droplr/droplr.rb b/plugins/droplr/droplr.rb deleted file mode 100755 index 00300198e..000000000 --- a/plugins/droplr/droplr.rb +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env ruby - -if ARGV[0].nil? - puts "You need to specify a parameter." - exit!(1) -end - -if ARGV[0][%r{^http[|s]://}i] - `osascript -e 'tell app "Droplr" to shorten "#{ARGV[0]}"'` -else - `open -ga /Applications/Droplr.app "#{ARGV[0]}"` -end