Friday, March 21, 2008

Howto Twitter From the Command Line in Ubuntu!


Twitter rocks, here is a quick n easy way to twitter from your console in any Unix system:



sudo apt-get install curl

sudo gedit /usr/bin/twitter

Now Paste this in gEdit and simply replace "yourusername" with your username and "yourpasswd" with your twitter passwd and ctrl-s to save, then alt-F4 to exit!


curl --basic --user "yourusername:yourpasswd" --data-ascii "status=`echo $@|tr ' ' '+'`" "http://twitter.com/statuses/update.json" -o /dev/null
echo Message Sent!


Then chmod for exec privileges:
chmod +x /usr/bin/twitter
All done! w00t! Now lets try it out :)

All you gotta do is:
twitter "message here without the quotes"
You dont even need to open the command line, all you gotta do is press alt-F2 and type twitter then your message, and dont forget to check "Run in Terminal"

11 comments:

  1. You do have to include the quotes when you type characters like parenthesis. Dunno what else need this. ? and ; don't.

    ReplyDelete
  2. Why would you want to tweet from CLI?

    I'm being smart, but not, with that statement. I mean, Twitter can be used from Fx, the website, your mobile, via email...

    I won't say it's pointless, because I use some pretty niche products, but it does seem odd to me.

    Still, glad to see more tips.

    ReplyDelete
  3. well sometime I personally dont have a window manager running, and I spend allot of time on the terminal so it is convenient for me, and probably others that use twitter and use the command line allot.

    ReplyDelete
  4. kyle - I could see that, that's why I didn't want to call it "pointless". ;)

    Hey, if it works for one person, then it's worth it. I just use the CLI for maintenance, so it doesn't relate to me personally.

    ReplyDelete
  5. Mike, yes, africans do use ubuntu, afterall ubuntu is a african word meaning:
    A Zulu word, literally meaning “humanness.” Ubuntu is a social and spiritual philosophy serving as a framework for African society.
    I hope your not being racist, which I think you are, I will forgive you for that this time. I am not african but I have some beloved friends that are that use the command line daily, some that I know and I learn allot from, and then learning to adapt and deal with racism means that the racists have allot to learn from them as well.

    ReplyDelete
  6. Waiting for your next post -- you seem to be on holiday.

    ReplyDelete
  7. Everything works fine until the line

    chmod +x /usr/bin/twitter

    then it says

    chmod: changing permissions of '/usr/bin/twitter': not permitted


    Any tips?

    ReplyDelete
  8. I think he forgot to put "sudo" in front of that command.

    ReplyDelete
  9. yeah thanks dirtvoyles. :)

    Doesn't say sudo there, but I guess they expect people to assume that part of it.

    ReplyDelete
  10. I got this idea from fsckn w/linux, and improved his idea with echo message sent and output to dev/null, and added twittering from alt F2

    ReplyDelete