How to run goosh (command line google search) from WSL (Linux bash shell on Win10)?

I have an installation of WSL (an ubuntu installation limited to the command line - no GUI) under Win10 home edition. I would like to perform web searches from the WSL bash command line using goosh. I might be able to use cygwin or some other shell, and also a different search engine, but I would like to use WSL/goosh (if possible) because it is/seems convenient. All the pieces are (almost) in place. I can open the *nix emulator from a windows cmd console simply by typing bash. It would be "nice" if I could then type a command such as goosh my-search-string > my-text-file.

Ultimately I just want to collect search results in a text file through command line redirection, but that is down the road. Of course I appreciate alternatives or hints on how to do this. So far I have been unable to find how to do this, and specifically whether it is at all possible to run goosh under WSL/bash.

Note some related posts but which don't answer this:

  • This suggests using start xxx which opens a browser, defeating the purpose of working from the command line.

  • This might work but sends up flags as unsafe and is unsupported.


Solution 1:

I suggest using instead of the problematic goosh to use the links package.

A script/alias such as the following can call it with a query parameter consisting of multiple words (spaces are converted to plus):

links "google.com/search?q=$(echo $@ | sed 's/ /+/g')"

Solution 2:

In case anyone is interested, as noted in the comments, googler relies on Python, which is available on Windows (outside the Microsoft Store releases). And light poking around led to the discovery that googler has (at least some) support on Windows itself.

This means that it is (currently) possible to run googler v4.3.2 without WSL/bash/Linux on Windows 10 (21H1). This was done successfully with both older copies of Python (3.7.9, 3.8.10), as well the latest Python 3.9.7 release.

Steps:

  1. Download and install Python for Windows.

  2. Download the googler "Source code" .zip file (e.g. googler-4.3.2.zip) from the current GitHub "Releases" page for the project. As of this writing, the latest release is 4.3.2 (January 2021).

  3. Unzip e.g. googler-4.3.2.zip and run the googler script (no extension) via Python ex.:

     python googler search terms
    

If the example above doesn't work, just specify the full path to python.exe and/or the googler script. Note that you can alias this example in something like a batch file:

ex. googler.bat

"C:\path\to\python.exe" "C:\path\to\googler" %*

googler (above) is the googler script itself (not a directory). You could then place the folder containing googler.bat in your Windows Path environment variables (likely under your System Path) and use googler like so:

googler search terms

A Minor Note On Terminals

  • Both cmd and PowerShell appeared to display colors, though I didn't try changing these or checking if they were correct.

  • Using the official Windows Terminal app had the added benefit of making the URLs returned clickable (through Ctrl + Left Click). They were opened in the default browser.