I thought it would be fun and convenient to post to Twitter from the command line, so I wrote a little shell script to do just that. You can download it here. Just place it somewhere in your $PATH, set the executable bit, and then you can do this from anywhere:

$ twit

Simple as that. It does have a few features to be aware of:

  • The script will prompt you for your Twitter username and password, unless you set the $TWITTER_USER and $TWITTER_PASS environment variables (in .bash_profile or wherever)

  • You can optionally select an image to post, in which case it will be uploaded to TwitPic

  • All the prompts use readline, so you get filename completion, emacs/vi editing mode goodness, and the benefits of whatever you have set in your .inputrc

  • The response is in XML format and just dumped to STDOUT unprocessed. No fancy parsing or formatting. After all, XML is human readable, right? Right?

Finally, it requires you have curl installed. But you already use and love curl, don't you?