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

Time:01-18

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?

CodePudding user response:

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.
  • Related