aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdeploy.py45
-rwxr-xr-xdeploy.sh8
-rw-r--r--directoryinfo7
-rw-r--r--setup.sh0
4 files changed, 52 insertions, 8 deletions
diff --git a/deploy.py b/deploy.py
new file mode 100755
index 0000000..466587c
--- /dev/null
+++ b/deploy.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python3
+from os import listdir
+from os.path import isfile, join, abspath
+from shutil import copy2
+from pathlib import Path
+
+home = str(Path.home())
+contents = dict()
+directory = dict()
+
+with open('directoryinfo') as f:
+ lines = f.readlines()
+ for line in lines:
+ line = line.replace('%HOME', home)
+
+ if (line.isspace()):
+ continue
+
+ if (line.startswith('#')):
+ continue
+
+ parts = line.split()
+ if parts[0] == 'copycontent':
+ contents[parts[1]] = parts[2]
+ elif parts[0] == 'copyfulldir':
+ directory[parts[1]] = parts[2]
+ else:
+ print(f'directoryinfo: unknown directive \'{parts[0]}\'')
+
+# Directive: copycontent
+for d, t in contents.items():
+ files = [f for f in listdir(d) if isfile(join(d, f))]
+ for file in files:
+ print(f'Copying {abspath(join(d, file))} to {abspath(join(t, file))}')
+ copy2(abspath(join(d, file)), join(t, file))
+
+# Directive: copyfulldir
+for d, t in directory.items():
+ files = [f for f in listdir(d) if isfile(join(d, f))]
+ print(f'Creating {t}')
+ Path(t).mkdir(parents=True, exist_ok=True)
+ for file in files:
+ print(f'Copying {abspath(join(d, file))} to {join(t, file)}')
+ copy2(abspath(join(d, file)), join(t, file))
+
diff --git a/deploy.sh b/deploy.sh
deleted file mode 100755
index 27560e9..0000000
--- a/deploy.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-cp -a zsh/. ~
-cp -a git/. ~
-cp -a vim/. ~
-
-cp -a nvim ~/.config/nvim
-
diff --git a/directoryinfo b/directoryinfo
new file mode 100644
index 0000000..cca6945
--- /dev/null
+++ b/directoryinfo
@@ -0,0 +1,7 @@
+# ~ dotfiles
+copycontent zsh %HOME
+copycontent vim %HOME
+copycontent git %HOME
+
+# Directories
+copyfulldir nvim %HOME/.config/nvim
diff --git a/setup.sh b/setup.sh
deleted file mode 100644
index e69de29..0000000
--- a/setup.sh
+++ /dev/null