-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup_config.py
47 lines (35 loc) · 1.47 KB
/
backup_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
from shutil import copyfile
from distutils.dir_util import copy_tree
home_path = "/Users/kevin"
config_path = os.path.join(home_path, ".config")
backup_path = os.path.join(home_path, "_config")
config_files = [
# .zshrc
[os.path.join(home_path, ".zshrc"), os.path.join(backup_path, "zsh", ".zshrc")],
# .nv
[os.path.join(home_path, ".nv"), os.path.join(backup_path, "nv", ".nv")],
# .svgo
[os.path.join(home_path, ".svgo.config.js"), os.path.join(backup_path, "svgo", ".svgo.config.js")],
# .tool-versions
[os.path.join(home_path, ".tool-versions"), os.path.join(backup_path, "asdf", ".tool-versions")],
# git
[os.path.join(home_path, ".gitconfig"), os.path.join(backup_path, "git", ".gitconfig")]
]
config_directories = [
# zsh
[os.path.join(home_path, ".zsh"), os.path.join(backup_path, "zsh", "config")],
# nvim
[os.path.join(config_path, "nvim"), os.path.join(backup_path, "nvim")],
# git
[os.path.join(config_path, "git"), os.path.join(backup_path, "git")]
]
for config_file in config_files:
if not os.path.exists(os.path.dirname(config_file[1])):
print("Creating directory %s" % os.path.dirname(config_file[1]))
os.makedirs(os.path.dirname(config_file[1]))
print("Copying %s to %s" % (config_file[0], config_file[1]))
copyfile(config_file[0], config_file[1])
for config_directory in config_directories:
print("Copying %s to %s" % (config_directory[0], config_directory[1]))
copy_tree(config_directory[0], config_directory[1])