I was about to transfer a set of 20 extensions to another instance of VSC on another machine. In Atom it works simply with two commands:
create a list with all extensions
apm list --installed --bare > packages.list
Install all extensions from list
apm install --packages-file packages.list
I know you have the possibility to install via cli as well in VSC, but it is somewhat weird. I can list all the extensions and save them in a list:
code --list-extensions > extensions.list
But from that point on it's overcomplicated as I'm not able to install from a list. So, in a powershell I now use something like
foreach($line in get-content extensions.list)
{code --install-extension $($line)}
But I'd wish there was a built-in method to install from a list, like in Atom. Please consider this in a future update.
Linux/Mac:
cat extensions.list | xargs -L1 code --install-extension
I use this for windows cmd:
for /F "tokens=*" %%A in (extensions.list) do code --install-extension %%A
and this for bash:
<extensions.list xargs -I % code --install-extension %
@Tyriar uses this script http://www.growingwiththeweb.com/2016/06/syncing-vscode-extensions.html
I guess vscode-way of doing this is .vscode/extensions.json file in the workspace https://code.visualstudio.com/docs/editor/extension-gallery#_workspace-recommended-extensions
You can create empty workspace with this file, push it to your github and use it as bootstrap to install your favorite extensions
I'd like to see this for the same reasons as @malorus (i.e. syncing across machines) with a couple of additions:
needed for onboarding new developers more quickly.
@jtkiley Re 1:
cat extensions.list | grep -v '^#' | xargs -L1 code --install-extension
Any line that starts with # will get ignored.
I'd like to see this for the same reasons as @malorus (i.e. syncing across machines) with a couple of additions:
- Allow the command to read a file with a list of extensions that also supports comments. At a certain number of extensions, it's nice to break them down by category, especially for reviewing them periodically to see if they're still important.
- For each, check whether they are installed before reinstalling them. The reason is that it's nice to take a list like this, put it in a dotfiles repository, and then regularly run the command in a script so that extensions are just there (within a reasonable time) across machines once you commit the update to the dotfiles repository. Without the check, it's a lot of unnecessary work to keep reinstalling extensions daily (or at whatever interval a script would run). Similarly, it might be nice to have an option or another command that uninstalls any extensions that are not in the list.
I arrived here searching exactly for this: a method to sync extensions through a dotfile, like in sublime text.
The extensions installed and the names in this dotfile should be on a 1-1 correspondence.
I hope this feature will be implemented!
Following command from @Nowaker looks to me a reasonable solution for this.
cat extensions.list | grep -v '^#' | xargs -L1 code --install-extension
Hence closing this.
I still would like to be able to manage all the settings, extension, etc. using just an unique approach (to almost all applications) like YADM
Isn't the package manager of Sublime Text a successful example to follow?
@LucaMoschella there is an extension that does that https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync
@Nowaker I finally got around to adding this to my dotfiles, and it works really nicely. Many thanks!
Most helpful comment
Linux/Mac: