aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2016-08-29 17:12:54 +0200
committerKarel Kočí <karel.koci@nic.cz>2016-08-29 17:12:54 +0200
commitdcbd84af7aeeb4cf3bec07b77e575e8fe602944e (patch)
tree7edb99707011d3f69e12decbf46180d2f64c56fe
parent9b9eef9cccf11ab0f0c13fc5d2f53786d2fd1e23 (diff)
downloadmyconfigs-dcbd84af7aeeb4cf3bec07b77e575e8fe602944e.tar.gz
myconfigs-dcbd84af7aeeb4cf3bec07b77e575e8fe602944e.tar.bz2
myconfigs-dcbd84af7aeeb4cf3bec07b77e575e8fe602944e.zip
TMP install commit. More work will be done
-rwxr-xr-xinstall49
1 files 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) "