LoginSignup
14
15

More than 5 years have passed since last update.

zshを使っていてVSCodeのcodeコマンドを使用する方法

Posted at

環境

  • Mac 10.13.6
  • zsh

起きた問題

VSCodeのshell command installは出来るのになぜかターミナルから使用できなかった

解決方法

.zshrcをviで開く

$ vi ~/.zshrc

以下を追記する

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
}

追記したら、以下を実行

$ source ~/.zshrc

以上でcodeコマンドでVisual Studio Codeをコマンドラインから起動出来るようになります。

14
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
15