I already talked about how to add a function to launch the IDE to the contact menu. I'll tell you again, but about VS Code.
Setting up the option occurs in two stages: setting a command for the terminal and creating automation.
Installing a command in the terminal
Open VS Code (in my case it's VS Code Insiders), press CMD+SHIFT+P
and type Shell
in the search.
Select the "Install command" option.
Now you can call the code
or code-insiders
command from the terminal to launch VS Code. The second parameter is the path to the directory we want to open.
$ code ~/dev/awesome-project
Creating an item in the context menu
Open the Automator application.
Create "New Document" and select "Quick Action" type.
Set Workflow receive current "folders".
Find and add a "Run Shell Script" step from the left list.
At the right top corner or step change Path input to "as arguments" value.
After entering the command, you need to write the command itself that will be called and the argument.
It wasn't enough for me to specify code-insiders $1
. Because the launch gave an error that it could not find the command itself. Therefore, first we find the full path to the command in the terminal using whereis
.
talyguryn@mac ~ % whereis code-insiders
code-insiders: /usr/local/bin/code-insiders
In my case, the team became like this.
Now all that remains is to save this action and give it a clear name.
Final result
Now you can open any directory directly in the editor in two clicks. Thanks for reading.