0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Visual Studio Codeでコマンドラインから新規ウィンドウでプロジェクトフォルダを開く

0
Last updated at Posted at 2017-08-28

(小ネタ)

最近Visual Studio Code(VSCode)をMacで利用しています。
Atomのように複数プロジェクトを1つのウィンドウで開くことができないので、複数ウィンドウを立ち上げてプロジェクトごとに作業している感じです。
コードはもちろん、最近は現在取り掛かっている仕事に関する仕様やメモ書きなどを入れるフォルダを仕事単位で作成し、VSCodeで立ち上げています。
コマンドラインから開けたらいいなぁと言うのがあったので調べました。

code

VSCode側が用意してくれているコマンドがありました。Windows/Macどちらにもあります。
Macの場合はCMD+Shift+Pでshell commandまで入れると、候補にinstall code command in PATHというのが出てくるので選択します。これでTerminal上からcodeで呼び出せるようになります。

codeコマンドの詳細は以下。

特定のフォルダを新規ウィンドウでプロジェクトフォルダを開く

本題です。本当はこういう風に書きたかった。

code -n -folder="hogehoge"

でもこれだと-nが動かず既存のウィンドウで開こうとしてしまいます。

code -n && code -folder="hogehoge"

そのためこのように書いてみたら想定通りに動いてくれました。

vsc.sh
# !/bin/sh

code -n && code -folder $1

こんなスクリプトを書いて、PATHを通しておくと、vsc .とかvsc hogehogeで動かせますね。

0
3
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
0
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?