Skip to content

Instantly share code, notes, and snippets.

@gmgp
Last active February 27, 2018 08:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gmgp/f1b21ff3179b82183703f2825dcab838 to your computer and use it in GitHub Desktop.
Save gmgp/f1b21ff3179b82183703f2825dcab838 to your computer and use it in GitHub Desktop.
For subl:// links on Debian to open in Sublime-Text-3 (rails-footnotes, better-errors...)
# config/environments/development.rb
...
if defined? BetterErrors
# Force all developers on this project to use VS Code, even if they prefer something else.
BetterErrors.editor = proc { |file, line| "subl://#{file}:#{line}"}
end
#.local/share/applications/mimeapps.list
[Added Associations]
....
x-scheme-handler/subl=subl-urlhandler.desktop
# myapp/config/rails_footnotes.rb
# (~> 4.0)
...
# Change the prefix :
# f.prefix = 'mvim://open?url=file://%s&line=%d&column=%d'
f.prefix = 'subl://%s:%d:%d'
...
#/usr/share/applications/subl-urlhandler.desktop
[Desktop Entry]
Version=1.0
Name=Sublime Text 3
Name[en_PH]=Sublime Text 3
Exec=/usr/bin/xdebug-urlhandler %u
Icon=/opt/subl/Icon/48x48/sublime_text.png
Terminal=false
Type=Application
Categories=Development;
StartupNotify=true
MimeType=x-scheme-handler/subl;
#!/bin/bash
#/usr/bin/xdebug-urlhandler
# remember to chmod +x
url=${1:7}
# sanitize with only a-z A-Z 0-9 -_/.: chars
url=${echo $url | sed 's/[^a-zA-Z0-9-_\/\.\:]//g'}
subl $url
@gmgp
Copy link
Author

gmgp commented Feb 24, 2018

reminder:

  • sudo update-desktop-database
  • sudo chmod +x /usr/bin/xdebug-urlhandler

@gmgp
Copy link
Author

gmgp commented Feb 24, 2018

  # sanitize with only a-z A-Z 0-9 -_/.: chars
  url=$(echo $url | sed 's/[^a-zA-Z0-9-_\/\.\:]//g')

not perfect but something

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