Sublime Forum

Handling URLs with Sublime Text

#1

Now that we have an Ubuntu package, would it be possible to configure it so that we can open URLs from our browser in Sublime?

This requires modifying /usr/share/applications/sublime_text.desktop to including something like this:

[Desktop Entry]
Name=sublime
Comment=Sublime Text URI scheme subl:// handler
Exec=/opt/sublime_text/sublime_text --url %u
Terminal=0
Type=Application
X-MultipleArgs=True
MimeType=x-scheme-handler/subl
Encoding=UTF-8
Categories=Application;

And then updating sublime_text to support these URLs, with something like this:

if [[ "${1:0:7}" = "subl://" ]]; then
    file=${1:23}
    file=${file//%2F//}
    file=${file/&line=/:}
    file=${file/&column=/:}
fi
3 Likes