When you use Visual Studio Code on Windows, one handy feature is you can always call it from the command line by typing “code .” (without the quotes) in the folder where you want to work on.
But when you try that on macOS Terminal, this is what you get:
zsh: command not found: code
Not to worry, the same feature can be had on macOS but it’s just not installed by default. In order to do so, we need to do a one-time setup from Visual Studio Code.
- Launch Visual Studio Code.
- Press Cmd ⌘ + Shift ⇧ + P to open the Command Palette.
Type in shell command and select the Shell command: Install ‘code’ command in PATH to install it.
A screen will pop up stating:
Code will now prompt with 'osascript' for Administrator privileges to install the shell command.
Just click OK and authorize it.
Now, the “code .” command works the same way in macOS Terminal as it is on Windows Command Prompt.