Rick Cohen
Rick Cohen

Reputation: 25

Visual Studio Code: command-line does not accept "code"

I want to create a new python file by using:

code filename.py

But I get:

~ % code file.py zsh: command not found: code

I learned that I could not run a program from the command-line with: python filename.py zsh: command not found: python

I have to use python3 filename.py

Is there a similar solution here?

Upvotes: 1

Views: 2010

Answers (1)

聂超群
聂超群

Reputation: 2120

You can run VS Code from the terminal by typing 'code' after adding it to the path:

  1. Launch VS Code.
  2. Open the Command Palette (Cmd+Shift+P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command. enter image description here
  3. Restart the terminal for the new $PATH value to take effect. You'll be able to type 'code .' in any folder to start editing files in that folder.

Upvotes: 6

Related Questions