-
Notifications
You must be signed in to change notification settings - Fork 436
Link to your editor
Better Errors includes a link to the source code when you're looking at any exception.

By default, your EDITOR environment variable is used to determine which editing application you prefer.
If you haven't set EDITOR, that would be a good first step for making development easier.
Some editors require you to take steps to install their command-line tool, and then you'll need to modify your ~/.bashrc (stock macOS) or ~/.zshconfig (if you use ZSH).
If you are using Pow, a tool for managing multiple web applications on Mac, see these instructions to configure Pow.
If you are using Vagrant, Docker, or another virtualization mechanism, you may need to configure it to have the correct location of the source files on your machine. See Running on virtual machines.
You can configure your Ruby project to force Better Errors to link to a specific editor, but this is not recommended, since each developer on your project may prefer a different editor.
If you want to do this even though it is not recommended, in a Rails project, place this in config/environments/development.rb:
if defined? BetterErrors
# Force all developers on this project to use Textmate, even if they prefer something else.
BetterErrors.editor = :txmt
endor if you are using an editor that is not supported directly by Better Errors, you can use:
if defined? BetterErrors
# Force all developers on this project to use VS Code, even if they prefer something else.
BetterErrors.editor = "vscode://open?url=file://%{file}&line=%{line}"
endBetter Errors supports the following editors:
This is enabled if $EDITOR contains "emacs".
The URL is emacs://open?url=file://%{file}&line=%{line}.
You'll need to register the emacs:// protocol in Firefox.
Also, Firefox will pass a lot of junk to the command, here's a suggestion for your bin/ folder: https://gist.github.com/nofxx/6987409
This is enabled if $EDITOR contains "idea".
The URL is idea://open?file=%{file}&line=%{line}.
This is enabled if $EDITOR contains "vim".
The URL is mvim://open?url=file://%{file}&line=%{line}.
Instructions are in phallstrom/urlscheme_vim_in_iterm.
This is enabled if $EDITOR contains "rubymine".
The URL is rubymine://open?file=%{file}&line=%{line}.
This is enabled if $EDITOR contains "subl".
The URL is subl://open?url=file://%{file}&line=%{line}.
You'll need to install subl handler or something similar.
If you installed a sublime URL handler before August 2017, please see this security advisory and remove your old URL handler.
Add the following to your shell config:
export EDITOR="subl -w"(The -w causes the command line tool to wait until you close the file before it continues.
This is necessary for tools like git, where it must wait for you to edit the file before continuing.)
This is enabled by default, or if $EDITOR contains "mate".
The URL is txmt://open?url=file://%{file}&line=%{line}.
Add the following to your shell config:
export EDITOR="mate -w"(The -w causes the command line tool to wait until you close the file before it continues.
This is necessary for tools like git, where it must wait for you to edit the file before continuing.)
Support for these should be added to Better Errors soon.
Atom 1.23 (currently in beta) added support for open/file URLs. At the current time though, it has not been released so support has not been added directly to Better Errors.
In the meantime, add the following to config/environments/development.rb:
if defined? BetterErrors && ENV['EDITOR'].include?('atom')
BetterErrors.editor = proc { |file, line|
"atom://core/open/file?filename=#{CGI.escape(file)}&line=#{line-1}"
}
endInstall the Shell Commands from within Atom and add the following to your shell config:
export EDITOR="atom"(If you're using the beta version of Atom, that will need to be atom-beta instead of atom.)
Atom v1.22 added support for packages to perform URI Handling
You'll need to add the open package to Atom and add the following to config/environments/development.rb:
if defined? BetterErrors && ENV['EDITOR'].include?('atom')
BetterErrors.editor='atom://open?url=file://%{file}&line=%{line}'
endInstall the Shell Commands from within Atom and add the following to your shell config:
export EDITOR="atom"Unfortunately there is no way for a project to support URLs for both 1.23 and older versions at the same time.
You'll need to install the vscode-handler extension and add the following to config/environments/development.rb:
if defined? BetterErrors && ENV['EDITOR'].include?('code')
BetterErrors.editor = "vscode://open?url=file://%{file}&line=%{line}"
endInstall the command-line tools and add the following to your shell config:
export EDITOR="code"