Published at
Updated at
Reading time

Today I read a post about Matthias Ott's VS Code setup. I love these posts because you can always discover new things.

After reading it, I shared on Twitter that you can handle and automate your VSCode extension setup with shell commands.

code --install-extension extensionAuthor.extensionName
code --install-extension anotherExtensionAuthor.anotherExtensionName

I've been maintaining a script in my dotfiles to manage my extensions. Meaning, whenever I added a new extension, I had to update this script manually. @shdli shared a way nicer way of handling these repetitive commands. He called it a "manifest'y approach".

# backing up VS Code extensions
code --list-extensions > "./visual-studio-code-extensions.txt"

# installing VS Code extensions
cat  "./visual-studio-code-extensions.txt" | xargs -L 1 code --install-extension

Export all your installed extensions using code --list-extensions, write them to disk, and install them using some shell piping magic and xargs. That's a very sweet way of automating VS Code extensions!

This new manifest approach immediately led to me introducing commands like install and backup in my dotfiles. ๐Ÿ™ˆ My dotfiles are not well documented, reach out via Twitter or write me an email if you have questions.

Was this snippet helpful?
Yes? Cool! You might want to check out Web Weekly for more snippets. The last edition went out 4 days ago.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics

Related Articles