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
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.
-
Plasma Desktop Will Soon Ask for Donations
The next iteration of Plasma has reached the soft feature freeze for the 6.2 version and includes a feature that could be divisive.
-
Linux Market Share Hits New High
For the first time, the Linux market share has reached a new high for desktops, and the trend looks like it will continue.
-
LibreOffice 24.8 Delivers New Features
LibreOffice is often considered the de facto standard office suite for the Linux operating system.
-
Deepin 23 Offers Wayland Support and New AI Tool
Deepin has been considered one of the most beautiful desktop operating systems for a long time and the arrival of version 23 has bolstered that reputation.
-
CachyOS Adds Support for System76's COSMIC Desktop
The August 2024 release of CachyOS includes support for the COSMIC desktop as well as some important bits for video.
-
Linux Foundation Adopts OMI to Foster Ethical LLMs
The Open Model Initiative hopes to create community LLMs that rival proprietary models but avoid restrictive licensing that limits usage.
-
Ubuntu 24.10 to Include the Latest Linux Kernel
Ubuntu users have grown accustomed to their favorite distribution shipping with a kernel that's not quite as up-to-date as other distros but that changes with 24.10.