Skip to content

Instantly share code, notes, and snippets.

@Darkflib
Created November 13, 2023 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Darkflib/757e07ce43c7b271712ad66950959771 to your computer and use it in GitHub Desktop.
Save Darkflib/757e07ce43c7b271712ad66950959771 to your computer and use it in GitHub Desktop.
create a quick action to open in vscode

Adding a right-click option to open files or folders with Visual Studio Code (VSCode) on a Mac involves creating a service using Automator, a macOS tool for automating tasks. Here's a step-by-step guide to achieve this:

  1. Open Automator:

    • Go to your Applications folder and open Automator.
  2. Create a New Service:

    • In Automator, select File > New.
    • Choose Service or Quick Action (depending on your macOS version).
  3. Configure the Service:

    • At the top of the right pane, you'll find two drop-down menus.
    • Set the first one to files or folders and the second to Finder.
  4. Add a Run Shell Script Action:

    • In the search bar on the left, type Run Shell Script.
    • Drag the Run Shell Script action to the right pane.
    • In the Run Shell Script action, set Pass input to as arguments.
  5. Enter the Shell Script:

    • Type the following script in the text box:
      for f in "$@"
      do
          open -a "Visual Studio Code" "$f"
      done
    • This script will open each selected file or folder in VSCode.
  6. Save the Service:

    • Go to File > Save.
    • Name it something like Open with VSCode.
  7. Test the Service:

    • Right-click on any file or folder in Finder.
    • You should see Open with VSCode in the context menu (you might have to look under Services).
  8. Assign a Keyboard Shortcut (Optional):

    • Go to System Preferences > Keyboard > Shortcuts.
    • Select Services from the left pane.
    • Find your Open with VSCode service.
    • Add a keyboard shortcut if you like.

That's it! You now have a custom right-click option to open files or folders with VSCode on your Mac. This should streamline your workflow, especially as a Python developer and tech enthusiast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment