How to Start Visual Studio Code from Shell on MacOS

When you install Visual Studio Code on MacOS, you can start it from the shell using the code command. If you get the error zsh: command not found: code, you need to add the code command to your shell path.

user@mac-mini new_project % code .
zsh: command not found: code

Open Visual Studio Code and press Cmd+Shift+P to open the command palette and type shell command and first select Shell Command: Uninstall 'code' command from PATH.

Mac OS uninstall code command fom PATH

Then press Cmd+Shift+P to open the command palette and type shell command and select Shell Command: Install 'code' command in PATH.

Mac OS install code command in PATH