Twitter / terminal

Reading time:
1 min. | 180 words

I’m trying to incorporate Twitter into my workflow for Jekyll by allowing any new posts to the site to subsequently update Twitter. The script I’ve hacked together so far is very basic, and doesn’t yet do the job, but I thought I’d share what I have thus far.

Pretty easy to get this working. The script requires a couple of simple includes:

  • twitter
  • oauth

Then register your app to authenticate your new Ruby command line Twitter script to use OAuth. Write down the consumer and access public and private keys; you’ll need them to get things working. Once you’re ready, simply plug in your keys into this script:

# !/usr/bin/env ruby

# broadcastr.rb
# Simple Twitter updater built in Ruby
# Use: $ ruby broadcastr.rb "Tweeting with Ruby"
# Created by Jason A. Heppler
# Last Modified: 2011-07-09

require "rubygems"
require "twitter"
require "oauth"

Twitter.configure do |config|
    config.consumer_key = 'INSERT_CONSUMER_KEY'
    config.consumer_secret = 'INSERT_CONSUMER_SECRET'
    config.oauth_token = 'INSERT_OAUTH_TOKEN'
    config.oauth_token_secret = 'INSERT_OAUTH_SECRET'

client =

twttr_update = ARGV[0]


You can run this by calling up Ruby or make the script executable and edit your bash PATH in your .bashrc file (don’t forget to refresh .bashrc after you modify it).

You can update Twitter by writing:

$ ./broadcastr.rb "I'm tweeting from the command line, yo!"


Greetings! My name is Jason Heppler. I am a Digital Engagement Librarian and Assistant Professor of History at the University of Nebraska at Omaha and a scholar of the twentieth-century United States. I often write here about the history of the North American West, technology, the environment, politics, culture, and coffee. You can follow me on Twitter, or learn more about me.