summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ensureddirs.csv2
-rw-r--r--install.awk64
-rw-r--r--symlinks.csv9
3 files changed, 75 insertions, 0 deletions
diff --git a/ensureddirs.csv b/ensureddirs.csv
new file mode 100644
index 0000000..1f249b9
--- /dev/null
+++ b/ensureddirs.csv
@@ -0,0 +1,2 @@
+.config
+.local/bin
diff --git a/install.awk b/install.awk
new file mode 100644
index 0000000..78c9f94
--- /dev/null
+++ b/install.awk
@@ -0,0 +1,64 @@
+function path_join(a, b, x, y) {
+ x = a
+ y = b
+
+ sub(/\/+$/, "", x) # remove trailing / from a
+ sub(/^\/+/, "", y) # remove leading / from b
+
+ if (x == "")
+ return y
+ if (y == "")
+ return x
+
+ return x "/" y
+}
+
+BEGIN { FS = "," } ;
+ARGIND == 1 {
+ # requested dirs
+ dir=path_join(ENVIRON["HOME"], $1)
+ cmd="mkdir -p " dir
+ print cmd
+ system(cmd)
+
+ next
+}
+
+ARGIND == 2 {
+ # block for locations
+ src=path_join(ENVIRON["PWD"], $1)
+ dst=path_join(ENVIRON["HOME"], $2)
+ testcmd="test -e " dst
+ linkcmd="ln -sf " src " " dst
+ diffcmd="diff -ursN " dst " " src
+
+ if (system(testcmd) == 0) {
+ system("ls -lda " dst)
+ printf "Exists, overwrite? y/N/d" # no newline
+ getline resp < "/dev/tty"
+ while (1) {
+ if (resp == "d" || resp == "D") {
+ # dst is exists src is new, order is right
+ print "Showing diff to apply (empty is none)"
+ system(diffcmd)
+ printf "Exists, overwrite? y/N/d" # no newline
+ getline resp < "/dev/tty"
+ continue
+ } else if (resp == "y" || resp == "Y") {
+ print linkcmd
+ system(linkcmd)
+ break
+ } else if (resp == "n" || resp == "N" || resp == "") {
+ print "Skipped"
+ break
+ }
+ print "Exists, overwrite? y/N/d"
+ getline resp < "/dev/tty"
+ }
+ } else {
+ print linkcmd
+ system(echo linkcmd)
+ }
+}
+
+
diff --git a/symlinks.csv b/symlinks.csv
new file mode 100644
index 0000000..0b6366e
--- /dev/null
+++ b/symlinks.csv
@@ -0,0 +1,9 @@
+emacs,.emacs.d
+bash_profile,.bash_profile
+bashrc,.bashrc
+bash_aliases,.bash_aliases
+xinitrc,.xinitrc
+Xdefaults,.Xdefaults
+alacritty,.config/alacritty
+qutebrowser,.config/qutebrowser
+fbterm/fbtermrc,.config/fbtermrc