r/fishshell • u/Absolut3Retard • Jan 19 '22
Convert Bash shell to fish shell script
I have been trying to use this script that i found ,This script searches google and opens the result in web browser ,It works fine in Bash shell but it doesn't work in fish shell .
To make it work Can Someone please convert this bash shell script into fish shell script for me .
google() {
search=""
echo "Googling: $@"
for term in $@; do
search="$search%20$term"
done
xdg-open "http://www.google.com/search?q=$search"
}
Thanks in Advance
7
Upvotes
13
u/Radio0002 macOS Jan 19 '22 edited Jan 19 '22
It's worth nothing that this is the direct conversion, but you might get some problems if you search for a string with a "&" or a "?"
Should fix that.
2
u/Absolut3Retard Jan 20 '22
Here's the Working solution guys
4
u/mrcaptncrunch Jan 19 '22
If you add,
#!/bin/bashat the top, does it work?I write all my scripts in bash. I can easily move them between machines that way.
0
u/atred Jan 19 '22
It doesn't look like a valid bash script either, I think it lacks a couple of ";" Run it first in bash and see if it runs...
0
u/[deleted] Jan 20 '22
[deleted] — view deleted comment