Skip to content

Instantly share code, notes, and snippets.

@sairam
Forked from anonymous/file1.ab
Created December 19, 2010 17:27
Show Gist options
  • Save sairam/747501 to your computer and use it in GitHub Desktop.
Save sairam/747501 to your computer and use it in GitHub Desktop.
#
# Copyright (c) 2010 Sairam Kunala
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# README :
# This program requires Dropbox, growlnotify and wget to be installed and is configured
# to be working on a Mac OS X . Also requires a bit.ly login and API key to shorten URL
#
#
# You need to set your bitly login and API Key
bitlyLogin="bitlyapidemo"
bitlyApiKey="R_0da49e0a9118ff35f52f629d2d71bf07" # http://bit.ly/a/account
userId="0000000" # you need to change this
path="/misc" # You can set path as empty "" if you want it in your Public directory
filepath="/`echo $1| cut -f2- -d:|sed -e 's@:@/@g'`"
if [ -d "$filepath" ]
then
filename="`echo $filepath|rev|cut -f2 -d'/'|rev`.tgz"
/usr/bin/tar -cvzf "/tmp/$filename" "$filepath"
mv "/tmp/$filename" ~/Dropbox/Public$path
else
filename=`echo $filepath|rev|cut -f1 -d'/'|rev`
cp "$filepath" ~/Dropbox/Public$path
fi
shortUrl=`/usr/local/bin/wget -O - "http://api.bit.ly/v3/shorten?login=$bitlyLogin&apiKey=$bitlyApiKey&format=txt&longUrl=http://dl.dropbox.com/u/$userId$path/$filename" 2>/dev/null`
echo $shortUrl
/usr/local/bin/growlnotify -a Dropbox.app -t "Copied to Dropbox" -m "Dropbox URL shortened and copied to Clipboard : $shortUrl" > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment