Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add a command to Finder services in Mac OSX to open a folder in VS Code
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- Save it as something like "Open in Visual Studio Code"
@JARVIS-AI
Copy link

JARVIS-AI commented Feb 4, 2019

Here we have cool stuff
Great contributes
Thanks everyone

@marcopelegrini
Copy link

marcopelegrini commented Feb 5, 2019

for f in "$@"
do
    open -n -b "com.microsoft.VSCode" --args "$f"
done

For multiple files

@kaidatavis
Copy link

kaidatavis commented Feb 28, 2019

For newbies like me, the 'Service' in automator is now called 'Quick Action'. The rest of the steps work fine.

@itsthomas
Copy link

itsthomas commented Mar 1, 2019

Automator menu is changed and I cannot follow the tutorial. Can some one please update the workflow?

@quasiDigi
Copy link

quasiDigi commented Mar 6, 2019

I works for me.
Thanks :)

@caprica-Six
Copy link

caprica-Six commented May 8, 2019

Great!! Thanks a lot!

@kugoo109
Copy link

kugoo109 commented Jun 20, 2019

This should solve all your problems.
https://github.com/Mortennn/FiScript

@shaltaev
Copy link

shaltaev commented Aug 4, 2019

Awesome! Thanks you very match!

@hoangnamitc
Copy link

hoangnamitc commented Aug 12, 2019

Awesome! Thanks bro,

Action Same for Sublime Text:
shell script box:
 /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -a "$@"

@farkroft
Copy link

farkroft commented Aug 16, 2019

cool, thanks !

@ArnoutPullen
Copy link

ArnoutPullen commented Aug 21, 2019

To make it even easier add a shortcut to this service Command + .
System Preferences->Keyboard->Shortcuts->Services->Open with Visual Studio Code->Add->'Command' + '.' ->Save
Now in finder select a file or folder and press COMMAND + .
Have fun :)

@gkdg
Copy link

gkdg commented Oct 4, 2019

Very cool thanks!!!!

@marcokiel77
Copy link

marcokiel77 commented Oct 27, 2019

Thnx!

@subbu-muthusubramanian
Copy link

subbu-muthusubramanian commented Nov 6, 2019

Just brilliant. Thanks

@MagnusNordin
Copy link

MagnusNordin commented Nov 14, 2019

For newbies like me, the 'Service' in automator is now called 'Quick Action'. The rest of the steps work fine.

Thank you very much!

@philipdanielhayton
Copy link

philipdanielhayton commented Nov 28, 2019

This is brill, thank you!

@elloGuy69
Copy link

elloGuy69 commented Dec 21, 2019

For Mojave, use the following steps

  1. Open Automator
  2. File > New
  3. Select Quick Action
  4. Click Choose
  5. Select "Workflow receives current files or folders in Finder"
  6. From the left hand side pane in Automator, drag-drop Library > Utilities > Run Shell Script into the right hand pane
  7. Ensure Pass input is set to "as arguments"
  8. Then paste the below text:

for f in "$@"
do
open -n -b "com.microsoft.VSCode" --args "$f"
done

  1. Click File > Save
  2. Give name as "Open in VS Code"
  3. Go to Finder, select a folder or files, right click > choose Quick Actions > Open In VS Code

@bthes
Copy link

bthes commented Jan 13, 2020

saved my day ;-) thx

@jaekookang
Copy link

jaekookang commented Jan 25, 2020

This looks super amazing. Thanks!

@JibranYousuf
Copy link

JibranYousuf commented Feb 24, 2020

For Mojave, use the following steps

  1. Open Automator
  2. File > New
  3. Select Quick Action
  4. Click Choose
  5. Select "Workflow receives current files or folders in Finder"
  6. From the left hand side pane in Automator, drag-drop Library > Utilities > Run Shell Script into the right hand pane
  7. Ensure Pass input is set to "as arguments"
  8. Then paste the below text:

for f in "$@"
do
open -n -b "com.microsoft.VSCode" --args "$f"
done

  1. Click File > Save
  2. Give name as "Open in VS Code"
  3. Go to Finder, select a folder or files, right click > choose Quick Actions > Open In VS Code

Worked like a charm, thank you.

@M1kep
Copy link

M1kep commented May 11, 2020

Everybody, you can just go to applications and cmd+click VS Code's application onto the top bar, which will allow you to drag folders onto it to open them into VSCode. No automator necessary. This also works for iTerm2.

Like This

Feel like this one got overlooked, but is by far the best approach IMO. Thanks @mattwaler

@rustamtm
Copy link

rustamtm commented May 21, 2020

Everybody, you can just go to applications and cmd+click VS Code's application onto the top bar, which will allow you to drag folders onto it to open them into VSCode. No automator necessary. This also works for iTerm2.
Like This

Feel like this one got overlooked, but is by far the best approach IMO. Thanks @mattwaler

Oh you are hero! Simple and powerful

@kenecottle
Copy link

kenecottle commented Sep 2, 2020

This is great, thanks for your help!

@merken
Copy link

merken commented Jan 12, 2021

Thanks for this!

Here's an update for Catalina, since Automator has changed a bit over time...

  • Open Automator
  • File -> New -> Quick Action
  • Change "Workflow Receives current" to "files or folders" in "Finder"
  • Add a "Run Shell Script" action
  • Change "Pass input" to "as arguments"
  • Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
  • Save it as something like "Open in Visual Studio Code"

After saving, it should be available on any folder in Finder under the menu Services

@aamnah
Copy link

aamnah commented Feb 26, 2021

updated for Big Sur (doesn't run a script, picks the app's icon) https://gist.github.com/aamnah/9b66ab2462e1b50358455dbd3c9c2f0f

@cybersasi
Copy link

cybersasi commented Apr 19, 2021

Thank you so much

@TugbaK0619
Copy link

TugbaK0619 commented Oct 28, 2021

Screen Shot 2021-10-27 at 8 45 19 PM

it dosen't work

@TugbaK0619
Copy link

TugbaK0619 commented Oct 28, 2021

Screen Shot 2021-10-27 at 8 46 47 PM

it dosen't work

@halataa
Copy link

halataa commented Nov 7, 2021

@adeguntoro
Copy link

adeguntoro commented Jul 30, 2022

wow...thanks man, still works with Mojave.

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