0
0

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 1 year has passed since last update.

コマンドの結果を Visual Studio Code で開く

Last updated at Posted at 2023-02-22

要旨

テキストファイルを編集する際など、Visual Studio Code (以下、VSCode) で編集するよりもコマンドを叩いたほうが早く、軽く実施できることが多く有る。
しかし、コマンドの結果は、通常は Terminal に表示され、再利用性に乏しい。

ここでは、 コマンドを実行し、その結果を VSCode に表示する方法を記載する。

TL;DR

  1. Command Palette から code をインストールする。
  2. Terminal から パイプで code - へ繋ぐ

やり方

Code コマンド インストール

code コマンドは、 Command Palette からインストールする。

VSCode で Command Palette を表示して、 code と入力
Shell Command Install 'code' command in PATH を選択。
(言語パックが入っている場合は適宜読み替えてください。)

image.png

Terminal からコマンドの実行

(サンプルデータは JSON.org から)

元データ

JSON ファイルなのは分かるけど、整形して、フィルタリングしたい。
image.png

コマンドで整形

cat sample.json | jq .glossary を Terminal から実行
整形できたが、見にくい、ここから VSCode で編集したい。
image.png

コードにパイプ

Terminal に | code - を追加して実行。
image.png

結果

Command で整形した結果を、Code に表示することができた。

参考文献

stackoverflow How do I pipe output into Visual Studio Code?
Visual Studio Code Command Line Interface (CLI)

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?