No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install-dotfiles.sh 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/usr/bin/env bash
  2. #
  3. # Symlinks ALL the things! (really just all the .dotfile files)
  4. set -e
  5. cd "$(dirname $0)"
  6. export DOTFILES_ROOT="`pwd`"
  7. create_link () {
  8. ln -s $1 $2
  9. echo "linked $1 to $2"
  10. }
  11. overwrite_all=false
  12. backup_all=false
  13. skip_all=false
  14. install_file () {
  15. src=$1
  16. dest=$2
  17. if [ -f $dest ] || [ -d $dest ]
  18. then
  19. overwrite=false
  20. backup=false
  21. skip=false
  22. if [ "$overwrite_all" == "false" ] && [ "$backup_all" == "false" ] && [ "$skip_all" == "false" ]
  23. then
  24. echo "conflict adding $dest"
  25. echo "[s]kip, [S]kip all, [o]verwrite, [O]verwrite all, [b]ackup, [B]ackup all: "
  26. echo -n "> "
  27. read -n 1 cmd
  28. echo ""
  29. case "$cmd" in
  30. o ) overwrite=true;;
  31. O ) overwrite_all=true;;
  32. b ) backup=true;;
  33. B ) backup_all=true;;
  34. s ) skip=true;;
  35. S ) skip_all=true;;
  36. * ) ;;
  37. esac
  38. fi
  39. if [ "$overwrite" == "true" ] || [ "$overwrite_all" == "true" ]
  40. then
  41. rm -rf $dest
  42. echo "removed $dest"
  43. fi
  44. if [ "$backup" == "true" ] || [ "$backup_all" == "true" ]
  45. then
  46. mv $dest $dest\.bak
  47. echo "moved $dest to $dest.bak"
  48. fi
  49. if [ "$skip" == "true" ] || [ "$skip_all" == "true" ]
  50. then
  51. echo "skipped $src"
  52. else
  53. create_link $src $dest
  54. fi
  55. else
  56. create_link $src $dest
  57. fi
  58. }
  59. for src in `find $DOTFILES_ROOT -name \*.dotfile`
  60. do
  61. dest="$HOME/.`basename \"${src%.*}\"`"
  62. install_file $src $dest
  63. done
  64. for src in `find $DOTFILES_ROOT -name \*.configdir`
  65. do
  66. dest="$HOME/.config/`basename \"${src%.*}\"`"
  67. install_file $src $dest
  68. done
  69. find . -name "setup.*sh" | while read setup; do sh -c "${setup}"; done