Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added VSCode settings and extensions backup/reinstall, pip3 backup. #205

Merged
merged 22 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8d087b2
#200 added gitpython to setup.py
AlexanderProd Dec 14, 2018
673b3a3
Merge branch 'master' of https://github.com/alichtman/shallow-backup
AlexanderProd Dec 14, 2018
b08c6c7
added ~./vscode folder for vscode extensions
AlexanderProd Dec 22, 2018
34996d7
added vscode settings backup
AlexanderProd Dec 22, 2018
cb37095
Merge branch 'master' of https://github.com/alichtman/shallow-backup
AlexanderProd Jan 5, 2019
0cbf207
added vscode settings backup
AlexanderProd Jan 5, 2019
ca4aa4d
removed sync_local_settings from beeing backuped
AlexanderProd Jan 5, 2019
cdd837c
removed .vscode folder from backup
AlexanderProd Jan 5, 2019
9a2786f
removed .vscode folder from backup
AlexanderProd Jan 5, 2019
ef49f49
Update compatibility.py
AlexanderProd Jan 5, 2019
514b56e
fixed indent
AlexanderProd Jan 5, 2019
d7cb57e
fixed indent in compatibility.py
AlexanderProd Jan 5, 2019
eea5012
vscode configs are saved to dedicated folder
AlexanderProd Jan 5, 2019
99f9e94
vscode configs are saved to dedicated folder
AlexanderProd Jan 5, 2019
b5242c2
added pip3 backup
AlexanderProd Jan 6, 2019
af0532d
added vscode extensions backup
AlexanderProd Jan 6, 2019
049f273
updated README for VSCode and pip3
AlexanderProd Jan 6, 2019
470577e
removed trailing whitespace in backup.py
AlexanderProd Jan 6, 2019
b5397bc
added .DS_Store to gitignore
AlexanderProd Jan 6, 2019
ff83611
added pip3 reinstall
AlexanderProd Jan 6, 2019
97b65f0
changed vscode extensions file name
AlexanderProd Jan 7, 2019
e799aed
added vscode extensions restore
AlexanderProd Jan 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ By default, `shallow-backup` backs these up.

2. App Config Files
* Atom
* VSCode
* Sublime Text 2/3
* Terminal.app

Expand All @@ -99,8 +100,10 @@ By default, `shallow-backup` backs these up.
* `cargo`
* `gem`
* `pip`
* `pip3`
* `npm`
* `macports`
* `VSCode` Extensions
* `Sublime Text 2/3` Packages
* System Applications

Expand Down
12 changes: 12 additions & 0 deletions shallow_backup/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ def backup_packages(backup_path, skip=False):
dest = "{}/pip_list.txt".format(backup_path)
run_cmd_write_stdout(command, dest)

# pip3
print_pkg_mgr_backup("pip3")
command = "pip3 list --format=freeze"
dest = "{}/pip3_list.txt".format(backup_path)
run_cmd_write_stdout(command, dest)

# npm
print_pkg_mgr_backup("npm")
command = "npm ls --global --parseable=true --depth=0"
Expand All @@ -137,6 +143,12 @@ def backup_packages(backup_path, skip=False):
dest = "{}/apm_list.txt".format(backup_path)
run_cmd_write_stdout(command, dest)

# vscode extensions
print_pkg_mgr_backup("VSCode")
command = "code --list-extensions --show-versions"
dest = "{}/vscode_list.txt".format(backup_path)
run_cmd_write_stdout(command, dest)

# macports
print_pkg_mgr_backup("macports")
command = "port installed requested"
Expand Down
12 changes: 12 additions & 0 deletions shallow_backup/compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,35 @@ def get_config_paths():
if "darwin" == get_os_name():
sublime2_path = os.path.join(get_home(), "Library/Application Support/Sublime Text 2")
sublime3_path = os.path.join(get_home(), "Library/Application Support/Sublime Text 3")
vscode_path_1 = os.path.join(get_home(), "Library/Application Support/Code/User/settings.json")
vscode_path_2 = os.path.join(get_home(), "Library/Application Support/Code/User/Snippets")
vscode_path_3 = os.path.join(get_home(), "Library/Application Support/Code/User/keybindings.json")
atom_path = os.path.join(get_home(), ".atom")
terminal_path = os.path.join(get_home(), "Library/Preferences/com.apple.Terminal.plist")

return {
sublime2_path: "sublime2",
sublime3_path: "sublime3",
vscode_path_1: "vscode/settings",
vscode_path_2: "vscode/Snippets",
vscode_path_3: "vscode/keybindings",
atom_path: "atom",
terminal_path: "terminal_plist"
}
else:
sublime2_path = "/.config/sublime-text-2"
sublime3_path = "/.config/sublime-text-3"
vscode_path_1 = "/.config/Code/User/settings.json"
vscode_path_2 = "/.config/Code/User/Snippets"
vscode_path_3 = "/.config/Code/User/keybindings.json"
atom_path = os.path.join(get_home(), ".atom")
return {
# TODO: Double check these paths. Not sure these are right.
sublime2_path: "sublime2",
sublime3_path: "sublime3",
vscode_path_1: "vscode/settings",
vscode_path_2: "vscode/Snippets",
vscode_path_3: "vscode/keybindings",
atom_path: "atom"
}

Expand Down
1 change: 1 addition & 0 deletions shallow_backup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_default_config():
"default-gitignore": [
"dotfiles/.ssh",
"dotfiles/.pypirc",
".DS_Store"
alichtman marked this conversation as resolved.
Show resolved Hide resolved
],
"config_mapping" : get_config_paths()
}
Expand Down
12 changes: 11 additions & 1 deletion shallow_backup/reinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def reinstall_packages_sb(packages_path):
package_mgrs = set()
for file in os.listdir(packages_path):
manager = file.split("_")[0].replace("-", " ")
if manager in ["gem", "brew-cask", "cargo", "npm", "pip", "brew", "apm", "macports"]:
if manager in ["gem", "brew-cask", "cargo", "npm", "pip", "pip3", "brew", "vscode", "apm", "macports"]:
package_mgrs.add(file.split("_")[0])

print_blue_bold("Package Manager Backups Found:")
Expand All @@ -97,6 +97,16 @@ def reinstall_packages_sb(packages_path):
print_pkg_mgr_reinstall(pm)
cmd = "pip install -r {0}/pip_list.txt".format(packages_path)
run_cmd(cmd)
elif pm == "pip3":
print_pkg_mgr_reinstall(pm)
cmd = "pip3 install -r {0}/pip3_list.txt".format(packages_path)
run_cmd(cmd)
elif pm == "vscode":
print_pkg_mgr_reinstall(pm)
with open("{0}/vscode_list.txt".format(packages_path), "r") as f:
for x in f:
cmd = "code --install-extension {0}".format(x)
run_cmd(cmd)
elif pm == "apm":
print_pkg_mgr_reinstall(pm)
cmd = "apm install --packages-file {0}/apm_list.txt".format(packages_path)
Expand Down