Run / Open VSCode from Mac Terminal

后端 未结 16 1117
忘了有多久
忘了有多久 2020-12-07 07:01

I\'d like to run / open Visual Studio Code from the Mac OSX Terminal by running this command code .. I found instructions here:

https://code.visualstud

相关标签:
16条回答
  • 2020-12-07 07:09

    For Mac users:

    One thing that made the accepted answer not work for me is that I didn't drag the vs code package into the applications folder

    So you need to drag it to the applications folder then you run the command inside vs code (shown below) as per the official document

    • Launch VS Code.
    • Open the Command Palette (⇧⌘P) and type 'shell command' to find the Shell Command: Install 'code' command in PATH command.
    0 讨论(0)
  • 2020-12-07 07:09
    code () {
        if [[ $# = 0 ]]
        then
            open -a "Visual Studio Code"
        else
            echo "Opening: "$@
            "/Applications/Visual Studio Code.app/Contents/MacOS/Electron" $@
        fi
    }
    

    I put that into my .bash_profile I tested it and it works.

    0 讨论(0)
  • 2020-12-07 07:12

    To set up VS code path permanently on Mac OS;

    just open .bash_profile using the following command on terminal

    open -t .bash_profile
    

    Then add the following path to .bash_profile

    code () { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ;}
    

    save the .bash_profile file and quit the terminal. Then reopen the terminal and type code .to open VS code.

    0 讨论(0)
  • 2020-12-07 07:17

    Try this one

    Open Visual Studio Code and press Command + Shift + P or F1 then type Shell in command palette now you are able to find this option like Shell Command : Install code in PATH from suggested list in command palette. Select that options.

    That's it.

    Now open your terminal type.

    $ code .
    
    0 讨论(0)
  • 2020-12-07 07:19

    open finder and go to applications and make sure that vscode exists there ,then open type in terminal export PATH="/Applications/Visual Studio Code.app/Contents/Resources/app/bin"

    0 讨论(0)
  • 2020-12-07 07:23

    If you are on Mac OSX Maverick, it's ~/.bash_profile not ~/.bashrc

    Try putting the code in there, close the terminal and then try again. Should be working

    0 讨论(0)
提交回复
热议问题