forked from metakermit/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink
executable file
·28 lines (25 loc) · 961 Bytes
/
link
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
#!/usr/bin/env python
import os, shutil
script_path = os.path.realpath(os.path.dirname(__file__))
repo_root = os.path.dirname(script_path)
special_links = os.path.join(script_path, 'special-links.txt')
with open(special_links) as f:
for line in f:
line = line.strip()
if line != '':
target, link = line.split(' ')
link = os.path.expanduser(link)
link_location, link_name = os.path.split(link)
os.system('mkdir -p ' + link_location)
target, link_name = os.path.join(repo_root, target), link_name
try:
curr_dir = os.getcwd()
print('ln -s %s %s' % (target, link))
os.chdir(link_location)
os.symlink(target, link_name)
os.chdir(curr_dir)
except OSError as e:
if e.errno==17: # file exists
pass
else:
raise