From 1af4e9c521d82068871956dc4cf172a262827520 Mon Sep 17 00:00:00 2001 From: Fabio Fernandes Date: Sat, 13 Jul 2013 05:27:37 -0300 Subject: [PATCH 1/3] Add Droplr plugin --- plugins/droplr/droplr.plugin.zsh | 3 +++ plugins/droplr/droplr.rb | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 plugins/droplr/droplr.plugin.zsh create mode 100755 plugins/droplr/droplr.rb diff --git a/plugins/droplr/droplr.plugin.zsh b/plugins/droplr/droplr.plugin.zsh new file mode 100644 index 000000000..a20ca9368 --- /dev/null +++ b/plugins/droplr/droplr.plugin.zsh @@ -0,0 +1,3 @@ +#!/bin/zsh + +alias droplr=$ZSH/plugins/droplr/droplr.rb \ No newline at end of file diff --git a/plugins/droplr/droplr.rb b/plugins/droplr/droplr.rb new file mode 100755 index 000000000..38751dfcb --- /dev/null +++ b/plugins/droplr/droplr.rb @@ -0,0 +1,25 @@ +#!/usr/bin/env ruby +# +# droplr +# Fabio Fernandes | http://fabiofl.me +# +# Use Droplr from the comand line to upload files and shorten links. +# +# Examples: +# +# droplr ./path/to/file/ +# droplr http://example.com +# +# This needs Droplr.app to be installed and loged in. +# Also, Mac only. + +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 \ No newline at end of file From 864887388758b615d15a3f30a461aff1a7711d0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Fri, 2 Sep 2016 20:25:28 +0200 Subject: [PATCH 2/3] Add Droplr README --- plugins/droplr/README.md | 19 +++++++++++++++++++ plugins/droplr/droplr.plugin.zsh | 4 +--- plugins/droplr/droplr.rb | 15 +-------------- 3 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 plugins/droplr/README.md diff --git a/plugins/droplr/README.md b/plugins/droplr/README.md new file mode 100644 index 000000000..cfbec25ed --- /dev/null +++ b/plugins/droplr/README.md @@ -0,0 +1,19 @@ +# droplr + +Use [Droplr](https://droplr.com/) from the comand line to upload files and shorten +links. It needs to have [Droplr.app](https://droplr.com/apps) installed and logged +in. MacOS only. + +To use it, add `droplr` to the `$plugins` variable in your zshrc file: + +```zsh +plugins=(... droplr) +``` + +Author: [Fabio Fernandes](https://github.com/fabiofl) + +## Examples + +- Upload a file: `droplr ./path/to/file/` + +- Shorten a link: `droplr http://example.com` diff --git a/plugins/droplr/droplr.plugin.zsh b/plugins/droplr/droplr.plugin.zsh index a20ca9368..2a2ec227c 100644 --- a/plugins/droplr/droplr.plugin.zsh +++ b/plugins/droplr/droplr.plugin.zsh @@ -1,3 +1 @@ -#!/bin/zsh - -alias droplr=$ZSH/plugins/droplr/droplr.rb \ No newline at end of file +alias droplr=$ZSH/plugins/droplr/droplr.rb diff --git a/plugins/droplr/droplr.rb b/plugins/droplr/droplr.rb index 38751dfcb..00300198e 100755 --- a/plugins/droplr/droplr.rb +++ b/plugins/droplr/droplr.rb @@ -1,17 +1,4 @@ #!/usr/bin/env ruby -# -# droplr -# Fabio Fernandes | http://fabiofl.me -# -# Use Droplr from the comand line to upload files and shorten links. -# -# Examples: -# -# droplr ./path/to/file/ -# droplr http://example.com -# -# This needs Droplr.app to be installed and loged in. -# Also, Mac only. if ARGV[0].nil? puts "You need to specify a parameter." @@ -22,4 +9,4 @@ 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 \ No newline at end of file +end 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 3/3] 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