sublime_text
sublime_text copied to clipboard
support url handlers to open files from url
Problem description
basically, support this nativly https://github.com/inopinatus/sublime_url why? because I made this https://github.com/a7madgamal/open_github_in_editor and I would love to add your amazing editor to the list of supported editors :D
I'm more interested in MacOs support but other OS are welcome I guess
Preferred solution
just adjust the installers to add the url handler
still no updates? :(
What kind of problems does a custom scheme solve?
I need a way to open a specific file and line number using a url-like format as I use for vscode and other editors
But do you need a custom scheme for this? Why can’t you use the over-arching script and/or environment to select the appropriate program? The subl executable already supports file:line:col syntax so I don’t see any problems with this. And if you’re choosing subl:// as the scheme then you’ve already iterated over the possible editors in your over-arching script I would think.
not sure what you mean by over-arching script but since my addon runs only in a browser I only have access to links not executables. if 'subl://filepath.ext:lineNumber' works then we have no issues here 😁 this is what we need exactly https://github.com/microsoft/vscode/issues/4883
On Mon, Aug 24, 2020, 12:53 AM Raoul Wols [email protected] wrote:
But do you need a custom scheme for this? Why can’t you use the over-arching script and/or environment to select the appropriate program? The subl executable already supports file:line:col syntax so I don’t see any problems with this. And if you’re choosing subl:// as the scheme then you’ve already iterated over the possible editors in your over-arching script I would think.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sublimehq/sublime_text/issues/2514#issuecomment-678835235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHFMUWSTWJFHAWNJXEBWSLSCGMWNANCNFSM4GJJ4Q6Q .
@rwols sorry I didn't get your answer. any updates on this topic since then?
An extension to this request is to support web links to clone a git repo directly into the editor as a new project. VS Code supports such a scheme:
vscode://vscode.git/clone?url=https://github.com/sublimehq/sublime_text
The url parameter should be url-encoded, I only decoded it for demonstrative purpose.
I was able to register subl as a protocol handler, but I couldn't get it to actually open a file, it opens c:/windows/system32/subl instead :/
I figured it out for windows
; sublime text protocol
[HKEY_CLASSES_ROOT\subl]
"URL Protocol"=""
[HKEY_CLASSES_ROOT\subl\shell\open\command]
@="\"D:\\Software\\portable\\Sublime Text\\sublime_text.exe\" --command \"open_file_from_url {\\\"url\\\": \\\"%1\\\"}\""
; pretend we are vscode
[HKEY_CLASSES_ROOT\vscode]
"URL Protocol"=""
[HKEY_CLASSES_ROOT\vscode\shell\open\command]
@="\"D:\\Software\\portable\\Sublime Text\\sublime_text.exe\" --command \"open_file_from_url {\\\"url\\\": \\\"%1\\\"}\""
then in the user folder add this command
import sublime_plugin
import sublime
import re
from urllib.parse import unquote
class OpenFileFromUrlCommand(sublime_plugin.WindowCommand):
def run(self, url):
url = unquote(re.sub(r"^(vscode|subl):(\/\/)?((file|open)\/)?", "", url))
self.window.open_file(url, sublime.ENCODED_POSITION)