12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #!/bin/bash
- commonFiles=();
- for sourceFile in .*; do
-
- if [[ "$sourceFile" == "dotfiles-002.png" || "$sourceFile" == "dotfiles-001.png" || "$sourceFile" == "install.sh" ]] || [[ "$sourceFile" == "README.md" ]] || [[ "$sourceFile" == "." ]] || [[ "$sourceFile" == ".." ]] || [[ "$sourceFile" == ".git" ]]; then
- continue;
- fi;
-
-
- targetFile="$HOME/$sourceFile";
-
- if [ -e "$targetFile" ]; then
-
- [ "$sourceFile" -ef "$targetFile" ] && continue;
-
- diff -rq "$sourceFile" "$targetFile" > /dev/null 2>&1 && continue;
-
-
- commonFiles+=("$sourceFile");
- fi;
- done;
- conflictCount=${#commonFiles[@]};
- if [ $conflictCount -gt 0 ]; then
-
-
- backupSuffix=".jsVimconfig-$(date +'%Y%m%d-%H%M%S')";
-
- tput setaf 3;
- printf "Warning: there are some files that will be overwritten.";
- tput sgr0;
- echo " Your files will be given the suffix $backupSuffix and will be" \
- "replaced by symlinks to the Dotfiles:";
-
- for sourceFile in "${commonFiles[@]}"; do
- targetFile="$HOME/$sourceFile";
- echo "Yours: $targetFile";
- echo "Dotfiles: $sourceFile";
- done;
-
- read -p "Would you like to overwrite the current files? (yes|no): ";
- case "$(tr '[:upper:]' '[:lower:]' <<< "$REPLY")" in
- 'yes'|'y')
-
- ;;
- 'no'|'n')
-
- echo 'Aborting.';
- exit 1;
- ;;
- *)
-
- echo 'Invalid answer. Assumed "no". Installation aborted.';
- exit 1;
- esac;
- fi;
- for sourceFile in "${commonFiles[@]}"; do
- targetFile="$HOME/$sourceFile";
- mv -v "$targetFile" "$targetFile$backupSuffix";
- done;
- for sourceFile in .*; do
-
- if [[ "$sourceFile" == "dotfiles-002.png" || "$sourceFile" == "dotfiles-001.png" || "$sourceFile" == "install.sh" ]] || [[ "$sourceFile" == "README.md" ]] || [[ "$sourceFile" == "." ]] || [[ "$sourceFile" == ".." ]] || [[ "$sourceFile" == ".git" ]]; then
- continue;
- fi;
- targetFile="$HOME/$sourceFile";
-
- rm -rf "$targetFile" &&
- ln -vs "$PWD/$sourceFile" "$targetFile";
- done;
- echo "Done.";
|