在我的 windows 电脑上,我只需要双击一个文件夹,然后点击“打开 VS 代码”就可以打开一个文件夹,这为我在网上查看大量代码节省了时间。然而,对于 Mac,我没有这个选择。我必须直接打开 vscode 并单击“打开”来打开一个新文件夹。如何通过 macOS 中的 finder 直接在 vscode 中打开文件?
Tbh. I would have expected to be able to use just code -n "$*", but for some reason, the PATH used by the automator's shell seems to be different from that used in the terminal. I'd welcome some input on that matter.
在新添加的名为“ Run Shell Script”的操作中,编写“ code”并右键单击以获得下面的弹出框,继续“ Insert variable”,然后“ Shortcut Input”。
Click on the ‘Shortcut Input’ tag that appears. A pop must appear, choose ‘File Path’ and just click anywhere else. This will change the tag to ‘File Path’.
该脚本将允许您在 VSCode 中打开当前文件夹路径。
The steps to do so are:
使用 Automator 创建新的应用程序
Select the "Run shell script" from the menu and drag it to the editor
将下面的小脚本粘贴到文本区域:
finderPath=`osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)'`
open -n -b "com.microsoft.VSCode" --args "$finderPath"
将应用程序保存到 申请表文件夹
Right click the app and drag and drop your desired VSCode icon to the blank area to the left of the name and close the 去找信息 window