Using Mastodon from the command line
Command Line – Mastodon CLI Client
If you are looking for a Twitter alternative, toot lets you interact with Mastodon from the command line.
An open source, decentralized version of Twitter, Mastodon has been in development since 2016. With Elon Musk's erratic decisions since purchasing Twitter in late 2022, many users predicting Twitter's doom have been searching desperately for alternatives. The result has been a new surge in interest in Mastodon – even if many newcomers remain puzzled by its open source organization. The interest is so great that Mastodon's founder Eugen Rochko reports that he has received offers of "hundreds of thousands of dollars" from five investors – offers he refused so as not to endanger Mastodon's nonprofit status [1]. As I write, the exodus from Twitter appears to have slowed, but along with the renewed interest in Mastodon has come a renewed interest among Linux users in toot [2], an open source command-line client for Mastodon.
Toot takes its name from Mastodon's equivalent of Twitter's tweets, the microblog messages posted by users. Officially, the term is obsolete, with Mastodon's latest release replacing toot with a simple Publish button [3], but the term remains widely used. Toot compares favorably with Twitter clients for Linux such as Twidge, Oyster, and Rainbow Stream, many of which are not up-to-date, and have an alarming tendency to come and go without warning. By contrast, although current users must still use the web interface to create a Mastodon account for everyday use, toot is a complete replacement for the web version of Mastodon (Figure 1), providing functionality that is both thoroughly documented and up-to-date with Mastodon through a series of commands and options that keeps users' hands firmly on the keyboard.
Getting Started
You will find toot in the package repositories of many distributions and you can also install toot using Homebrew, although some sources are more current than others. However you choose to install, to use toot, you must create an account in a Mastodon instance from a web browser before logging in with the command toot login_cli
(Figure 2). Upon launching, toot creates a configuration file in your home directory at .config/toot/config.json
. You must then specify a Mastodon instance to log in to – but note that its name must be entered in lowercase characters with periods rather than spaces between the words, regardless of how the instance name is presented in the web interface. After toot locates the instance, enter your email and password to log in. For later access, toot stores your email and a temporary access token in the configuration file so that your password is never stored unencrypted. Once you are connected to an instance, you can enter user whoami
to display user details and toot whois
to display account details. To switch accounts, use toot activate
. To see a list of active accounts, enter toot auth
.
Posting Toots
You can post a toot in several ways. The simplest (as shown in Figure 3) is:
toot post 'MESSAGE'
Alternatively, you can compose a toot in a text editor of your choice (Figure 4) – Vim in this example – with the following command:
toot post --editor vim
Save and exit the toot as you normally would in the editor, and the toot is also posted. If you prefer to always use a text editor, define your preferred editor as an environmental variable (for instance, export EDITOR=vim
), and then you can simply use the following command:
toot post --editor
With all these variations of the command, you can add up to four attachments. For the first attachment, use the option
-media path/to/image1.png --description "TEXT" \
and then change the image number for the subsequent attachments. If necessary, you can flag attachments with:
--media nsfw.png --sensitive
Once a toot is posted, you can see any replies using toot notifications
.
Viewing the Timeline
When viewing toots in your timeline, the basic command toot timeline
displays the most recent toot. It then gives you the option of either displaying the last dozen toots or else exiting the client altogether. You can also use the options listed in Table 1 to modify which toots are displayed.
Table 1
Viewing Options
|
Public timeline, only this Mastodon instance |
|
Posts tagged with |
|
Fetch up to 20 toots |
|
Don't prompt to fetch more toots |
At the bottom of each toot, you will find its ID and whether it has been reblogged. You can pin one of your own toots to the top of your timeline with toot pin ID
or delete it with toot delete ID
(Figure 5).
You can locate other people on Mastodon with
toot search "NAME"
or by their Mastodon instance address with
toot search NAME@INSTANCE
With an instance address, you can also use the self-explanatory commands follow
, mute
, block
, or unfollow
. To like a toot, used the command
toot favourite ID
(note the UK English spelling). To reblog toot use toot reblog ID
.
Should you decide to undo any of these actions, you can run the same commands prefaced by un
. For example, if you decide on second thought not to favor a toot, use the command:
toot unfavourite ID
The rest you can probably figure out for yourself. If necessary, though, for detailed summaries, run
toot COMMAND --help
You can perform all these basic functions from the command line or start the curses user interface with toot tui
(Figure 6). The curses interface is navigated by the keyboard commands shown in Table 2.
Table 2
Curses Interface Navigation
|
Move up the list of toots |
|
Move down the list of toots |
|
Show a help screen |
|
View status thread |
|
View the current toot in a browser |
|
Boost or unboost a status |
|
Favorite or unfavorite a status |
|
Quit the curses interface and return to the command line |
|
Show sensitive content |
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.