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

  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.


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