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.
If you use VSCodium, you don’t need to do any kinds of setup, it works right away.
Further Reading
How to Use Visual Code as Default Editor in Git
How to Enable Font Ligatures in Visual Studio Code
How to Reassign Shortcut Key for Column Selection in Visual Studio Code
How to Setup Visual Studio Code for Hugo Static Site Generator
Leave a Reply