summaryrefslogtreecommitdiff
path: root/bin/dot
diff options
context:
space:
mode:
Diffstat (limited to 'bin/dot')
-rwxr-xr-xbin/dot42
1 files changed, 20 insertions, 22 deletions
diff --git a/bin/dot b/bin/dot
index 905e0c1..2e94da1 100755
--- a/bin/dot
+++ b/bin/dot
@@ -7,51 +7,49 @@ import yaml
# Colors for terminal
from termcolor import colored
-
# Path of dotfiles
-dotpath = '/home/urbain/dotfiles'
+homepath = '/home/urbain'
+dotpath = homepath + '/dotfiles'
# Load yaml configuration file
with open(dotpath + "/install.yaml", 'r') as stream:
config = yaml.load(stream)
-# Special symlinks
+# Special and default symlinks
special_symlinks = set(config['special'].keys())
-
-# All files in dir
-normal_symlinks = set(os.listdir(dotpath)) - set(config['exclude'])
+normal_symlinks = set(config['default'])
def perform(action):
- # Command to execute
- command = config['commands'][action]
-
for f in special_symlinks | normal_symlinks:
# Print filename
print('[' + colored(f, 'green') + ']')
- if f in config['pre']:
- print(config['pre'][f])
- os.system(config['pre'][f])
+ if f in config['pre'] and action == 'up':
+
+ # Format command
+ command = config['pre'][f]
+ formatted = command.format(file=f, path=dotpath)
+
+ # Print & execute
+ print(formatted)
+ os.system(formatted)
# Target of symlink
if f in special_symlinks:
t = config['special'][f]
elif f in normal_symlinks:
- t = config['default'].format(file=f)
-
- if t != "":
- # Formatted command
- formatted = command.format(file=f, path=dotpath, target=t)
+ t = homepath + '/' + f
- # Print & execute command
- print(formatted)
- os.system(formatted)
+ # Command to execute
+ command = config['commands'][action]
+ formatted = command.format(file=f, path=dotpath, target=t)
- else:
- print("Nothing to do!")
+ # Print & execute command
+ print(formatted)
+ os.system(formatted)
print('\n')