Skip to content

Instantly share code, notes, and snippets.

Forked from stevenpetryk/
Last active December 12, 2015 09:09
Show Gist options
  • Save wojtha/4749450 to your computer and use it in GitHub Desktop.
Save wojtha/4749450 to your computer and use it in GitHub Desktop.

Using better_errors on Ubuntu with SublimeText 2

After I installed the fantastic better_errors gem, I was disappointed to notice that linking to your text editor doesn't work correctly on Ubuntu (at least, it didn't for me). Here's how I fixed it.

First, create a new desktop entry:

# /usr/share/applications/subl-urlhandler.desktop

[Desktop Entry]
Name=Sublime Text 2
Name[en_PH]=Sublime Text 2
Exec=/usr/bin/subl-urlhandler %u

Next, let's create the script we're linking to.

# /usr/bin/subl-urlhandler

request=${1:23}               # Delete the first 23 characters
request=${request//%2F//}     # Replace %2F with /
request=${request/&line=/:}   # Replace &line= with :
request=${request/&column=/:} # Replace &column= with :

# Launch sublime
sublime $request       # Launch ST2

Make the url handler executable: sudo chmod +x /usr/bin/subl-urlhandler.

Finally, reload your desktop files by running: sudo update-desktop-database.

Now you should be good to go! I hope this helped!

Copy link

Make sure you check if sublime is available as a command. On my machine I use subl $request to launch Sublime Text 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment