2
1

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 3 years have passed since last update.

VS Codeに追加した拡張機能からextensions.jsonを作成する

Last updated at Posted at 2021-06-27

はじめに

VS Codeに追加した拡張機能から楽にextensions.jsonを作れないかと思い調査した。
codeコマンドを使えば楽に作れることが分かった。

目次

  1. 環境
  2. 作成手順
  3. 共有方法
  4. 参考文献

環境

  • Windows10
  • Git Bash(MSYS2)
  • jq

作成手順

extensions.jsonを作成する

※git bashを使うのでUNIXの書き方になる

echo '{"recommendations": [],"unwantedRecommendations":[]}' > extensions.json
code --list-extensions | xargs -i sh -c "cat extensions.json | jq '.recommendations |= .+[\"{}\"]' > tmp && mv tmp extensions.json"
{
  "recommendations": [
    "ms-vscode-remote.remote-containers",
    "ms-vscode-remote.remote-ssh",
    "ms-vscode-remote.remote-ssh-edit",
    "ms-vscode-remote.remote-ssh-explorer",
    "ms-vscode-remote.remote-wsl",
    "ms-vscode-remote.vscode-remote-extensionpack"
    ~略~
  ],
  "unwantedRecommendations": []
}

インストールコマンドの一覧を作成する

Windows

code --list-extensions | % { "code --install-extension $_" } > install_vscode_extensions.bat

UNIX

code --list-extensions | xargs -L 1 echo code --install-extension > install_vscode_extensions.bat

batファイル

code --install-extension ms-vscode-remote.remote-containers
code --install-extension ms-vscode-remote.remote-ssh
code --install-extension ms-vscode-remote.remote-ssh-edit
code --install-extension ms-vscode-remote.remote-ssh-explorer
code --install-extension ms-vscode-remote.remote-wsl
code --install-extension ms-vscode-remote.vscode-remote-extensionpack
~略~

共有方法

.vscodeディレクトリにextensions.jsonを保存する。
.gitignoreから拡張機能をコミット対象外にしてあとはpushして共有する。

.vscode/*
!.vscode/extensions.json

参考文献

2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?