Skip to content

Instantly share code, notes, and snippets.

@c80609a
Created March 22, 2019 19:02
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 c80609a/752e566093b1489bd3aef0e56ee0426c to your computer and use it in GitHub Desktop.
Save c80609a/752e566093b1489bd3aef0e56ee0426c to your computer and use it in GitHub Desktop.
xdg-mime, Ubuntu 18.04, RubyMine-2018.2, Gnome, BetterErrors

Make files, do chmod +x, modify existing files; RubyMine -> tools -> create command line launcher.

Execute:

xdg-mime default rubymine.desktop x-scheme-handler/rubymine

Check output:

xdg-mime query default x-scheme-handler/rubymine
# /home/scout/git/get-the-boat/config/initializers/better_errors.rb
if defined?(BetterErrors)
BetterErrors.editor = "rubymine://open?file=%{file}&line=%{line}" # same same as into /home/scout/.local/bin/mine-open.sh
end
#!/usr/bin/env ruby
#encoding: UTF-8
# /home/scout/.local/bin/mine-open.sh
#script opens URL in format `rubymine://open?file=%{file}&line=%{line}` in RubyMine
require 'uri'
url = ARGV.first
/file=(?<file>.+)&line=(?<line>\d+)/ =~ url # same same as into initializers/better_errors.rb
file_arg = URI.unescape(file)
line_arg = line ? ":#{line}" : ""
cmd = "mine #{file_arg}#{line_arg}"
`#{cmd}`
# ~/.local/share/applications/
[MIME Cache]
x-scheme-handler/rubymine=rubymine.desktop;
# ~/.local/share/applications/rubymine.desktop
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Exec=/home/scout/.local/bin/mine-open.sh %u
MimeType=x-scheme-handler/rubymine;
Name=Rubymine
Comment=BetterErrors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment