From dcbd84af7aeeb4cf3bec07b77e575e8fe602944e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 29 Aug 2016 17:12:54 +0200 Subject: TMP install commit. More work will be done --- install | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/install b/install index a2fa367..dc2300d 100755 --- a/install +++ b/install @@ -2,11 +2,50 @@ cd `dirname $0` -function inst { - SOURCE=$1 - OUTPUT=$2 - echo rsync -rlpt $SOURCE $OUTPUT - rsync -rlpt $SOURCE $OUTPUT +dodiff() { + if ! [ -f "$2" ]; then + echo "Not installed: $1 => $2" + read -p "Install? (Y/n) " + if [[ $REPLY =~ ^[Yy]?$ ]]; then + doinst $1 $2 + fi + return + fi + if cmp "$1" "$2" >/dev/null; then + echo "No difference detected: $2" + return + fi + vimdiff "$1" "$2" +} +diff() { + # Ignore some folders. + if ! echo $1 | sed '/vim/q1' >/dev/null; then + continue + fi + # Iterate trough source directory + # Note that its design decision to not iterate trough target directory. + if [ -d "$1" ]; then + for f in `find "$1" -type f`; do + F="${f#$1/}" + echo $f + dodiff "$1/$F" "$2/$F" + done + else + dodiff "$1" "$2" + fi +} + +doinst() { + echo rsync -rlpt $1 $2 + rsync -rlpt $1 $2 +} +inst() { + if [ -e "$2" ]; then + # If output exists, execute diff instead + diff $1 $2 + return + fi + doinst $1 $2 } read -p "Install Bashrc? (Y/n) " -- cgit v1.2.3