You are not logged in.

#1 2009-02-17 13:16:57

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

tinify - a tiny script to make urls tiny

I wrote a small script to make urls tiny quickly. dependencies are curl and xclip (for convenience)
there are two possible ways to use this:
1. copy an url to the X clipboard, run the script (e.g. through a hotkey) and immediately paste the tinyurl again. smile
2. pass an URL as the first and only argument and tadaa, there is the tinified url on STDOUT (and also in the clipboard)

#!/bin/sh
#
# title: tinify
# author: Philip Stark
# desc:  pass an url as the first and only argument to make it tiny or 
#        leave it away and it takes the content of the clipboard by
#        calling xclip. 
# licenced under the WTFPL (http://sam.zoy.org/wtfpl/)
 
if [ "$1" = "" ]; then
  tinyurl=$(curl http://tinyurl.com/api-create.php?url=$(xclip -selection clipboard -o) 2> /dev/null)
  echo $tinyurl;
  echo $tinyurl | xclip -selection clipboard -i;
else
  url=$1;
  tinyurl=$(curl http://tinyurl.com/api-create.php?url=${url} 2> /dev/null)
  echo $tinyurl;
  echo $tinyurl | xclip -selection clipboard -i;
fi

version without xclip dependency (to keep it simple wink ):

#!/bin/sh
# title: tinify
# author: Philip Stark
# desc:  pass an url as the first and only argument to make it tiny or 
#        leave it away and it takes the content of the clipboard by
#        calling xclip. 
# licenced under the WTFPL (http://sam.zoy.org/wtfpl/)
[ "$1" == "" ] && echo "Usage: tinify url" && exit
url=$1;
tinyurl=$(curl http://tinyurl.com/api-create.php?url=${url} 2> /dev/null)
echo $tinyurl;

have fun
cheers Barde

Last edited by Heller_Barde (2009-02-17 18:50:05)

Offline

#2 2009-02-17 13:37:36

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: tinify - a tiny script to make urls tiny

Handy! I just might have to use this smile

Offline

#3 2009-02-17 15:03:37

Runiq
Member
From: Germany
Registered: 2008-10-29
Posts: 1,053

Re: tinify - a tiny script to make urls tiny

You may want to post this here for increased fame. wink

That being said, I'll be using it too.

Offline

#4 2009-02-17 16:09:43

scj
Member
From: Sweden
Registered: 2007-09-23
Posts: 158

Re: tinify - a tiny script to make urls tiny

What is the point of licensing small helper scripts like this? de minimis non curat lex and all that.

Offline

#5 2009-02-17 16:32:53

dolby
Member
From: 1992
Registered: 2006-08-08
Posts: 1,581

Re: tinify - a tiny script to make urls tiny

Does the size of the script matter? Its still someones work.


There shouldn't be any reason to learn more editor types than emacs or vi -- mg (1)
[You learn that sarcasm does not often work well in international forums.  That is why we avoid it. -- ewaller (arch linux forum moderator)

Offline

#6 2009-02-17 16:42:46

scj
Member
From: Sweden
Registered: 2007-09-23
Posts: 158

Re: tinify - a tiny script to make urls tiny

dolby wrote:

Does the size of the script matter? Its still someones work.

Are you kidding?

Offline

#7 2009-02-17 18:34:53

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: tinify - a tiny script to make urls tiny

i was actually kinda kidding about the licensing. it was very late and i was very tired smile so I decided i wanted to do a little bit of effort and make a real description and a license. it was even funnier considering the tinyness of the script

cheers Barde

Last edited by Heller_Barde (2009-02-17 18:35:14)

Offline

#8 2009-02-17 18:44:24

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: tinify - a tiny script to make urls tiny

I have to agree that I thought slapping a license on a few simple lines of code was quite disturbing, however useful the code might be... until I read the license and laughed. smile

The copyright line though...


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#9 2009-02-17 18:46:20

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: tinify - a tiny script to make urls tiny

Nice script thanks for sharing wink


Mr Green

Offline

#10 2009-02-17 18:49:45

Heller_Barde
Member
Registered: 2008-04-01
Posts: 245

Re: tinify - a tiny script to make urls tiny

Xyne wrote:

The copyright line though...

true, now that i am not tired anymore, it makes no sense anymore  big_smile brb, gotta steal a line from my own script

Offline

Board footer

Powered by FluxBB