diff options
2 files changed, 48 insertions, 0 deletions
| -rwxr-xr-x | copy.sh | 24 | ||||
| -rwxr-xr-x | install.sh | 24 |
@@ -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 |
