Lazy Man's Twitter Updates via CLI
While the various twitter apps around are nice for reading tweets, I'm too lazy to want to fire up the browser or reach for a desktop menu when I just want to twitter. After a pointer from coworker Sean Stoops to a Lifehacker article, Send Twitters from Command Line in Any OS, I kicked up this little shell script to make it even that much easier.
#!/bin/bash if [ $# -eq 0 ]; then echo 'Usage: twit "STATUS IN QUOTES"' exit 1 elif [ $# -gt 1 ]; then echo 'Usage: twit "STATUS IN QUOTES"' exit 1 fi STATUS=$1 TWITUSER=yourusername TWITPASS=yourpassword curl -u $TWITUSER:$TWITPASS -d status="$STATUS" http://twitter.com/statuses/update.xml
Now it's just -- twit "MY STATUS UPDATES" -- and I'm done.
Posted by deryck on March 7, 2008


Comments
Alex Kritikos March 7, 2008 at 3:28 p.m.
If you remove the [ $# -gt 1 ] check and use STATUS=$* instead of STATUS=$1, you can omit the quotes around multi-word tweets.
So, you can say:
twit MY STATUS UPDATES
instead of:
twit "MY STATUS UPDATES"
deryck March 7, 2008 at 10:16 p.m.
For some reason, I liked requiring the quotes. It seemed to make me think more about the whole message, and with having to close the quotes, I'm not as worried about sending a stray word I didn't mean to send.