ytfzf-Search (with thumbnails) and play YouTube videos on the terminal

ytfzf It is a script that can search, download and play YouTube videos by using mpv and youtube-dl. It can run on Linux and macOS. The command line script released the first stable version (1.0.0) today.

The tool originally started as a one-line script, but has since been developed, and recently gained the ability to display YouTube thumbnails in the terminal and other enhancements.

For each YouTube search query, the results pane is displayed in the right pane. On the left, you can see the selected video title, the channel where the video was posted, number of views, video duration, upload date and video thumbnail (optional).

use Up with Down Arrow keys to browse the search results, then press Enter The key to play the video (or download the video, ytfzf is from -d Command line parameters). These videos are played using mpv by default, but you can use other video players to make changes, as long as it can start the YouTube link.

The thumbnail is implemented using the following method Überzug, This is a command-line utility that allows drawing images on the terminal using sub-windows. Since Überzug is only available on X11, the ytfzf video thumbnail function is also associated with X11 sessions and does not work on Wayland. Also, don’t expect it to work in a tty-obviously it won’t.

It is worth noting that video thumbnails may sometimes be displayed outside the terminal window.In this case, you need to adjust the size of the terminal, and then press Up / Down Use the arrow keys to select other videos and it will use the updated thumbnail size.

In addition, ytfzf also supports video history, allows selection of media formats, and can queue multiple tracks (use fzf for multiple selection). You can search YouTube videos and use fzf, dmenu or rofi to play/download.

Other functions include playing/downloading audio only, auto-playing and repeating YouTube videos, the function of playing random search results, and the option to display available media formats before continuing.

See ytfzf --help A complete list of relevant options.

For future versions, the developers intend to implement support for YouTube playlists and comments. However, there is no timetable for when these functions will be implemented.

[[Edit]]In ytfz​​f 1.1.0, the tool adds subscription, Which allows you to easily search among the videos of subscribed channels.

Related: How to download a YouTube playlist and convert it to MP3 using youtube-dl (command line)

ytfzf configuration can be in ~/.config/ytfzf/ File or use environment variables.Let’s use ~/.config/ytfzf/ Set everything below.create ~/.config/ytfzf folder:

mkdir ~/.config/ytfzf

Open now ~/.config/ytfzf/ In a text editor (create it because it doesn’t exist yet), and paste the following:

YTFZF_HIST=1 # history is on by default it can be set to -> 0 history off, 1: history onYTFZF_LOOP=0 # if set to 1 it is on but normally it is off by default. Can be turned on using option -lYTFZF_PREF="bestvideo[height<=?1080]+bestaudio/best" # set the video formatYTFZF_ENABLE_FZF_DEFAULT_OPTS=1 # fzf colors are going to be the one from your fzf configurationFZF_PLAYER="mpv" # sets the video player used by ytfzf (mpv by default), e.g. FZF_PLAYER="devour mpv"; you can also specify the YTFZF_PLAYER_FORMAT, e.g. YTFZF_PLAYER_FORMAT="devour mpv --ytdl-format="

This is an example configuration. You can change some of these settings, use them as they are, or uncomment them to use the default settings.You can find more configuration options Here.

Using ytfzf is as easy as running:


After entering this command, you will be prompted to enter a YouTube search query, as shown below:

$ ytfzf

Search Youtube:

You can directly specify the search query, so ytfzf will not prompt you to query, as shown below:

ytfzf <query>

However, when using this feature, there will be no thumbnails in YouTube search results.To enable thumbnails, use -t (or --thumbnails) Command line parameters:

ytfzf -t

By default, ytfzf will play the video in the search results when you click Enter.If you want to download the video instead of playing the video, use -d Command line parameters:

ytfzf -d

Want to put YouTube videos in ytfzf (and therefore in mpv)?press Tab Select each video you want to add to the queue and play it in mpv.use > with < (Therefore using Shift + > with Shift + <) Navigate to the next and previous video in the queue.

For more detailed information about configuring and using ytfzf, including how to use it with external menus such as dmenu or rofi, please see its Project page.

You might also like: Use browser-mpris2 (Chrome extension) to add YouTube player controls to your Linux desktop

Install ytfzf

ytfzf can be Installed From AUR On Arch Linux/Manjaro, and use Nitrate Overlay on Gentoo.You can also install it on Apple system.

For other Linux distributions, installing ytfzf is fairly easy because it is just a script. However, you need to manually install its dependencies: mpv, youtube-dl, fzf (Optional, for menu), jq with ueberzug (Optional, for video thumbnails; it also has some Dependency).We still need git To get the latest ytfzf.

Below, you will find Debian / Ubuntu / Linux Mint / Pop! Step-by-step instructions for installing ytfzf on _OS and other Linux distributions based on Debian or Ubuntu and Fedora. You can follow the instructions below to install ytfzf on other Linux distributions, but you need to figure out the dependency names of the Linux distributions yourself.

As a reminder, video thumbnails do not work on Wayland, so if you use Fedora or Ubuntu 21.04 that uses Wayland by default, you can use this thumbnail without using thumbnails, or you can switch from Wayland to X11 session from the login screen.

1. Install ytfzf dependencies and Üeberzug dependencies.

  • Debian / Ubuntu / Linux Mint / Pop! _OS:

sudo apt install jq mpv fzf git python3-pip python3-wheel python3-dev python3-xlib libx11-dev libxext-dev make

sudo dnf install$(rpm -E %fedora).noarch.rpm$(rpm -E %fedora).noarch.rpm

sudo dnf install jq mpv fzf git python3-pip python3-wheel python3-devel python3-xlib libX11-devel libXext-devel make

For any Linux distribution: Since youtube-dl is usually updated in the repository (at least on Debian/Ubuntu), let’s install it from PyPi. We also need to install ueberzu in the same way:

python3 -m pip install --user youtube-dl ueberzug

If you have installed the youtube-dl package from the repository, it is best to delete it. You can use it later to update youtube-dl python3 -m pip install --user --upgrade youtube-dl

2. Get the ytfzf GitHub repository and install ytfzf:

git clone

cd ytfzf

sudo make install

This will install the ytfzf script to /usr/bin.

If you need to uninstall it later, navigate to the ytfzf directory and run:

sudo make uninstall

You might like: Olivia: a cloud-based music player with YouTube support and more than 25,000 online radio stations

by r / unixporn


Related Posts