I would like to run a single terminal command to open a Firefox (my default browser) and perform a search. For example:
$ firefox lord of the rings
would open a new Firefox tab and search the term "lord of the rings". Similarly:
$ firefox https://amazon.com
would open a new Firefox tab and load amazon.com.
I know that I can run the command:
$ open -a firefox <url>
But this does not work with search queries (only urls). Any tips on how to accomplish this are appreciated.
Firefox on it's own does not query/search the web. You search by using a website that has search capabilities like google.com or bing.com ... so you can simply open a bing.com URL with urlencoded search string.. which will open firefox with the results:
Example:
firefox 'https://www.bing.com/search?q=lord+of+the+rings'