Twitter Cli, Twitter client for the command line

name twitter cli

In the next article we are going to take a look at Twitter CLI, or just t. Today, I have started using the CLI mode more than the GUI on my desktop. Working from the command line is a fun, fast, safe and recommended way to learn how to use Gnu / Linux.

Every day, I spend time on Gnu / Linux forums, websites, and blogs looking for CLI alternatives to the GUI applications I use the most. Like I say, I stumbled upon a Twitter client for command line called "Twitter CLI" or simply "t". This will allow us to interact with Twitter from our terminal. It is a great application with which fans of the terminal can enjoy very good times on this social network.

Installation

First of all we will have to make sure we have Ruby installed in our system. On DEB-based systems like Ubuntu or Linux Mint, the following command will install Ruby:

sudo apt install ruby-dev

Now, we can install "Twitter CLI" using command:

sudo gem install t

This command will install the "Twitter CLI" tool along with all the dependencies.

Note: In case you have a PATH related error of the system, we can add ruby ​​to our PATH variable. If the terminal didn't return an error, just skip this part.

In my case, I have added the following to my PATH:

echo 'export PATH="$HOME/.gem/ruby/2.4.0/bin:$PATH"' >> ~/.bashrc

To update the PATH changes, we will execute:

source ~/.bashrc

Next, we should be able to install "t" using the following command:

sudo gem install t

Configuration

Before using t, we will first have to register an application with Twitter. For this we will have to follow the following steps.

First we will have to log in to the Twitter app management site. Then you will have to click on «Create new app«.

twitter cli twitter app

We will complete the required fields and submit the form. Keep in mind that the request must have a unique name. Next, we are going to move to the «Permissions » y change the Access settings to "Read, write and access direct messages". A mobile phone number must be associated with your Twitter account to get typing privileges.

twitter cli data on the web

Now is the time to move to the tab «Keys and access codes» to see the API Key and APISecret that we will need to copy and paste when the program requests it.

Authorize the client

We have already installed "t" and created and registered an application on Twitter. Now, we need authorize this tool with our Twitter account. To do this, we will execute in the terminal (Ctrl + Alt + T):

t authorize

t authorize twitter cli

A dialog box will appear. In it, we will be told to press the ENTER key to open the Twitter Developer site and copy / paste the API Key and APISecret when requested. We will just have to follow the steps.

At the end, if we get the message «authorization successful", Congratulations! We will have correctly configured "t" with our Twitter account.

To see the list of all the accounts that we have authorized, we will execute:

t accounts

This option will show us users who are authorized in our system to use the application. If you authorize more than one account, the last authorized account will be set as active.

For make another account active, just mention the username and your consumer password as below:

t set active sapoclay RQi8DiW4IuPt

All authorized account data will be stored in the file ~ / .trc. You can view the details of the accounts at any time by using the command:

accounts saved twitter cli

cat ~/.trc

Use Twitter CLI

Arrived here, it is now to see how send a tweet. For this we will only have to execute:

tweet from console sent

t update "Enviando un Tweet desde la consola de Ubuntu"

As you can see in the following screenshot, the tweet is published on Twitter without problem and immediately:

tweet sent to twitter

A highlight of this tool will be that will show us how to delete our last tweet. To delete the previous tweet, I had to execute the following command:

t delete status 913726339378827270

For include special characters in our tweets, we will only have to wrap it with single quotes instead of double quotes, so those characters are not interpreted by our shell. If you use single quotes, your Tweet obviously cannot contain any apostrophes unless you set them with a backslash.

Now we know how to post a tweet and how to delete it. We can also view the full details of a Twitter user if we know the name of the user. We can see the details of your account using the command:

t whois @ubunlog

To see the statistics of a user, we will only have to execute:

t users -l @ubunlog

There are more options, but the article would get too long. To see the full list of available commands, we will only have to execute:

twitter cli commands

t help

We can consult all its characteristics and other properties of this project on its page of GitHub.


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.