Watch YouTube Videos Directly from Your Terminal with the "watch-yt" Script
Have you ever wanted to watch a YouTube video from the comfort of your terminal, without opening up a web browser and navigating to the YouTube website? If so, you might be interested in a bash script called
watch-yt that I recently wrote. This script allows you to search for and watch YouTube videos directly from the terminal, using the command-line tools such as
What is yt-dlp?
yt-dlp is a command line tool that allows you to download YouTube videos and play them directly from the terminal. It is a fork of
youtube-dl (a popular command-line utility for downloading YouTube videos).
yt-dlp is written in Python and is available for Linux, macOS, and Windows.
What is mpv?
mpv is a free and open-source media player available for a wide range of platforms, including Linux, macOS, and Windows. It is highly customizable and can be controlled using keyboard shortcuts or a graphical interface.
mpv is known for its minimalistic design and high performance and can play a wide range of video and audio formats.
What is fzf?
fzf (fuzzy finder) is a command line tool that allows you to quickly search through large amounts of text. It uses an algorithm called "fuzzy matching" to find patterns in the text and can be used to search through files, command history, and more.
fzf is written in Go and is available for Linux, macOS, and Windows.
How does "watch-yt" work?
watch-yt script uses
yt-dlp to search for YouTube videos and display the results in a list using
fzf. The user can then select a video from the list to watch, using the arrow keys and Enter key. Once a video is selected, the script uses
mpv to play the video in the terminal.
To use the
watch-yt script, you will need to have
fzf installed on your system. You can then download the script and make it executable using the following commands:
chmod +x watch-yt
You can then run the script by typing
./watch-yt in the terminal.
# watch-yt QUERY
./watch-yt 'learn rust lang'
# watch-yt URL
If you want to run the command anywhere, you can move the script file to a directory listed on your system PATH environment variable (Example:
watch-yt bash script is a handy tool for anyone who wants to watch YouTube videos directly from the terminal. It uses
fzf to search for and play videos, providing a convenient and fast way to access YouTube content from the command line. Whether you're a fan of the terminal or just looking for a quick and easy way to watch YouTube videos, "
watch-yt" is worth checking out.