Run / Open VSCode from Mac Terminal

后端 未结 16 1118
忘了有多久
忘了有多久 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:34

    I prefer to have symlinks in the home directory, in this case at least. Here's how I have things setup:

    : cat ~/.bash_profile | grep PATH
    # places ~/bin first in PATH
    export PATH=~/bin:$PATH
    

    So I symlinked to the VSCode binary like so:

    ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code ~/bin/code
    

    Now I can issue code . in whichever directory I desire.

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

    I simply created a file called code:

    #!/bin/bash
    
    open /Applications/Visual\ Studio\ Code.app $1
    

    Make it executable:

    $ chmod 755 code
    

    Then put that in /usr/local/bin

    $ sudo mv code /usr/local/bin
    

    As long as the file sits someplace that is in your path you can open a file by just typing: code

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

    I just made a symbolic link from the "code" program supplied in the Visual Studio Code.app bundle to /usr/local/bin (a place where I prefer to put stuff like that and which is already in my path on my machine).

    You can make a symbolic link using ln -s like this:

    ln -s /Applications/Visual\ Studio\ Code.app/Contents/Resources/app/bin/code /usr/local/bin/code

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

    How about a simple Bash alias that you stick in your .bash_profile ?

    alias code="open -a /Applications/Visual\ Studio\ Code.app"

    To open the current directory:

    code .

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