Created
September 16, 2013 21:10
-
-
Save mishak87/6586662 to your computer and use it in GitHub Desktop.
Nette tool to ease up pain from errors (bind to editor: protocol via reg)
PHPStorm and with fallback to Sublime Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REGEDIT4 | |
[HKEY_CLASSES_ROOT\editor] | |
@="URL:editor Protocol" | |
"URL Protocol"="" | |
[HKEY_CLASSES_ROOT\editor\shell\open\command] | |
@="wscript \"C:\\bin\\scripts\\run-editor.js\" \"%1\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NetBeans | |
// var editor = '"C:\\Program Files\\NetBeans 7.0\\bin\\netbeans.exe" "%file%:%line%" --console suppress --nosplash'; | |
// PhpStorm | |
//~ var phpStorm = '"C:\\Program Files (x86)\\JetBrains\\PhpStorm 6.0.3\\bin\\PhpStorm.exe" --line %line% "%file%"'; | |
var phpStorm = '"C:\\Program Files (x86)\\JetBrains\\PhpStorm 131.98\\bin\\PhpStorm.exe" --line %line% "%file%"'; | |
// jEdit | |
//~ var editor = '"C:\\Program Files (x86)\\jEdit\\jedit.exe" "%file%" +line:%line% -reuseview'; | |
// PHPEd | |
//~ var editor = '"C:\\Program Files\\NuSphere\\PhpED\\phped.exe" "%file%" --line=%line%'; | |
// SciTE | |
var editor = '"C:\\Program Files\\Sublime Text 3\\sublime_text.exe" "%file%":%line%'; | |
// EmEditor | |
//~ var editor = '"C:\\Program Files\\EmEditor\\EmEditor.exe" "%file%" /l %line%'; | |
// PSPad Editor | |
//~ var editor = '"C:\\Program Files\\PSPad editor\\PSPad.exe" -%line% "%file%"'; | |
// gVim | |
//~ var editor = '"C:\\Program Files\\Vim\\vim73\\gvim.exe" "%file%" +%line%'; | |
// Sublime Text 2" | |
//~ var editor = 'C:\\Program Files\\Sublime Text 2\\sublime_text.exe "%file%":%line%'; | |
var match = /^editor:\/\/open\/\?file=(.+)&line=(\d+)$/.exec(WScript.Arguments(0)); | |
if (match) { | |
var file = decodeURIComponent(match[1]).replace(/\+/g, ' '); | |
var translate = { | |
'/home/mishak/sites/net.mishak.sih': 'c:/users/mishak/projects/shit-is-happening.local' | |
}; | |
for (var x in translate) { | |
if (file.indexOf(x) === 0) { | |
file = file.replace(x, translate[x]); | |
} | |
} | |
file = file.replace(/\//g, '\\'); | |
var slugs = file.split('\\'); | |
var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
slugs.pop(); | |
while (slugs.length > 2) { | |
if (fso.FolderExists(slugs.join('\\') + '\\.idea')) { | |
editor = phpStorm; | |
break; | |
} | |
slugs.pop(); | |
} | |
var command = editor.replace(/%line%/g, match[2]).replace(/%file%/g, file); | |
var shell = new ActiveXObject("WScript.Shell"); | |
shell.Exec(command.replace(/\\/g, '\\\\')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment