1. 程式人生 > >給 Mac 新增右鍵選單「使用 VSCode 開啟」

給 Mac 新增右鍵選單「使用 VSCode 開啟」

最終的實現效果是在檔案 / 資料夾上右擊時,會出現選單項「用 VSCode 開啟」,點選後會啟動 Visual Studio Code 開啟對應的檔案 / 資料夾。 ![](https://img2020.cnblogs.com/other/86632/202010/86632-20201029200752436-1442928035.png) ## 實現步驟 1. 開啟「自動操作.app」,就是小機器人圖示那個; ![](https://img2020.cnblogs.com/other/86632/202010/86632-20201029200752711-1365491923.png) 2. command + n 新建文稿,在「選取文稿型別」裡選擇「快速操作」; ![](https://img2020.cnblogs.com/other/86632/202010/86632-20201029200753009-1261403006.png) 3. 按以下步驟操作: 第五步貼入程式碼 ```sh for f in "$@" do open -a "Visual Studio Code" "$f" done ``` ![](https://img2020.cnblogs.com/other/86632/202010/86632-20201029200753468-1067445439.png) 以上程式碼片段的大概意思是對於傳入的一個或多個引數,都使用 Visual Studio Code 這個 APP 開啟(將以下步驟配置完成後,可以分別選中一個、多個檔案 / 資料夾,然後右鍵用 VSCode 開啟看看效果)。 4. command + s
儲存為 「用 VSCode 開啟」: ![](https://img2020.cnblogs.com/other/86632/202010/86632-20201029200753691-1744076603.png) 5. 好了,現在試試在 Finder 裡右鍵一個檔案,就可以直接看到「用 VSCode 開啟」選單,右鍵一個資料夾,就可以看到「服務」-「用 VSCode 開啟」選單了。 ![](https://img2020.cnblogs.com/other/86632/202010/86632-20201029200753910-991572960.png) 愉快地使用 Visual Studio Code 和各種檔案、資料夾玩耍吧。 ## 編輯 以後如果想修改上面這個快速操作,有兩種方法: 1. 可以開啟「自動操作.app」,然後「檔案」-「開啟最近使用」 -「用 VSCode 開啟.workflow」; 2. 如果找不到這個操作,可以「檔案」-「開啟」-個人目錄 / 資源庫 / Services / 用 VSCode 開啟.workflow ![](https://img2020.cnblogs.com/other/86632/202010/86632-20201029200754243-920718530.png) 如果個人目錄下不顯示「資源庫」,按 Command + Shift + .
。 ## 參考 -