install_dotfiles.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
  3. exclude=("scripts")
  4. elemIn() {
  5. for e in "${@:2}"; do
  6. [[ "$e" = "$1" ]] && return 1
  7. done
  8. return 0
  9. }
  10. link() {
  11. if [ -e "$1/$3$2" ]; then
  12. read -p "$1/$3$2 exists! Delete? [y/N] " -n 1 -r
  13. if [[ $REPLY =~ ^[Yy]$ ]]; then
  14. # It might be a very, very bad idea to rm -rf.
  15. rm -rf "$1/$3$2"
  16. ln -sn "$DIR/$2" "$1/$3$2"
  17. fi
  18. echo ""
  19. else
  20. ln -sn "$DIR/$2" "$1/$3$2"
  21. fi
  22. }
  23. for i in $(ls "$DIR"); do
  24. elemIn "$i" "${exclude[@]}"
  25. if [[ $? == 1 ]]; then continue; fi
  26. echo "Linking $i to $HOME/.$i"
  27. link "$HOME" "$i" "."
  28. done
  29. ln -fsn $DIR/../vim "$HOME"/.vim
  30. ln -fsn $DIR/../vim/pathogen/autoload "$DIR"/../vim/
  31. mkdir -p "$DIR"/../vim/tmp/{backup,swap,undo}
  32. git submodule update --init --recursive
  33. git submodule foreach --recursive git pull origin master
  34. read -p "Auto compile YouCompleteMe? [y/N] " -n 1 -r
  35. if [[ $REPLY =~ ^[Yy]$ ]]; then
  36. echo ""
  37. echo "Compiling YouCompleteMe"
  38. cd "$DIR"/../vim/bundle/YouCompleteMe
  39. ./install.sh
  40. fi
  41. echo ""
  42. read -p "Auto compile exuberant-ctags? [y/N] " -n 1 -r
  43. if [[ $REPLY =~ ^[Yy]$ ]]; then
  44. echo ""
  45. git clone git://github.com/jakedouglas/exuberant-ctags.git "$DIR"/exuberant-ctags
  46. cd "$DIR"/exuberant-ctags
  47. ./configure
  48. make
  49. sudo make install
  50. rm -rf "$DIR"/exuberant-ctags
  51. fi
  52. echo ""