HOW TO RUN VISUAL STUDIO CODE FROM ZSH ON MAC OSX

Adding the codefunction to .zshrc file:

function code {
    if [[ $# = 0 ]]
    then
        open -a "Visual Studio Code"
    else
        local argPath="$1"
        [[ $1 = /* ]] && argPath="$1" || argPath="$PWD/${1#./}"
        open -a "Visual Studio Code" "$argPath"
    fi
}

hen from Terminal you can type:

code – opens Visual Studio Code
code . – opens current directory in Visual Studio Code
code somefile – opens somefile in Visual Studio Code

About Tang

A mobile developer, work in Stockholm, Sweden
This entry was posted in Mac and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s