"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
4 Answers
Launch VS Code
Open View --> Command Palette
Type
shell command
andfind
Shell Command: Install 'code' command in PATH command
and install (for mac)find
Allow Workspace Shell Configuration
and install (for linux )Restart the terminal
Go to your folder path and type
code .
in terminal.
Visual Code Studio will open with your current folder directory.

- 1
- 1

- 353
- 2
- 8
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

- 1
- 1

- 526
- 1
- 6
- 21
Adding to Pyae's answer, if you're running the Insider's version of VS code, you will need to use code-insiders <command>
in order to use the command line utilities.
This is easily solved by adding an alias in your bash profile if you don't want to type the full program name every time.

- 5,031
- 17
- 33
- 41

- 1
This is what I did in my .bash_rc file based on Min Htet Oo's answer:
export PATH="/Applications/Utilities/Visual Studio Code.app/Contents/MacOS/":$PATH
alias code='Electron'
code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}

- 1