Command line linking?

by Bob DuCharme



Try this: open up Mozilla's Bookmark Manager (Bookmarks, Manage Bookmarks), right-click a bookmark, and pick Properties. Adding a short string to the Keyword field will let you go directly to that URL by entering that keyword in Mozilla's navigation bar. I had known about this for a while, but hadn't done much more than just play with it—typing "www.whatever.com" didn't seem like that much trouble to me.



Then I found out about Mozilla keymarks. Now try this: do a search for a particular word in Google, and then bookmark the result. In the bookmark's properties dialog box, enter "g" as the keyword. Then, in the URL shown in the same dialog box's Location field, replace the search term that you entered with "%s" so that it looks something like this (if you like, just replace the whole URL with what I have here):




http://www.google.com/search?q=%s


Once this is saved, you can enter a Google search query after the "g" keyword and the search will be executed. You can add multi-word searches, quotation marks, and specialized parameters like site:. The following examples all worked just as I expected:




g site:w3.org emacs
g "bob quine" OR "robert quine"
g "dave thomas" -wendy's


Now the Navigation bar feels like a command line to me. I no longer need the one-field form I have on my browser's default home page, which does a Google search. I can jump to the Navigation bar by just pressing ^L, making it even quicker to link this way. And, I've created several new "commands" by assigning the following keywords to the following URLs:













































keywordto searchURL
g Google http://www.google.com/search?q=%s
dict the dictionary http://dictionary.reference.com/search?q=%s
thes the thesaurus http://thesaurus.reference.com/search?q=%s
gnews Google news http://news.google.com/news?q=%s
bbcnews BBC news http://www.bbc.co.uk/cgi-bin/search/results.pl?tab=news&q=%s
imdb Internet Movie Database http://www.imdb.com/find?tt=on;nm=on;mx=20;q=%s
imdbname Internet Movie Database (name search) http://www.imdb.com/find?nm=on;mx=20;q=%s
imdbtitle Internet Movie Database (title search) http://www.imdb.com/find?tt=on;mx=20;q=%s

Note how the last three keywords all point to roughly the same URL. The last, imdbtitle, searches only movie titles, and imdbname searches only names. (Compare the results of "imdbname ed wood" and "imdbtitle ed wood".) Different keywords do slightly different things there; it's like having different commands to achieve different results.



