How to open Visual Studio Code from the command line on OSX?

后端 未结 24 1186
日久生厌
日久生厌 2020-11-30 16:20

The docs mention an executable called code, but I\'m not sure where I can find that so I can put it on my path. The zip I downloaded from the VSCode site did no

24条回答
  •  悲&欢浪女
    2020-11-30 17:06

    On OSX Mavericks I created a bash script named vscode (adapted from the .bashrc in VSCode Setup) in ~/bin:

    #!/bin/bash
    
    if [[ $# = 0 ]]
    then
        open -a "Visual Studio Code"
    else
        [[ $1 = /* ]] && F="$1" || F="$PWD/${1#./}"
        open -a "Visual Studio Code" --args "$F"
    fi
    

    vscode now works as expected.

提交回复
热议问题