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

前端 未结 25 2372
日久生厌
日久生厌 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: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

提交回复
热议问题