Visual Studio Code の拡張をコマンドラインでインストールする
Visual Studio Code のコマンド code
で code --install-extension
により指定した拡張をコマンドラインでインストールできます。
また code --list-extension
を実行することにより、インストールされている拡張をリストアップできます。
準備 (プロキシ環境のみ)
プロキシが必要な環境だと code --install-extension
は失敗します。
必要な場合は、あらかじめプロキシを設定します。
https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations で説明されている場所に保存されます。
実例
インストールされている拡張のインストール
$ code --list-extensions
eamodio.gitlens
letmaik.git-tree-compare
mattlott.copy-github-url
mhutchie.git-graph
MS-CEINTL.vscode-language-pack-ja
ms-python.python
ms-vscode.cpptools
拡張の名前を指定してインストール
code --install-extension eamodio.gitlens
code --install-extension letmaik.git-tree-compare
code --install-extension mattlott.copy-github-url
code --install-extension mhutchie.git-graph
code --install-extension MS-CEINTL.vscode-language-pack-ja
code --install-extension ms-python.python
code --install-extension ms-vscode.cpptools
--force
を指定するとうまく動作しなくなったので外した。(2020/10/10)
ヘルプ
$ code --help
Visual Studio Code 1.49.3
Usage: code [options][paths...]
To read from stdin, append '-' (e.g. 'ps aux | grep code | code -')
Options
-d --diff <file> <file> Compare two files with each other.
-a --add <folder> Add folder(s) to the last active window.
-g --goto <file:line[:character]> Open a file at the path on the specified line and character position.
-n --new-window Force to open a new window.
-r --reuse-window Force to open a file or folder in an already opened window.
--folder-uri <uri> Opens a window with given folder uri(s)
--file-uri <uri> Opens a window with given file uri(s)
-w --wait Wait for the files to be closed before returning.
--locale <locale> The locale to use (e.g. en-US or zh-TW).
--user-data-dir <dir> Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.
-h --help Print usage.
Extensions Management
--extensions-dir <dir> Set the root path for extensions.
--list-extensions List the installed extensions.
--show-versions Show versions of installed extensions, when using --list-extension.
--category Filters installed extensions by provided category, when using --list-extension.
--install-extension <extension-id[@version] | path-to-vsix> Installs or updates the extension. Use `--force` argument to avoid prompts. The
identifier of an extension is always `${publisher}.${name}`. To install a specific
version provide `@${version}`. For example: 'vscode.csharp@1.2.3'.
--uninstall-extension <extension-id> Uninstalls an extension.
--enable-proposed-api <extension-id> Enables proposed API features for extensions. Can receive one or more extension IDs to
enable individually.
Troubleshooting
-v --version Print version.
--verbose Print verbose output (implies --wait).
--log <level> Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace',
'off'.
-s --status Print process usage and diagnostics information.
--prof-startup Run CPU profiler during startup
--disable-extensions Disable all installed extensions.
--disable-extension <extension-id> Disable an extension.
--sync <on> <off> Turn sync on or off
--inspect-extensions <port> Allow debugging and profiling of extensions. Check the developer tools for the connection URI.
--inspect-brk-extensions <port> Allow debugging and profiling of extensions with the extension host being paused after start. Check the
developer tools for the connection URI.
--disable-gpu Disable GPU hardware acceleration.
--max-memory Max memory size for a window (in Mbytes).
--telemetry Shows all telemetry events which VS code collects.