-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.py
31 lines (29 loc) · 936 Bytes
/
sync.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
import os, sys
from pathlib import Path
import shutil
def help():
print("python3 sync.py [cmd]")
print()
print("cmd : [push | pull]")
if __name__ == '__main__':
if len(sys.argv) < 2:
cmd = 'push'
else:
cmd = sys.argv[1]
if cmd not in ['push', 'pull']:
help()
else:
files = ['.vimrc', '.tmux.conf', 'config', '.zshrc']
home = Path(os.path.expanduser('~'))
for f in files:
if f == 'config':
home_path = str(home / '.ssh/config')
else:
home_path = str(home / f)
local_path = str(Path() / f)
if cmd == 'pull':
shutil.copy(home_path, local_path)
print("copy {} to {}".format(home_path, local_path))
elif cmd == 'push':
shutil.copy(local_path, home_path)
print("copy {} to {}".format(local_path, home_path))