2

Opening VSCode from the Terminal in macOS

 3 years ago
source link: https://knasmueller.net/opening-vscode-from-the-terminal-in-macos
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
macOS

Opening VSCode from the Terminal in macOS

As a regular user of Visual Studio Code (VSCode) on macOS, you may be wondering why opening VSCode from the terminal does not work as expected:

Pasted-into-Opening-VSCode-from-the-Terminal-in-macOS-1.png

zsh: command not found: code” means that the shell (in my case zsh, in your case maybe bash) is not able to find the code executable. This might confuse you if VSCode is already installed on your system.

There are two solutions to this problem.

Plan A: You can execute the following command:

ln -s "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" /usr/local/bin/code

This creates a symbolic link to the code executable in a directory where your shell usually looks for executables (/usr/local/bin/code). That’s it – you should now be able to use code . as expected.

Plan B: If the above command is not working for some reason, you can use VSCode’s UI to accomplish the same thing. Press Command-Shift-P, enter “shell” and select “Shell Command: Install ‘code’ command in PATH”.

Pasted-into-Opening-VSCode-from-the-Terminal-in-macOS-2.png

Again, that’s it. Run code /path/to/some/directory to open a folder in VSCode and have fun programming!


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK