You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
719 B
Python
20 lines
719 B
Python
1 year ago
|
#!/usr/bin/python3
|
||
|
|
||
|
import os
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
cfg_dir = os.getenv("XDG_CONFIG_HOME", os.path.expanduser('~/.config/'))
|
||
|
cfgs = os.listdir(cfg_dir)
|
||
|
os.chdir('./configs/')
|
||
|
for filename in os.listdir():
|
||
|
print(filename, end=':\n')
|
||
|
if filename in cfgs and os.path.islink(f'{cfg_dir}/{filename}'):
|
||
|
print(' previously linked! unlinking...')
|
||
|
os.remove(f'{cfg_dir}/{filename}')
|
||
|
elif filename in cfgs:
|
||
|
print(' file already exists! backing up...');
|
||
|
os.rename(f'{cfg_dir}/{filename}', f'{cfg_dir}/{filename}.apr_bak')
|
||
|
print(' linking...')
|
||
|
os.symlink(f'{os.getcwd()}/{filename}', f'{cfg_dir}/{filename}')
|
||
|
|