Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set up a link to open up Visual Studio Code from terminal on OSX?

I've recently installed Visual Studio Code and I love it! In the past, I've used sublime text 2/3 and at some point I copied code to allow subl . command to open the current directory with sublime.

Question:

  • How can I write a similar code to allow visual studio code to open up the current directory like I've done in the past with sublime.
  • Where should I put paste this code?

Desired alias/link/command would be code .

Does the command on this video

like image 859
Armeen Harwood Avatar asked May 11 '15 03:05

Armeen Harwood


1 Answers

From version 1.0 use the command Install 'Code' command in path from the command palette (View | Command Palette) to make Code available to the command line.

Historical answer:

With VSCode 0.3.0 the startup script should now be configured to be this:

code () {
    VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*
}

UPDATE: If this doesnt work for you uninstall VSC and reinstall it; for this will only work with 0.3.0+

like image 182
Benjamin Pasero Avatar answered Nov 15 '22 08:11

Benjamin Pasero