Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"code ." command doesn't work to open Visual Studio Code operator from mac terminal

"code ." command doesn't work to open Visual Studio Code operator from mac terminal I cannot open Visual Studio Code Editor from command line just by typing "code ." in terminal

code

like image 600
San Di Avatar asked Jun 01 '18 10:06

San Di


People also ask

How do I open Visual Studio code from command line Mac?

Launching from the command line You can also run VS Code from the terminal by typing 'code' after adding it to the path: Launch VS Code. Open the Command Palette (Cmd+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.

Why code is not working in VS Code terminal?

If your terminal is set to run as administrator only, and you are not launching VS Code as administrator, the terminal will not be able to open. You can either change the default terminal or edit the properties of the terminal exe to not run as administrator.

How do I run code from terminal Mac?

Execute commands in the shell In the Terminal app on your Mac, enter the complete pathname of the tool's executable file, followed by any needed arguments, then press Return.


2 Answers

  1. Launch VS Code

  2. Open View --> Command Palette

  3. Type shell command and

    find Shell Command: Install 'code' command in PATH command and install (for mac)

    find Allow Workspace Shell Configuration and install (for linux )

  4. Restart the terminal

  5. Go to your folder path and type code . in terminal.

Visual Code Studio will open with your current folder directory.

like image 158
pyae phyo hlaing Avatar answered Nov 09 '22 05:11

pyae phyo hlaing


Locate your bash profile with the command 'locate bash_profile'.That file is usually located in '/Users/user_name/.bash_profile'.Once you found the file, insert the following command.

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

After that, save the file and type the following command in the same directory.

See the attached screenshot for more clarity. enter image description here

$source .bash_profile

like image 21
Min Htet Oo Avatar answered Nov 09 '22 06:11

Min Htet Oo