Note: this only applies to MacOS
Often times while I'm working on a project, I'll need to search for something on the internet to solve a problem. I usually use the search engine created by Google, called Google. When I need to search for something, I always have to stop what I'm doing, and switch over to a browser to type in my search. This may not seem like a big deal because it doesn't take that much time, but in reality this is a context switch. There is a momentary discontinuity in the intentions of your search.
I'd like to remove this obstacle and be able to search without leaving my development environment. This can be accomplished by using the open
command on MacOS, and the chromium-browser
command on Linux.
Place this script in your PATH with the name "gsearch":
~/scripts/gsearch
#!/bin/sh
# If using mac
open "https://google.com/search?q=$*"
# If using linux and chromium
chromium-browser "https://google.com/search?q=$*"
# Now you can enter a search query like this:
gsearch please help google
A browser tab will then come into focus, showing the results for a Google search of "please help google". Now that's good DX.
Top comments (5)
First of all there is no
open
command in Linux,it's a Darwin specific command to open anything using its respective app. In Linux there isxdg-open
which should open a specific file in browser. So your post is Mac specific and you should specify this too. 💌👨🏻💻Noted! I purposely didn't do any research on compatibility to generate more discussion. Thanks for your insight!
Alt-Tab is a practical solution. However, I can be sensitive to sudden visual changes, especially when I'm thinking hard about something. Also the extra step of having to open another tab adds another obstacle for me, even though it is a simple Cmd-T. Anyway, I kind of made this as a joke for my first post. I thought it was a cool trick :)
Any Linux distro with KDE Desktop environment has Krunner which can do that and much more than that you should try it it's amazing
I certainly will! Thank you!