Browse Source

droplr: convert ruby file into zsh

Marc Cornellà 8 years ago
parent
commit
7a32a98ced
2 changed files with 15 additions and 13 deletions
  1. 15 1
      plugins/droplr/droplr.plugin.zsh
  2. 0 12
      plugins/droplr/droplr.rb

+ 15 - 1
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
+}

+ 0 - 12
plugins/droplr/droplr.rb

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