在 macOS Finder 中添加“在 VS Code 中打开”图标

假设我在 Finder 中,打开一个文件夹,并且想要在 VS Code 中打开它。 我该怎么做呢?通常情况下,我会转到上一级文件夹,拖动该文件夹并将其放入 Dock 中的 VS Code 图标中。 或者我会转到终端并输入 code . 但是,今天我花费了一些时间,让这个过程变得更容易,通过在 Finder 工具栏中添加一个按钮: 下面是你也可以这样做的方法。 打开 Automator,选择“应用程序” 在动作列表中搜索“运行 Shell 脚本”,并粘贴以下两行: finderPath=`osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)'` open -n -a "Visual Studio Code" --args "$finderPath" 如果你愿意,你也可以使用应用程序的 Bundle ID: finderPath=`osascript -e 'tell application "Finder" to get the POSIX path of (target of front window as alias)'` open -n -b "com....

如何在 macOS Finder 中添加「在終端機中打開」圖示

假設我在 Finder 中打開了一個資料夾,而我想要在終端機中打開它。 為了讓這個操作更加方便,我決定在 Finder 中添加一個「在終端機中打開」圖示: 下面是如何實現這一點的方法。 首先打開 Automator,選擇「應用程式」。 在操作列表中搜索「執行 AppleScript」,然後粘貼以下內容: on run {input, parameters} tell application "Finder" set myPath to (POSIX path of (target of front window as alias)) end tell tell application "Terminal" do script "cd " & myPath activate end tell return input end run 如果你更喜歡使用「執行 Shell 腳本」,可以使用以下 Bash 腳本: osascript -e ' tell application "Finder" set myPath to (POSIX path of (target of front window as alias)) end tell tell application "Terminal" do script "cd " & myPath activate end tell ' 第一個腳本運行的是 osascript(這是一個運行 AppleScript 的腳本),內容如下:...