1

According to the documentation off Visual Studio CODE, you can open the editor from terminal by adding the following lines to your .bash_profile on OS X.

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

That just works.

Now the question is, what needs to be done to allow the command to work if you try to launch it with administrator privileges.?

ie:

sudo code .
웃mauri
  • 179
  • 2
  • 14

1 Answers1

0

One way would be to add a sudo version to your .bash_profile

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

This is a problem that has been asked (and answered) in these posts.

How can I execute a bash function with sudo? (Server fault)

How can I execute a bash function using sudo? (Stack overflow)

Community
  • 1
  • 1
natemcmaster
  • 25,673
  • 6
  • 78
  • 100
  • Few problems, Vscode doesn't open as root and. You have to specify the file you want to open so its not opening folders. – 웃mauri Aug 04 '15 at 19:25
  • This is probably a bug in VS code itself. You can report it here https://code.visualstudio.com/Issues/List – natemcmaster Aug 04 '15 at 20:24