Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support url handlers to open files from url #2514

Open
a7madgamal opened this issue Dec 10, 2018 · 9 comments
Open

support url handlers to open files from url #2514

a7madgamal opened this issue Dec 10, 2018 · 9 comments

Comments

@a7madgamal
Copy link

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

@a7madgamal
Copy link
Author

still no updates? :(

@rwols
Copy link

rwols commented Aug 23, 2020

What kind of problems does a custom scheme solve?

@a7madgamal
Copy link
Author

a7madgamal commented Aug 23, 2020

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

@rwols
Copy link

rwols commented Aug 23, 2020

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.

@a7madgamal
Copy link
Author

a7madgamal commented Aug 23, 2020 via email

@a7madgamal
Copy link
Author

@rwols sorry I didn't get your answer. any updates on this topic since then?

@silverwind
Copy link

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.

@titoBouzout
Copy link
Collaborator

titoBouzout commented Apr 20, 2024

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 :/

@titoBouzout
Copy link
Collaborator

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants