Ubuntu有一个Ubuntu 的解决方案 https://askubuntu.com/questions/527166/how-to-set-subl-protocol-handler-with-unity
视窗法
您首先必须在 Windows 注册表中安装协议处理程序。
(参考:Chrome 中的自定义协议处理程序 https://stackoverflow.com/questions/7087728/custom-protocol-handler-in-chrome)
这将使 Chrome 在以下情况下运行命令:subl:path/to/file
链接被点击。
但你不能简单地跑步sublime_text.exe subl:path/to/file
,因为 Sublime 不理解subl:path/to/file
范围。您首先必须使用脚本提取文件名,然后使用单个文件参数调用 Sublime。
解决方案1
This https://github.com/ljubadr/sublime-protocol-win是 Windows 的解决方案,可打开以下格式的链接
subl://open?url=file://<path_to_file>&line=4
它首先注册一个脚本作为协议处理程序,然后调用 Sublime
解决方案2
我编辑了解决方案 1 以打开以下格式的链接
subl://path/to/file:line
只需遵循解决方案 1,但进行更改open_file.vbs
to:
' path to sublime_text.exe
Dim sublime_path
' CHANGE THIS:
sublime_path = "C:\Programme\Sublime Text 3\sublime_text.exe"
Dim text, filename
' get first command line argument
text = WScript.Arguments.Item(0)
filename = Split(text, ":/")(1)
Dim run_command
run_command = """"&sublime_path&""" """&filename&""""
Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run(run_command)
Set objShell = Nothing
(您必须更改 sublime_text.exe 的路径)
Mac
https://github.com/corysimmons/subl-handler https://github.com/corysimmons/subl-handler