dotfiles-bootstrap 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. if [ -z "${DOTFILES_DIR}" ]; then
  3. DOTFILES_DIR="kolter-dotfiles"
  4. fi
  5. printf "Looking for dotfiles dir '%s' ... " "${DOTFILES_DIR}"
  6. if [ -d "${DOTFILES_DIR}" ]; then
  7. printf "OK\n"
  8. else
  9. printf "FAILED\n"
  10. exit 1
  11. fi
  12. printf "Copying config files in home directory '%s':\n" "${HOME}"
  13. find "${DOTFILES_DIR}" -maxdepth 1 -mindepth 1 | \
  14. while read d ; do
  15. printf "\t'%s' -> '%s/%s' ... " "${d}" "${HOME}" "$(basename "${d}")"
  16. if mv -f "${d}" "${HOME}" >/dev/null 2>&1 ; then
  17. printf "OK\n"
  18. else
  19. printf "KO\n"
  20. fi
  21. done
  22. printf "Removing dotfiles dir '%s' ... " "${DOTFILES_DIR}"
  23. if rmdir "${DOTFILES_DIR}" >/dev/null 2>&1 ; then
  24. printf "OK\n"
  25. else
  26. printf "KO\n"
  27. fi
  28. printf "Adding some symbolic links ...\n" "${DOTFILES_DIR}"
  29. for lnk in .zsh.d/zshrc:.zshrc .vim/vimrc:.vimrc ; do
  30. lnk_src=$(echo "${lnk}" | cut -d ':' -f 1)
  31. lnk_dest=$(echo "${lnk}" | cut -d ':' -f 2)
  32. printf "\t'%s/%s' -> '%s/%s' ... " "${HOME}" "${lnk_src}" "${HOME}" "${lnk_dest}"
  33. if [ -f "${lnk_src}" ] && (cd "${HOME}" && ln -sf "${lnk_src}" "${lnk_dest}" ) ; then
  34. printf "OK\n"
  35. else
  36. printf "KO\n"
  37. fi
  38. done
  39. exit 0