Reputation: 6949
How can I install multiple extensions in VSCode using the cli? I tried:
code --install-extension xyz.local-history jock.svg
but it only installs the first extension xyz.local-history
.
Installing extensions...
Installing extension 'xyz.local-history' v1.7.0...
(node:10874) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Extension 'xyz.local-history' v1.7.0 was successfully installed.
Upvotes: 10
Views: 13724
Reputation: 139
On Windows:
To export the extensions, run the below PowerShell command on a path where you want to save the file.
code --list-extensions > vscode-extensions.txt
To import & install the list of extensions in a text file, navigate to the path where the file is located and run the command in PowerShell.
Get-Content vscode-extensions.txt | ForEach-Object { code --install-extension $_ }
where vscode-extensions.txt
is the file that contains list of extensions.
Upvotes: 1
Reputation: 11
there is actually a very simple, one-line solution for this:
$ sed -n 's/^/--install-extension /p' extension.list | xargs code
This will install all extensions exported with code --list-extensions
in one call.
Upvotes: 1
Reputation: 1
CLI find command could support this, in my Dockerfile, code-server could install multi vsix by find command. I think code could use similar scenario
ARG user=docker
#vscode server 1.79.1
ARG vscommit=4cb974a7aed77a74c7813bdccd99ee0d04901215
ADD ./vscode_extension/*.vsix /home/${user}/vscode_extension/
# install vscode extension
RUN find ./ -name '*vsix' -exec ~/.vscode-server/bin/${vscommit}/bin/code-server --accept-server-license-terms--install-extension {} \;
Upvotes: 0
Reputation: 1064
Might be useful to others.
I keep a dump of all extensions in text file for example:
code --install-extension aaron-bond.better-comments
code --install-extension abusaidm.html-snippets
code --install-extension afractal.node-essentials
code --install-extension anseki.vscode-color
code --install-extension be5invis.vscode-icontheme-nomo-dark
....
I would copy all contents of text file and then paste all the contents to PowerShell and then it would install plugins one by one.
Upvotes: -1
Reputation: 418
Disclaimer: This is not a command line approach, but rather a graphical way
to install existing extensions on a new system using .vsix package
, and might help some others with the same.
This method to install extensions on a new system (with reference to an existing system) requires Yeoman VS Code extension generator and vsce (or nodejs to install these).
extension pack
(more details here)npm install -g yo generator-code yo code
First command installs Yeoman VS Code generator, second creates the extension pack (choose default options as below. The created package.json
contains all extensions in the pack, you can modify that list)
.vsix file
npm install -g vsce vsce package
First command installs vsce, second packages the extension into a .vsix file
(run from the root of the extension pack created above)
.vsix file
code --install-extension extension-pack-0.0.1.vsix
Upvotes: 1
Reputation: 1256
It's possible to pass the --install-extension
argument multiple times and so install several extensions with just one line.
code --install-extension dbaeumer.vscode-eslint --install-extension esbenp.prettier-vscode
The documentation for this can be found in Extension Marketplace. Running this both extensions are installed but Installing extensions...
is only found once in the output.
Upvotes: 8
Reputation: 997
If you are use Unix/Linux create a bash script with a loop. In this case I want to backup the extensions list and install again:
First create a list of the extensions:
$ code --list-extensions > extensions.txt
Create a bash script for example with the name vscode-extension-install.sh
and input the following code:
#!/usr/bin/env bash
cat extensions.txt | while read extension || [[ -n $extension ]];
do
code --install-extension $extension --force
done
Then run:
$ ./vscode-extension-install.sh
Example output:
Installing extensions...
Installing extension 'visualstudioexptteam.vscodeintellicode' v1.2.6...
Extension 'visualstudioexptteam.vscodeintellicode' v1.2.6 was successfully installed.
Installing extensions...
Installing extension 'vscode-icons-team.vscode-icons' v10.0.0...
Extension 'vscode-icons-team.vscode-icons' v10.0.0 was successfully installed.
...
From my gists
Upvotes: 16
Reputation: 41
If you are on Windows and do not use WSL, try a PowerShell loop.
extensions.txt
Get-Content extensions.txt | ForEach-Object {code --install-extension $_}
Note: this would work on every system supporting PowerShell
Upvotes: 4
Reputation: 41
Declare a variable, containing the name of all extensions you want to install... after you have it, you can iterate doing the installation one by one...
for extensions in ms-python.python ms-azure-devops.azure-pipelines ms-mssql.mssql
do code --install-extension $extensions
done
Maybe you also have to add your code.cmd path, but if your command is working typring code, this will be enough to do the taks Happy coding!
Upvotes: 4