Today we’re making a command-line TweetDeck clone! I hope you’ve all brought your Twitter account, your phone and access to your Linux workstation or server. It’s supposed to also work on Mac devices but you’ll have to figure that out for yourselves. While it is perfectly possible to install Ruby on Windows I am not aware of screen or tmux possibilities there and that would take away half the fun.

So Linux it is. Pick any distribution; we’re not picky today. I’m using Debian 8 so this will most likely also work on the Ubuntus and Mint.



Our project consists of four parts:
1 – command-line Twitter client
2 – your custom Twitter application so you can use the Twitter api
3 – tmux for the columns
4 – PuTTY with customized colours

I assume some prior Linux experience; I won’t explain how to install Linux or connect with PuTTY.

We’ll be using @sferik‘s excellent command-line power tool for Twitter: ‘t’. Instructions on that site are pretty clear; here I’m just dressing it up a bit.

If you haven’t done so yet, you MUST associate a cell phone number with your Twitter account for this. Do that first, then come back here.

Time to prepare your system for t!

# aptitude install build-essential ruby ruby-dev

If you’re on a system that uses yum instead of apt, try

# yum groupinstall 'Development Tools'

I haven’t tested that though; in any case you need stuff like ‘make’ to compile the Ruby gem.

Once completed you can install t by doing

# gem install t

If you get errors check if Ruby and its development environment are correctly installed.

Now as your regular user you must set up your Twitter account. Not to worry: t will give you clear instructions. It will even open necessary urls in your browser. As I am doing this on a machine without a browser I want to see the urls but not have them openened; I will copy and paste them in a browser on a different machine. To that effect you can use the –display-uri parameter. If you’re on a machine with a gui by all means leave that parameter out.



Now tell t about your account:

$ t authorize --display-uri

t will instruct you on how to proceed.



Press Enter. If you left out the –display-uri parameter then your browser will be opened. If you did provide the –display-uri parameter then you will be shown the url you should open. Copy the url and open it in a browser.

I’ll just assume you haven’t created any Twitter apps before. If you did you know the drill.



Provide a name, a description and a url for your app. Some Twitter apps show this data along with your tweets so keep that in mind.



Congratulations, you are now a Twitter app developer.



Go to the Permissions tab and set the correct permissions. Provide only the persmissions you need, never more.



Go to the Keys and Access Tokens tab and copy the Consumer Key.



Paste the API key on the command line.



Copy the API secret key.



Paste it on the command line.



t will now instruct you to open the Twitter app authorization app. If you supplied the –display-uri parameter it will just show you the url you should open.



Authorize the app.



Copy the six digit code.



Paste the code on the command line.



If all is well t says ‘Authorization successful’.

Test it by sending a tweet:

$ t update 'Tweeting this from the command line!'

…or whatever tweet you like to send :P



t provides the command for deleting the tweet if necessary. The numeric code is the unique tweet id.




Now for the cosmetic part!


# aptitude install tmux

if tmux isn’t installed on your system yet. It pays to read some documentation on basic tmux operations.

Start tmux and split the screen horizontally:

$ tmux
^b + "



Select the upper pane:

^b + q 0


^b + [up]

Split the upper pane in four separate vertical panes by using

^b + %

Move around the panes with

^b + [up|down|left|right]

Select a specific pane by issuing

^b + q

Select the desired pane number.

You’ll get the hang of it ;)



In the individual panes issue the t commands you want. I like to set it up like this:
– pane one: #dtv OR #durftevragen (search query)
– pane two: timeline
– pane three: mentions
– pane four: dms (not shown in this article, I forgot to set dm permissions for my app ;))

Of course you are free to set it up however you like. In my case these are the commands:

t stream search "#dtv OR #durftevragen"
t stream timeline
watch -d 600 t mentions

The third command is because you can’t stream mentions. Or you can but it didn’t work for me. Anyway the watch command ($ man watch) is helping me out here.



If you’re connecting from PuTTY you can play around with the font, colours, size, etc.



If you’re done select Session, enter a name and click Save so your settings are saved.



First result:



‘watch’ is stripping colour from my mentions so I’m working around that with a manual watch replacement:

$ while true; do clear; t mentions -n 6; sleep 600; done



Victory! We can use the lower horizontal pane to send updates in.