How to Use Twitter from the Command Line
Often 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 like curl. Yes, curl! 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.
Show a List of Tweets from Any Twitter User with curl
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
Post an Update to Twitter with curl
And to post an update to your twitter status:
curl -u your_user:your_password -d status='This is My update' https://twitter.com/statuses/update.xml
Be sure to replace "your_user:your_password" with your user name and password. If you don't want the password to show up in your command history, put a space before curl for bash, or clear out your history if you're using zsh or fish or another shell.
That's it! Imagine all of the fun automation possibilities !
I also had problems after Twitter switched over to oAuth. I found this to be a good solution:
This is like curl, but made specifically for twitter, plus it uses oAuth!
The first one is not working. Whats the shame
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 ;-)
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 :)
I used something similar to “schedule” a tweet.
That tip on listing the tweets would be great with geektool.