How to Watch YouTube Videos in the Linux Terminal With ytfzf

It’s no secret that Linux keyboard warriors spend their lives in the terminal, only surfacing to load a browser and watch their favorite Taylor Swift music video on YouTube.

With ytfzf, you may search YouTube videos from your terminal and stream them using a lightweight media player. You’d never need to open a browser to watch YouTube on Linux again!

4

What Is ytfzf?

ytfzf is a set of scripts that run in your terminal, and it doesn’t use the YouTube API. When ytfzf starts up, it fetches a list of the top 10 Invidious instances and selects one at random. Invidious is a web-based alternative front end for YouTube, and there are thousands of instances across the world.

With the Invidious API, ytfzf searches for the video you want. It then uses yt-dlp to download and stream the video to mpv.

woman watching taylor swift bejeweled with ytfzf on a macbook

YouTube won’t be able to set any cookies on your devices, and you won’t see any adverts or pre-roll videos, either.

How to Install ytfzf on Linux

Before you install ytfzf, you need to install its dependencies, including mpv—a free media player for the command line, with support for a wide variety of media file formats, audio and video codecs, and subtitle types.

ytfzf uses yt-dlp to download YouTube videos you find, soyou should install yt-dlpas well.

ytfzf playing Taylor Swift Bejeweled

Clone the ytfzf repository, and cd into it:

Now compile ytfzf, install the documentation, and compile the add-ons:

multi selected Taylor Swift videos in ytfzf

ytfzf is now installed on your Linux system, and you can start it by entering:

As ytfzf is a bit awkward to type or remember, you may want tocreate a memorable alias for the command.

wikit mockup

How to Use ytfzf To Search for Videos on the Command Line

As ytfzf doesn’t connect directly to YouTube to search for videos, when you start the app, you’ll see “Fetching list of healthy invidious instances”.

At thesearchprompt, enter the name of the video you want to search for. This doesn’t need to be exact, and typing “swif” then hittingEnterwill give you all the Taylor Swift music videos you could want. it’s possible to further refine these by inputting more text.

Use the arrow keys on your keyboard to navigate results, and hitEnterto stream the one you want.

mpv will open, and the video will play. you’re able to pause the video withSpace, and fast-forward or rewind with the arrow keys.

If you want to see thumbnails of the videos before you stream them, you need to add a switch before launching ytfzf:

Be aware this will not work in all terminals.

To create a playlist with ytfzf and mpv, simply pressTabwhen a video you want to watch is highlighted, thenEnterto add it to the playlist.

Instead of launching ytfzf and then entering your search term, you can issue:

…to be given a list of Linux videos to select from. ytfzf accepts arguments to make your experience more precise. Here are some of them:

As an example, enter:

…and mpv will instantly start playing “Bejeweled” by Taylor Swift.

Searching YouTube From the Terminal Is Insanely Cool

Being able to search YouTube from the terminal without needing to open a browser and accept adverts, tracking, and cookie consent dialogs will make you the envy of your friends.

Why not impress them even more by reading out a Wikipedia summary of your favorite musical artist in the very same terminal window?

It’s easy to access and read Wikipedia articles using the Linux terminal when you need to.

Quality apps that don’t cost anything.

The fix was buried in one tiny toggle.

Freeing up vital memory on Windows only takes a moment, and your computer will feel much faster once you’re done.

Don’t let aging hardware force you into buying expensive upgrades.

Sometimes the smallest cleaning habit makes the biggest mess.

Technology Explained

PC & Mobile