diff options
author | Marc Cornellà <marc.cornella@live.com> | 2016-09-02 21:01:31 +0200 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2016-09-02 21:03:49 +0200 |
commit | 7a32a98ced7817c4c4f178cb80c2c39d4957ea59 (patch) | |
tree | aab54f3270357df69920dee9337033c7939e420d /plugins | |
parent | 864887388758b615d15a3f30a461aff1a7711d0b (diff) | |
download | zsh-7a32a98ced7817c4c4f178cb80c2c39d4957ea59.tar.gz zsh-7a32a98ced7817c4c4f178cb80c2c39d4957ea59.tar.bz2 zsh-7a32a98ced7817c4c4f178cb80c2c39d4957ea59.zip |
droplr: convert ruby file into zsh
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/droplr/droplr.plugin.zsh | 16 | ||||
-rwxr-xr-x | plugins/droplr/droplr.rb | 12 |
2 files changed, 15 insertions, 13 deletions
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 |