(As "command line linking" goes, it is possible to add a URL to the command line when you start up Mozilla from the shell, sending the browser right to that URL. In Windows, this opens up a new window each time you do it, and in Linux, it gives you the "Select User Profile" dialog box, both of which I'd rather avoid.)



Now that I think of it, a script that performs a true command-line version of this to retrieve a resource from within a shell would be easy enough to write. It would:




  1. Check the first parameter passed to it, and see whether it was g, imdb, bbcweb, or one of the other keywords it was configured to recognize


  2. Store the remaining parameters in one big string


  3. Map the keyword to the appropriate URL


  4. Substitute the saved string of parameters for the %s in the URL


  5. Call wget or curl with that URL.




Of course, this would pull the retrieved resource to standard out or to a disk file; if you want it displayed in a browser, do the Navigation Bar "command line" trick describ. This scripted wget way, though, can offer some interesting ways to work with RESTful applications, especially if the output really does go to standard out and can be piped to processes that use that data as input.




Has anyone else developed a dependency on this?


7 Comments

brianiac
2004-08-03 21:42:23
Here are the ones I use
g     Google Search           http://www.google.com/search?q=%s
gl Google Lucky Search http://www.google.com/search?btnI=1&q=%s
gp Google Phonebook Search http://www.google.com/search?btnI=1&q=phonebook:%s
gi Google Image Search http://images.google.com/images?q=%s
gn Google News Search http://news.google.com/news?q=%s
gg Google Groups Search http://groups.google.com/groups?q=%s
gq Google Quote Search http://www.google.com/search?q=%s&cat=gwd%2FTop%2FReference%2FQuotations
gw Google Wikipedia Search http://www.google.com/search?q=site:en.wikipedia.org+%s
gm Google Microsoft Search http://www.google.com/microsoft?q=%s
w Google Wikipedia Lucky http://www.google.com/search?btnI=1&q=site:en.wikipedia.org+%s
wq Google Wikiquote Search http://www.google.com/search?q=site:quote.wikipedia.org+%s
bbc BBC Search http://newssearch.bbc.co.uk/cgi-bin/results.pl?tab=news&scope=newsukfs&q=%s
d OneLook Search http://www.onelook.com/?ls=a&w=%s
dd Dictionary.com Search http://dictionary.reference.com/search?q=%s
t Thesaurus.com Search http://www.thesaurus.com/cgi-bin/search?config=roget&words=%s
dm dmoz Search http://search.dmoz.org/cgi-bin/search?search=%s
p PriceGrabber Search http://www.pricegrabber.com/search_noresults.php?form_keyword=%s
a Amazon Search http://www.amazon.com/exec/obidos/external-search/103-9778076-0791008?field-keywords=%s&index=blended&tag=edazzlenet-20
by Buy.com Search http://www.buy.com/retail/searchresults.asp?qu=%s
sf SourceForge Search http://sourceforge.net/search/?exact=1&words=%s
sfp SourceForge Project http://www.sourceforge.net/projects/%s
bz Bugzilla Search http://bugzilla.mozilla.org/buglist.cgi?query_format=&short_desc_type=allwordssubstr&short_desc=%s&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&changedin=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=
bzf Bugzilla Firefox Search http://bugzilla.mozilla.org/buglist.cgi?query_format=&short_desc_type=allwordssubstr&short_desc=%s&product=Firebird&long_desc_type=substring&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&status_whiteboard_type=allwordssubstr&status_whiteboard=&keywords_type=allwords&keywords=&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&emailassigned_to1=1&emailtype1=exact&email1=&emailassigned_to2=1&emailreporter2=1&emailqa_contact2=1&emailtype2=exact&email2=&bugidtype=include&bug_id=&votes=&changedin=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=
msdn MSDN Search http://search.microsoft.com/search/results.aspx?View=msdn&st=a&qu=%s&c=0&s=1
ws Wikipedia Search http://www.wikipedia.org/w/wiki.phtml?search=%s
ext FilExt Search http://www.filext.com/detaillist.php?extdetail=%s
reg WinGuides.com Search http://www.winguides.com/search.php?keywords=%s&mode=and&target=all&hits=25&guide=registry
past Wayback Machine Lookup http://web.archive.org/web/*/http://%s
anon Anonymizer http://anon.free.anonymizer.com/http://%s
imdb IMDB Search http://www.imdb.com/Find?for=%s&select=All
ipdb IPDB Search http://www.ipdb.org/search.pl?any=%s&searchtype=quick
c .com Shortcut http://www.%s.com/
o .org Shortcut http://www.%s.org/
n .net Shortcut http://www.%s.net/

Note: those last three are less useful in Firefox, since the Ctrl+Enter, Ctrl+Shift+Enter, and Shift+Alt+Enter do the same thing faster now.

Another consideration: keywords with parameters can be used for bookmarklets, too, making the address bar even more like a command-line.

sideshowbarker.net
2004-08-04 02:18:32
NeedleSearch
I use sideshowbarker.net
2004-08-04 02:20:28
Oops
I meant to say I use NeedleSearch. (forget a closing quotation
mark in the link markup...)
otto
2004-08-04 03:43:59
SafariKeywords
Just in case your favourite browser is Safari, check out SafariKeywords .
andrewgwhite
2004-08-04 07:43:56
Lazy Calculator
I used to use google's new calculator all the time, but opening new tabs become a PITA. So I made myself a bookmark with keyword "expr" that pops up whatever argument i pass directly in an alert.


javascript:alert(%s);


Anyone know if its possible to write that value to the clipboard?

aufrank
2004-08-04 17:31:32
command line url in linux without switching profile
"(As 'command line linking' goes, it is possible to add a URL to the command line when you start up Mozilla from the shell, sending the browser right to that URL. In Windows, this opens up a new window each time you do it, and in Linux, it gives you the "Select User Profile" dialog box, both of which I'd rather avoid.)"


I recently grabbed a great applet for GNOME call MailNotification (http://www.nongnu.org/mailnotify) which will check the status of your gmail inbox. I yearned to have gmail open in a new window if firefox was not already running, or in a new tab if it was. I got halfway there (and to do this without the above mentioned "change profile" dialog). The following command will open gmail in a new tab (without the "change profile" dialog), as long as firefox is already running:


mozilla -a firefox -remote 'openURL(http://www.gmail.com/,new-tab)'


Having figured that out, I set my browser preferences in gaim to run this command:



mozilla -a firefox -remote 'openURL(%s,new-tab)'


Again, works to open a new tab as long as firefox is already running.


If anyone can get a single command that will open a new window when no instance is running, and a new tab when there is an instance running, I'd love to hear about it.


/au


(the above command works for firefox 9.1)

krider
2004-08-05 06:34:33
command line url in linux without switching profile
The http://www.wlug.org.nz/MozillaFirefoxNotes site provides some scripts for Linux for querying Firefox so it knows whether to run it or use a new tab.


Really useful, and I've used it for a few Firefox versions now (the script has evolved to be a lot cleaner in that time!).


Hope that helps :-)