Last active
November 19, 2022 06:08
-
-
Save kigster/9773f2a8b4047717afdf80352f86fa22 to your computer and use it in GitHub Desktop.
Makefile for Exporting and Restoring VSCode Extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# © 2019-2021 Konstantin Gredeskoul, MIT License. | |
# vim: ft=make | |
# | |
# Place this file anywhere. | |
# | |
# 1. To create a backup of your vscode settings, keybindings and extensions, run | |
# $ make save | |
# This backs it all up to your ~/Documents/VSCode folder. | |
# | |
# 2 To restore VSCode configuration: | |
# $ make install | |
# to restore/install all the extensions, keybindings, settings and install mono- | |
# spaced fonts. | |
# | |
.PHONY: help | |
TIMESTAMP := $(shell date '+%F.%T.%S' | tr -d '[\:\-\.]') | |
ARCHIVE := $(shell (ls -1 *.tarz 2>/dev/null || ls -1 $(HOME)/Documents/VSCode/*.tarz 2>/dev/null) | tail -1) | |
TMPDIR := $(shell mktemp -d) | |
help: | |
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | |
clean: | |
@rm -f $(TMPDIR)/*.txt $(TMPDIR)/*.json | |
@rm -rf $(TMPDIR) | |
can-install: | |
@test -z "$(ARCHIVE)" && test -f "$(ARCHIVE)" || ( echo "Can't find any *.tarz files in your ~/Documents/VSCode folder."; exit 1 ; ) | |
install-mono-fonts: ## Install Mono-Spaced fonts for IDE | |
@echo && echo " 〉downloading and installing mono-fonts..." | |
@test -f $(TMPDIR)/mono-fonts.sh.gz || curl -fsSL https://kig.re/share/mono-fonts.sh.gz > $(TMPDIR)/mono-fonts.sh.gz | |
@test -f $(TMPDIR)/mono-fonts.sh || gunzip $(TMPDIR)/mono-fonts.sh.gz | |
@test -f $(TMPDIR)/mono-fonts.sh && chmod 755 $(TMPDIR)/mono-fonts.sh | |
@$(TMPDIR)/mono-fonts.sh | |
install-settings: ## Copy current user settings and keybindings to this repo. | |
@echo && echo " 〉installing settings and keybindings" | |
@test -f $(TMPDIR)/settings.json && cp -v $(TMPDIR)/settings.json $(HOME)/Library/Application\ Support/Code/User/settings.json | |
@test -f $(TMPDIR)/keybindings.json && cp -v $(TMPDIR)/keybindings.json $(HOME)/Library/Application\ Support/Code/User/keybindings.json | |
install-extensions: ## Installed previously frozen extensions | |
@echo && echo " 〉installing vscode extensions" | |
@cat $(TMPDIR)/extensions.txt | xargs -L 1 code --install-extension | |
install: install-setup install-extensions install-settings install-mono-fonts ## Install VSCode settings, keybindings & monofonts | |
install-setup: | |
@test -f $(ARCHIVE) && tar xvzf $(ARCHIVE) | |
save-extensions: ## save VS Code Extensions | |
@code --list-extensions | sort > $(TMPDIR)/extensions.txt | |
save-settings: ## Copy current user settings and keybindings to this repo. | |
@echo && echo " 〉saving your vscode settingvs..." | |
@cp -v $(HOME)/Library/Application\ Support/Code/User/settings.json $(TMPDIR) | |
@cp -v $(HOME)/Library/Application\ Support/Code/User/keybindings.json $(TMPDIR) | |
save: save-extensions save-settings clean ## Saves settings, keybindings and extensions | |
@echo && echo " 〉creating a tar with your settings.."; | |
@bash -c "cd $(TMPDIR) || exit 1; \ | |
tar cvzf vscode-settings-backup-$(TIMESTAMP).tarz *.json *.txt ; \ | |
cd - >/dev/null" | |
@echo && echo " 〉moving archive to your ~/Documents/VSCode folder..." | |
@mkdir -p $(HOME)/Documents/VSCode && mv -v $(TMPDIR)/vscode*tarz $(HOME)/Documents/VSCode | |
@echo && echo " 〉moving archive to your ~/Documents/VSCode folder..." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment