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

如何在Alacritty中实现点击打开文件的功能?

在Alacritty中实现Cmd+点击打开文件(MacOS v14.3.1 + Alacritty v0.13.1)

完全可以实现,步骤如下:

  1. 配置VSCode命令行工具
    打开VSCode,调出命令面板(Cmd+Shift+P),执行Shell Command: Install 'code' command in PATH,确保终端能直接调用code命令打开文件。

  2. 修改Alacritty配置文件
    打开Alacritty的默认配置文件(路径为~/.config/alacritty/alacritty.toml),添加以下配置:

[url]
# 用code命令打开匹配到的文件路径
launcher = ["code"]

# 匹配带行号、列号的文件路径(比如 /test/file.spec.js:25:10)
[[url.matchers]]
regex = r"(\/[\w\/\.-]+):(\d+):?(\d+)?"
format = "file://{0}:{1}:{2}"
priority = 1

# 匹配不带行号的纯文件路径(比如 /test/file.spec.js)
[[url.matchers]]
regex = r"(\/[\w\/\.-]+\.\w+)"
format = "file://{0}"
priority = 2
  1. 重启Alacritty生效
    保存配置后重启Alacritty,现在Cmd+点击终端里的文件路径(无论带不带行号),就能直接在VSCode中打开对应文件;带行号的路径还会自动跳转到指定行位。

如果不想用code命令,也可以把launcher改成["open", "-a", "Visual Studio Code"],效果一致。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 23:47:18