Some months ago we published an article with several alternatives that would allow us to visit youtube.com a little less without having to give up its content. There are several options, among which stands out Free Tube. They are all good, but we can encounter the same problem: if I want to watch a video on FreeTube and I have a browser open, I have to go to the start menu, click on its icon, then on the search box — also Ctrl + L –, enter the search and press enter. In the browser I just go to the URL box and enter !yt search, since my browser supports !bangs.
This has a solution and it is to use a small script. FreeTube search box supports YouTube links, and that's part of the secret. If you accept links, it accepts your searches, and our little program has to accept a text, match it to the YouTube search and launch the app. It wouldn't be necessary if FreeTube added a native option, but that's not the case at the moment.
Script to search FreeTube from the terminal
The script would look like this:
#!/bin/bash if [ $# -eq 0 ]; then echo "No search provided." exit 1 fi search="$*" freetube "https://www.youtube.com/results?search_query=$(echo "$search" | sed 's/ /+/g')"
You could even remove the conditional if you wanted to simplify it further, but it is an error management that prevents exceptions or something similar from being thrown.
The code would do the following:
- The first thing is the Shebang, which indicates that it is going to be executed in bash.
- The conditional says that if no arguments are provided, display a message warning about this and exit the program.
- We then create the variable “search” and tell it what all the arguments are. If we put $1, it would only take the first word, and we want to perform searches that include phrases.
- Finally, you would launch Freetube with the search. The results will be the first thing that appears. If there are few, you can click on show more.
The file can be called whatever we want. I have it as “fts”, without the quotes and as “FreeTube Search”, and to perform a search the command is “fts funny kittens”, also without the quotes.
If after giving it execution permission — chmod -x file — we place the executable in the folder ~ / .local / bin, we can launch it from anywhere, like Kickoff or krunner KDE or the application launcher of any environment that supports launching commands. If there is no launcher, the most general combination is Alt + F2.
It's not something that's going to save our lives or make us rich, but it's a useful script that will allow us to get a little further away from Google's clutches.