You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux下手动注册vscode:协议,实现通过链接打开VS Code

手动注册vscode:协议的方法

根据你使用的操作系统,按照以下步骤手动注册vscode:协议:

Linux系统

  1. 创建/修改VS Code桌面文件
    • 打开终端,创建或编辑VS Code的desktop文件:
      nano ~/.local/share/applications/code.desktop
      
    • 在文件中添加或更新以下内容(替换/path/to/your/code为你tarball解压后的VS Code可执行文件路径):
      [Desktop Entry]
      Name=Visual Studio Code
      Comment=Code Editing. Redefined.
      Exec=/path/to/your/code/code --open-url %u
      Icon=/path/to/your/code/resources/app/resources/linux/code.png
      Type=Application
      Terminal=false
      Categories=Development;IDE;
      MimeType=x-scheme-handler/vscode;
      
  2. 更新桌面数据库
    运行命令使修改生效:
    update-desktop-database ~/.local/share/applications/
    
  3. 绑定协议处理程序
    执行命令将vscode:协议关联到VS Code:
    xdg-mime default code.desktop x-scheme-handler/vscode
    

macOS系统

  1. 添加协议关联
    打开终端,运行以下命令(确保VS Code已解压到应用目录,例如/Applications/Visual Studio Code.app):
    defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType = "x-scheme-handler/vscode"; LSHandlerRoleAll = "com.microsoft.VSCode";}'
    
  2. 刷新LaunchServices缓存
    执行命令使修改立即生效:
    /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
    
    重启Firefox后即可测试跳转功能。

Windows系统

  1. 创建注册表导入文件
    新建文本文件并命名为vscode-protocol.reg,填入以下内容(替换C:\path\to\Code.exe为你tarball解压后的VS Code可执行文件路径):
    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\vscode]
    @="URL:vscode Protocol"
    "URL Protocol"=""
    
    [HKEY_CLASSES_ROOT\vscode\shell]
    @=""
    
    [HKEY_CLASSES_ROOT\vscode\shell\open]
    @=""
    
    [HKEY_CLASSES_ROOT\vscode\shell\open\command]
    @="\"C:\\path\\to\\Code.exe\" --open-url \"%1\""
    
  2. 导入注册表
    双击该vscode-protocol.reg文件,确认导入注册表即可。完成后重启Firefox测试跳转。

内容的提问来源于stack exchange,提问作者Robin Green

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 03:00:10