简体   繁体   中英

Is there a way of opening Visual Studio Code from MacOS terminal?

I am used to opening Jupyter Notebook by simply typing 'jupyter notebook' in the terminal but was wondering whether there is a way of doing the same for for VS Code? (Tried opening it the same way as Jupyter but has not worked). Thank you!

Yes, you can open VSCode from the terminal but first, you need to add it to the PATH in MacOS

For zsh shell, run the following

cat << EOF >> ~/.zprofile
Add Visual Studio Code (code)
export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
EOF

If you use bash shell change the first line to cat << EOF >> ~/.bash_profile

Now you can, open VSCode from the terminal by using the following commands

  • To open VSCode with the previous session - code

  • To open VScode in the current directory - code.

  • To open a file in VSCode - code filename

More command-line options can be found here VSCode CMD Line

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM