How to use Twitter from the command line

Aug 23, 2010 - 5 Comments

Twitter-iconOften overlooked, the terminal can be used to accomplish all sorts of fun stuff. Something that you may find handy, is the ability to Tweet using built in Mac OS X command line utilities. Now of course this is not a full featured Twitter client by any means, but if you are looking for potential geek “cred” this is a fun trick to demonstrate.

Copy and paste the entire text in the grey boxes. When you paste it in your Terminal.app, it will show up as one single line.

To display a list of tweets (replace osxdaily with a twitter username of your choice):
curl -s http://twitter.com/osxdaily | grep '' | cut -d">" -f2 | cut -d"<" -f1

To update your twitter status:
curl -u your_user:your_password -d status='This is My update' https://twitter.com/statuses/update.xml

That's it! Imagine all of the fun automation possibilities !

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: chrisk in Command Line, Tips & Tricks

5 Comments

» Comments RSS Feed

  1. Murphy says:

    I used something similar to “schedule” a tweet.

    http://murphymac.com/twitter-while-you-sleep/

    That tip on listing the tweets would be great with geektool.

  2. Russell says:

    Nice tip,
    But perhaps a little late. This relies on twitter’s basic auth (plain text username + password), which is being switched off on August 31st.

    Their preferred authorisation method is oAuth, which will be a lot more tricky to use from the command line :)

  3. Mike says:

    To overcome the oAuth issue and to keep continuing twitter from the command line, have a look at ttytter (perl script).
    This runs on any platform that supports Perl ;-)

  4. Den says:

    The first one is not working. Whats the shame

  5. Wasim says:

    I also had problems after Twitter switched over to oAuth. I found this to be a good solution:

    http://github.com/marcel/twurl/

    This is like curl, but made specifically for twitter, plus it uses oAuth!

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates