在iterm中创build一个触发器,用匹配的参数打开一个应用程序
我有一个用例,当我在terminal上运行以下命令时 –
node --debug-brk --inspect Javascript.js
它以debugging模式运行node.js并输出一个可以在chrome中打开的url进行debugging –
➜ temp node --debug-brk --inspect Javascript.js Debugger listening on port 9229. Warning: This is an experimental feature and could change at any time. To start debugging, open the following URL in Chrome: chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/e7aae1e7-7952-41a4-9fe1-6bead23b791d
我创build了一个触发器chrome\-devtools.*$
在我的术语中,并将命令设置为
open -a "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \0
这样的URL自动打开铬,但可悲的是它不工作。
有两个重要的问题,你必须解决:
-
Chrome浏览器无法识别
chrome-devtools://...
作为通过cmd行parameter passing的有效URL,并尝试将其作为文件系统链接打开,从而导致失败 -
Chrome浏览器没有注册
chrome-devtools://
的URL Schemechrome-devtools://
与macOS操作系统,因此您无法open
它
iTerm触发器:
首先,注册chrome-devtools://
作为有效的URLscheme。 有几种方法可以做到这一点,这只是一个:
- 使用
LinCastor
( https://onflapp.wordpress.com/lincastor/ ),将chrome-devtools
注册为使用Chrome打开该模式的scheme:
其次,添加一个iTerm触发器来使用任何chrome\-devtools.*$
open
chrome\-devtools.*$
regex匹配:
iTerm智能select:
由于您已经注册了URLscheme,所以如果添加Smart Selection Rule
和该Smart Selection Rule
的操作,也可以通过在iTerm窗口中CMD-click
来打开它: