Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit26c9c875ddbbb421a61314266b9eca20a7789dbe (patch)
Author
 Syndamia <kamen@syndamia.com>
2025-03-28 18:13:18 +0200
Committer
 Syndamia <kamen@syndamia.com>
2025-03-28 18:13:18 +0200
Files57199713c7e61718d1e604e406b527972ebfe346
.files-26c9c875ddbbb421a61314266b9eca20a7789dbe.tar
.files-26c9c875ddbbb421a61314266b9eca20a7789dbe.tar.gz
.files-26c9c875ddbbb421a61314266b9eca20a7789dbe.zip
Parent4c2bea0ccda456ab38ccc205a79ccb6e977f49b8 (diff)
feat: Implement install and copy scripts
2 files changed, 48 insertions, 0 deletions
-rwxr-xr-xcopy.sh24
-rwxr-xr-xinstall.sh24
diff --git a/copy.sh b/copy.sh
new file mode 100755
index 0000000..c07f01f
--- /dev/null
+++ b/copy.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+while read -r conf
+do
+ [ -z "$conf" ] && continue
+ [ ! -f "$conf" ] && echo "warning: $conf is not a regular file, skipping!" && continue
+
+ dest="$HOME/$conf"
+ if [ -f "$dest" ] && ! cmp --silent -- "$dest" "$conf"
+ then
+ diff "$dest" "$conf"
+ printf "Files $dest and $conf are not the same! Overwrite? [y/N] "
+ read -n1 overwrite </dev/tty
+ echo
+ [ "$overwrite" != 'y' && "$overwrite" != 'Y' ] && continue
+ fi
+
+ dir="$(dirname "$dest")"
+ [ ! -d "$dir" ] && mkdir -p "$dir" || rm "$dest" >/dev/null 2>&1
+ cp "$PWD/$conf" "$dest"
+ echo "Installed ${conf##\./}"
+done <<EOF
+$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh' -not -name 'copy.sh')
+EOF
diff --git a/install.sh b/install.sh
new file mode 100755
index 0000000..19ca65b
--- /dev/null
+++ b/install.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+while read -r conf
+do
+ [ -z "$conf" ] && continue
+ [ ! -f "$conf" ] && echo "warning: $conf is not a regular file, skipping!" && continue
+
+ dest="$HOME/$conf"
+ if [ -f "$dest" ] && ! cmp --silent -- "$dest" "$conf"
+ then
+ diff "$dest" "$conf"
+ printf "Files $dest and $conf are not the same! Overwrite? [y/N] "
+ read -n1 overwrite </dev/tty
+ echo
+ [ "$overwrite" != 'y' && "$overwrite" != 'Y' ] && continue
+ fi
+
+ dir="$(dirname "$dest")"
+ [ ! -d "$dir" ] && mkdir -p "$dir" || rm "$dest" >/dev/null 2>&1
+ ln -s "$PWD/$conf" "$dest"
+ echo "Installed ${conf##\./}"
+done <<EOF
+$(find . -type f -not -path './.git/*' -not -name 'README.md' -not -name 'install.sh' -not -name 'copy.sh')
+EOF