Tweet from Command Line with t

By  on  

Tweet from Command Line

I've been obsessed with command line magic lately, as you may have noticed.  I don't plan on using every utility I've written about but I'm having fun learning about what's out there and how it's done.  My latest quandary was how one could tweet and perform other Twitter-centric tasks from the command line.  I found my answer:  t.

The t project README perfectly describes the process for installing t and the process you must follow to allow the app access to your account.  In short, you must create a Twitter app, provide t the proper API auth tokens, and enable the app within your account.  t is so well written, however, that it tells you exactly what to do and opens the necessary URLs in your browser.  t is an incredible utility.

The t project README also provides a host of command line instructions for tweeting, managing lists, etc.  Here are a few frequently used commands:

# Set the "active" account
t set active davidwalshblog

# Send a tweet
t update 'This is my epic command line tweet!' 
# >> Tweet posted by @davidwalshblog.  Run `t delete status 595038201179312128` to delete.

# Get user information
t whois davidwalsh

# Follow a user
t follow davidwalsh

# Get your timeline
t timeline

# Get your timeline listing with IDs, then get stats about a tweet
t timeline -l
t status {id}

# Get recent mentions
t mentions

# Get recent mentions with their ID so you can reply back
t mentions -l 
t reply {id} {message}

The commands I've shown above are just the tip of the iceberg.  t has loads of more advanced functionality available, and since all I/O is done via command line, you can use your other favorite command line utilities evaluate results, as shown here:

# Output the last 200 tweets in your timeline to a CSV file
t timeline -n 200 --csv > timeline.csv

I was up and running within t 5 minutes, despite needing to go through Twitter's API hoops.  And t is amazingly simple but very powerful, so I look forward to using it more in the future.  Kudos to its author and I look forward to seeing where this project goes!

Recent Features

  • By
    CSS vs. JS Animation: Which is Faster?

    How is it possible that JavaScript-based animation has secretly always been as fast — or faster — than CSS transitions? And, how is it possible that Adobe and Google consistently release media-rich mobile sites that rival the performance of native apps? This article serves as a point-by-point...

  • By
    Being a Dev Dad

    I get asked loads of questions every day but I'm always surprised that they're rarely questions about code or even tech -- many of the questions I get are more about non-dev stuff like what my office is like, what software I use, and oftentimes...

Incredible Demos

  • By
    HTML5 download Attribute

    I tend to get caught up on the JavaScript side of the HTML5 revolution, and can you blame me?  HTML5 gives us awesome "big" stuff like WebSockets, Web Workers, History, Storage and little helpers like the Element classList collection.  There are, however, smaller features in...

  • By
    Printing MooTools Accordion Items

    Sometimes we're presented with unforeseen problems when it comes to our JavaScript effects. In this case, I'm talking about printing jQuery and MooTools accordions. Each "closed" accordion content element has its height set to 0 which means it will be hidden when the...

Discussion

  1. This is great, thanks for the share. I also can’t wait to see where this project goes!

  2. Ryan

    I’ve always wanted to Tweet in the terminal, so this is great

    All I need now is a Googling terminal utility and I’ll be set.

  3. Alessandro Belloni

    how can i “t update” with an image?

  4. Can i post a tweet with image?

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!