Skip to content

Instantly share code, notes, and snippets.

@HotFusionMan
Last active July 26, 2016 08:28
Show Gist options
  • Save HotFusionMan/16ad82b946961efc9e73 to your computer and use it in GitHub Desktop.
Save HotFusionMan/16ad82b946961efc9e73 to your computer and use it in GitHub Desktop.
# For inclusion into a Rails config/initializers/better_errors.rb file.
if defined?(BetterErrors)
if ENV['DEV_PROFILING'] == 'true' || ENV['DEV_DISABLE_ERRORS'] == 'true'
Rails.configuration.middleware.delete( BetterErrors::Middleware )
end
BETTER_ERRORS_EDITORS = { 'x-mine:' => "x-mine://open?file=%{file}&line=%{line}", 'sublime:' => :sublime, 'txmt:' => :textmate, 'emacs:' => :emacs, 'mvim:' => :macvim }
if RUBY_PLATFORM.index( 'darwin' )
unless ENV['BETTER_ERRORS_EDITOR'].blank?
# use `export BETTER_ERRORS_EDITOR='the-url-scheme'` to set which editor you want to use
BetterErrors.editor = BETTER_ERRORS_EDITORS[ENV['BETTER_ERRORS_EDITOR']]
else
url_schemes = `/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep bindings:.*:`
BETTER_ERRORS_EDITORS.each do |key, value|
if url_schemes.index(key)
BetterErrors.editor = value
break
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment