twitter のタイムライン表示をコマンドライン twidge で

twitterのタイムラインってCUI向きではないか。
ソースもあるがパッケージ化もされてるので、誰でも簡単にインストールできる。
https://github.com/jgoerzen/twidge/wiki

Unix Command-Line Twitter and Identica Client
twidge is a client for microblogging sites such as Twitter and
Identica (identi.ca). Microblogging sites let you post short
one-paragraph updates, follow the updates that your friends post, and
interact with everyone in the site in a conversation style.

パッケージインストーラ系でインストールして、叩く。

$ twidge lscommands
All available commands:
Name                 Description
-------------------- -------------------------------------------------------
dmsend               Send direct message
block                Start blocking someone
follow               Start following someone
lsarchive            List recent status updates you posted yourself
lscommands           Display a list of all available commands
lsdm                 List recent direct messages to you
lsdmarchive          List recent direct messages you sent
lsblocking           List people you are blocking
lsfollowers          List people that follow you
lsfollowing          List people you are following
lsrecent             List recent updates from those you follow
lsreplies            List recent replies to you
lsrt                 List recent retweets from those you follow
lsrtarchive          List recent retweets you made yourself
lsrtreplies          List others' retweets of your statuses
setup                Interactively configure twidge for first-time use
unblock              Stop blocking someone
unfollow             Stop following someone
update               Update your status

まずは セットアップが必要。

$ twidge setup
Welcome to twidge.  We will now configure twidge for your
use with Twitter (or a similar service).  This will be quick and easy!
Please wait a moment while I query the server...
twidge: user error (Error from oauthRequest: "HTTP/1.1 401 Unauthorized")

どこかにアカウントの設定がいる。tw側の認証方式が変わるまではこれでいけたが。
oAuth向けの設定がいるようなので、パッケージ版をアンインストールして、最新版をソースコンパイルでインストールする。依存パッケージもすべて解決していく。

$ git clone https://github.com/jgoerzen/twidge.git
$ cd twidge
$ ghc --make -o setup Setup.lhs
$ ./setup configure
$ ./setup build
$ sudo ./setup install

twitterをブラウザで表示されるトークン付きURLでアクセスして、twidgeからのアクセスを許可して、そこに表示されるキーをコンソールから入力する。

$ twidge setup
Welcome to twidge.  We will now configure twidge for your
use with Twitter (or a similar service).  This will be quick and easy!
Please wait a moment while I query the server...
OK, next I need you to authorize Twidge to access your account.
Please cut and paste this URL and open it in a web browser:
https://api.twitter.com/oauth/authorize?oauth_token=QWERTYUIOYUISD$%&FGHJI
Click Allow when prompted.  You will be given a numeric
key in your browser window.  Copy and paste it here.
(NOTE: some non-Twitter services supply no key; just leave this blank
if you don't get one.)

Authorization key: **********
Successfully authenticated!
Twidge has now been configured for you and is ready to use.

初期設定が終わったらタイムラインをみてみる。

$ twidge lsrecent -su
<bsiyo>                鼻つまってやばい
<Minervity>            Mind Altering 3D TV - http://bit.ly/1YTPTl
<adakoda>              文鎮おつかれさまでしたー

もうすこし、整形するといい。
http://www.ishilab.net/~ishihara/tips/awk.txt
これくらいで。

$ twidge lsrecent -ausl | \
awk -F"\t" '{print $5"\nhttp://twitter.com/#!/"$2"\n"$4"\n"}'

Sun Dec 19 06:52:09 +0000 2010
http://twitter.com/#!/htnb_hot
オサレっぽい洋楽教えてくれ : はれぞう http://dlvr.it/BhQBK

Sun Dec 19 06:52:08 +0000 2010
http://twitter.com/#!/htnb_hot
【時間管理術】『アジャイルな時間管理術 ポモドーロテクニック入門』Staffan Noeteberg(著), 渋川よしき,渋川あき(翻訳):マインドマップ的読書感想文 http://dlvr.it/BhQB1

Ubuntuデフォルトコンソールなら、リンク文字列はクリックでブラウザへ渡せる。
ループとスリープで常時稼働スクリプトに。

#!/bin/sh
while :
do
    twidge lsrecent -ausl | \
    awk -F"\t" '{print $5"\nhttp://twitter.com/#!/"$2"\n"$4"\n"}'
    sleep 55
done