---
category: technology
layout: post
title: Twitter from the command line
date: '2009-07-02T11:38:00.000-04:00'
author: Anna Wiggins
tags:
- programming
- linux
- twitter
- Technology
modified_time: '2013-10-22T11:19:50.705-04:00'
blogger_id: tag:blogger.com,1999:blog-4209116010564764361.post-6156350980105195782
blogger_orig_url: http://www.stringofbits.net/2009/07/twitter-from-command-line.html
---
I've recently started playing with twitter. A nice way to use it via the command-line (using curl) was suggested here. I have taken that and improved slightly on it.
Here is the result:
#!/bin/sh
echo -n "twitter> "
read text
while [ ${#text} -gt 140 ]; do
echo
echo "Message too long; used ${#text}/140 characters."
echo
echo -n "twitter> "
read text
done
echo
echo "Message is ${#text}/140 characters. Press enter to post, or Ctrl+C to cancel."
read
curl --basic --user "username:password" --data-ascii "status=`echo $text|tr ' ' '+'`" "http://twitter.com/statuses/update.json" &> /dev/null
chmod 755 /usr/local/bin/twitter
). Now you can type 'twitter', type in your tweet, and you're done!
Mod4 t :Exec xterm -e "twitter"