macosapplescripteditor

Mac OS. How to open the project in VS code via right click on folder in finder


How can I right click on a project folder and open in VS code or another editor via the context menu? The question had a post on stack before which I referred to for previous computer setups but seems to have since been deleted. Thanks!


Solution

  • I figured it out.

    Open up Automator. ( It comes standard in osx ). It'll promp you to select a type. Click on Quick action. Now select Folders in finder. In the search bar, search for Apple Script, and drag and drop it into the screen on the right. Next, type in the applescript to match the photo.

    on run {input, parameters}    
        tell application "Visual Studio Code"        
            activate        
            open (first item of input) as text    
        end tell
    end run
    

    Save it and call it whatever you like. I named it 'Open in VS Code'. I believe what you name it is how it will appear. you can also choose your own icon.

    Entirely optional but you can also create your own hotkey binding if you like by going to System Settings/Preferences > Keyboard > Keyboard Shortcuts > Services > Files and Folders > and ensuring that 'Open in VS Code' is checked. then to assign a key binding, click on the none to the right and type in your key binding.

    Now right click on any project folder, click on quick actions. and enjoy your new Shortcut!