How To Open The VS Code From The MAC OS Terminal

Introduction

In the MAC OS some settings require admin privileges such as 'PATH' and for installing some software requires sudo permissions.

After installing VS code from the community site https://code.visualstudio.com/ you may open it from the application launcher in MAC system. But when opening from terminal by typing the command "Code ." it would end up in the following error if the PATH is not set.

How to open the VS Code from the MAC OS terminal

Z shell also known as zsh is a unix shell that is built on top of the bash. From the mac OS greater than Caitlyn zsh is default shell.

When you are getting the above error which says zsh: command not found: code, it clearly denotes that PATH for the vs code command is not set. There is a very simple way on how to set this path. Please follow the below steps.

Steps

Step 1

You need to finish the setup of VS code from the VS code community site. Please follow the reference link that has detail steps.

Step 2

After finishing the installation, open the VS code from the application launchpad, and then open the command palette by clicking 'command button + P' and type in "> Shell" in the command bar.

How to open the VS Code from the MAC OS terminal

Step 3

You will see the options

  • Uninstall 'Code'
  • Install 'Code'

Step 4

Select the option Install 'code'. It will ask for administrator privileges.

How to open the VS Code from the MAC OS terminal

Step 5

Click 'Ok' and then enter the administrator password/fingerprint to set up the path. After successful validation of the credentials, you should see the following message.

How to open the VS Code from the MAC OS terminal

Step 6

Open the zsh terminal and type in 'code .' (observe there is space between code and period). You should be able to open VS code from the terminal.

Conclusion

Thus, in this article, you have seen how to set up PATH for VS code so that you can open the VS code from the terminal zsh.

References


Similar Articles