-
Notifications
You must be signed in to change notification settings - Fork 96
Custom Prefix Configuration (Ubuntu, Sublime, and Firefox)
In order to open links with a custom prefix in Firefox (tested on Ubuntu), a few things must be configured.
.metrics
should have the prefix set:
MetricFu::Configuration.run do |config|
config.templates_configuration do |tc|
tc.link_prefix = 'sublime:/'
end
end
This will append a prefix of sublime:///
when you click any of the file links.
Most likely Firefox won't know what to do with this sublime:///
protocol. It'll probably say something a long the lines of: The address wasn't understood
.
- In your url bar go to:
about:config
- Right click somewhere and select
new
in the context menu and selectboolean
- Preference name should be
network.protocol-handler.expose.sublime
- Value should be set to
false
Now that you've added this custom protocol, next time you click a link with sublime:///
it will ask you what application to launch it with.
However, selecting Sublime won't work because it will try to read it from the sublime:///
location. So we need to write a script to strip out the protocol and then open it in Sublime.
Create a new subl-urlhandler.desktop
file inside /usr/share/applications
.
[Desktop Entry]
Version=1.0
Name=Sublime Text 2
Exec=/usr/bin/subl-urlhandler %u
Icon=sublime_text
Terminal=false
Type=Application
Categories=Development;
StartupNotify=true
MimeType=x-scheme-handler/subl;
When Firefox asks us what application we want to launch when using the sublime:
protocol, we can select subl-urlhandler
by browsing /usr/bin/applications
.
Now we need to configure the actual script.
Create /usr/bin/subl-urlhandler
:
#!/bin/bash
# /usr/bin/subl-urlhandler
request=${1:10} # Delete the first 10 characters
# Launch sublime
subl $request # Launch ST2
We just need to remove sublime://
, which is the first 10 characters. Replace subl
if you have it configured to use sublime
.
Now run metric_fu
in your terminal, go to a section and click a file link. Firefox will ask you what you want to launch the application with, browse
and go to /usr/bin/applications/subl-urlhandler.desktop
.
- MozillaZine: Register Protocol - Registering a protocol in Firefox
- Gist: Using Sublime Text 2 with better_errors on Ubuntu - Referenced this script that was originally configured to be used with better_errors