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.

tdclone25

 

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.

tdclone01

 

Now tell t about your account:

$ t authorize --display-uri

t will instruct you on how to proceed.

tdclone02

 

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.

tdclone03

 

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.

tdclone04

 

Congratulations, you are now a Twitter app developer.

tdclone05

 

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

tdclone10a

 

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

tdclone06

 

Paste the API key on the command line.

tdclone07

 

Copy the API secret key.

tdclone08

 

Paste it on the command line.

tdclone09

 

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.

tdclone12

 

Authorize the app.

tdclone13

 

Copy the six digit code.

tdclone14

 

Paste the code on the command line.

tdclone15

 

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

tdclone16

 

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

tdclone17

 

~~

Now for the cosmetic part!

Do

# 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 + "

tdclone18

 

Select the upper pane:

^b + q 0

or

^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 ;)

tdclone19

 

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.

tdclone20

 

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

tdclone21

 

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

tdclone22

 

First result:

tdclone23

 

‘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

tdclone24

 

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

tdclone25