url2firefox

After my recent desktop upgrade, I decided to finally get everything working together so that URLs in GNOME Terminal and XEmacs would open up new tabs in Firefox.

I found inspiration from a hack called Making Firefox Behave Like Galeon. After cleaning the example up a bit, it became url2firefox:

  #!/bin/bash

  FF_LIB=/opt/firefox1.0

  # get URL to load
  url=$1; [ -z $url ] && url=about:blank
  what=$2;

  if [ -z $what ]; then
        $FF_LIB/mozilla-xremote-client -a firefox \
                openURL\($url\,new-tab\) && exit 0
  else
        $FF_LIB/mozilla-xremote-client -a firefox \
                openURL\($url\,$what\) && exit 0
  fi

  # if xremote failed, then launch the browser
  exec $FF_LIB/firefox $url &

I then set url2firefox as the Custom Web Browser Command in the Preferences -> Preferred Applications dialog and as vm-url-browser in my XEmacs .vm file. Now I can right click on URLs in Terminal and select Open Link or middle click on URLs in VM in XEmacs and it will open a new tab with that URL.

One other thing I did was to add a set nomarkers to my .muttrc so long urls would not be wrapped with + when they hit the edge of the terminal.

Friday April 1, 2005   ·   Permalink