“code .” Not working in Command Line for Visual Studio Code on OSX/Mac

前端 未结 25 2220
日久生厌
日久生厌 2020-12-12 09:13

The command \"code .\" doesn\'t work in this manual?

All the other steps before that worked. How can I call the Visual Studio Code in OSX terminal?

         


        
相关标签:
25条回答
  • 2020-12-12 09:28

    It was quite simple to follow the documentation to install 'code' to PATH but didn't work.

    I simply uninstalled it first, then installed it again.

    Open the Command Palette (⇧⌘P)

    Shell Command: Uninstall 'code' command in PATH command.
    

    then install it again.

    Shell Command: Install 'code' command in PATH command.
    

    Don't forget to restart your terminal to have the new PATH included.

    0 讨论(0)
  • 2020-12-12 09:29

    Open the ~/.bashrc file using vi/vim $ vi ~/.bashrc

    Enter the following by pressing i to insert:

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

    Save the file using :wq

    Reflect the settings in ~/.bashrc using the following command:

    source ~/.bashrc
    
    0 讨论(0)
  • 2020-12-12 09:29

    Steps to follow:-

    1. Open Visual Studio code application & type Command+Shift+P and type command 'install code'. Then enter it.
    2. You will see below message in Visual Studio Application :- shell command ' code' successfully installed in PATH.
    3. Now, Jump to iTerm CLI and type code .
    4. Then you will be able to redirect to Visual studio for any code change/view.

    Hope this steps will be helpful for you.

    0 讨论(0)
  • 2020-12-12 09:29

    I've tried install add code command to PATH with Visual Studio Code's command pannel, but it's disabled after restart bash. if you want it be consolidated, just create a code file in your PATH; I create a code file in usr/local/bin and add

    #!/usr/bin/env bash
    function realpath() { python -c "import os,sys;print(os.path.realpath(sys.argv[1]))" "$0"; }
    CONTENTS="/Applications/Visual Studio Code.app/Contents"
    ELECTRON="$CONTENTS/MacOS/Electron"
    CLI="$CONTENTS/Resources/app/out/cli.js"
    ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
    exit $?
    

    just replace this CONTENTS with your VS Code's installed path. and don't forget make it excuteable with chmod +x /usr/local/bin/code

    0 讨论(0)
  • 2020-12-12 09:31

    If you are using VS Code Insiders Build:

    code-insiders .
    

    With regular VS Code:

    code .
    
    0 讨论(0)
  • 2020-12-12 09:32

    had this problem in kali. deleted go and reinstalled and now it works perfectly.

    :)

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