The quickest way to open a directory in VS Code is to use the `code` command in the Terminal. However, if its not configured correctly, you might encounter the error `zsh: command not Found: code`.
The quickest way to open a folder in VS Code is to use the `code` command in the Terminal. However, if not configured correctly, you might encounter the error "zsh: command not Found: code". Follow these two steps to resolve the issue.
1. Reinstall Visual Studio Code
Typically, the recommended way to install software on a Mac is through the App Store. However, since VS Code is not available on the App Store, downloading it from the official Visual Studio Code website is your only option.
Even after doing that, you still can't run the application from the Downloads folder in macOS. So, make sure you move the executable file to the Applications folder instead.
2. Install the code command for the PATH variable.
After moving VS Code to the Applications folder, you must add the command to your PATH variables. Once the command is in the PATH environment variable, you can run it from the Terminal application in macOS.
Fortunately, you don't need to use the command line to do that. VS Code provides a one-click solution to add commands to your PATH variables by doing the following:
1. Open VS Code on your Mac.
2. Press Cmd + Shift + P to open the Command Palette.
3. Now, type Shell Command . From the results displayed, select Install 'code' command in PATH .
4. Next, VS Code will ask for permission to install the code command. Select OK .
5. Enter your Mac's admin password at the next prompt and press OK .
Once complete, the "Shell command 'code' successfully installed in PATH" dialog box will appear. Now, even if you don't know how to use Mac Terminal, you can quickly open a folder in macOS using the code command. Simply open Terminal on your Mac and navigate to the folder using the `cd` command . Once you are in the folder of interest, type " code . " in Terminal and press Return (or Enter ).
As one of the best free code editors, VS Code offers many features that make software development and debugging easy. If you prefer using the Terminal to navigate your file system, the `code` command will help you easily open the current directory in the editor.