install_dotfiles.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. # BASH_SOURCE means the directory location of this bash script
  3. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
  4. exclude=("scripts" "README.md")
  5. configs=("conky" "openbox" "tint2")
  6. elem_in() {
  7. for e in "${@:2}"; do
  8. [[ "$e" = "$1" ]] && return 1
  9. done
  10. return 0
  11. }
  12. prompt() {
  13. while true; do
  14. if [ "${2:-}" = "Y" ]; then
  15. options="Y/n"
  16. default=Y
  17. elif [ "${2:-}" = "N" ]; then
  18. options="y/N"
  19. default=N
  20. else
  21. options="y/n"
  22. default=
  23. fi
  24. read -p "$1 [$options] " -n 1 -r REPLY
  25. if [ -z "$REPLY" ]; then
  26. REPLY=$default
  27. fi
  28. case "$REPLY" in
  29. Y*|y*) return 0 ;;
  30. N*|n*) return 1 ;;
  31. esac
  32. echo ""
  33. done
  34. }
  35. link() {
  36. if [ -e "$1/$3$2" ]; then
  37. if prompt "$1/$3$2 exists! Delete?" N; then
  38. # It might be a very, very bad idea to rm -rf.
  39. rm -rf "$1/$3$2"
  40. ln -sn "$DIR/$2" "$1/$3$2"
  41. fi
  42. echo ""
  43. else
  44. ln -sn "$DIR/$2" "$1/$3$2"
  45. fi
  46. }
  47. for i in $(ls "$DIR"); do
  48. elem_in "$i" "${exclude[@]}"
  49. if [[ $? == 1 ]]; then continue; fi
  50. elem_in "$i" "${configs[@]}"
  51. if [[ $? == 1 ]]; then
  52. echo "Linking $i to $HOME/.config/$i"
  53. link "$HOME/.config" "$i"
  54. else
  55. echo "Linking $i to $HOME/.$i"
  56. link "$HOME" "$i" "."
  57. fi
  58. done
  59. ln -fsn "$DIR"/vim/pathogen/autoload "$DIR"/vim/
  60. mkdir -p "$DIR"/vim/tmp/{backup,swap,undo}
  61. git submodule update --init --recursive
  62. git submodule foreach --recursive git pull origin master
  63. #Very specific to Arch
  64. if prompt "Install boost and airline glyphs?" N; then
  65. yaourt -S boost powerline-fonts-git
  66. fi
  67. echo ""
  68. if prompt "Auto compile YouCompleteMe?" N; then
  69. echo ""
  70. echo "Compiling YouCompleteMe"
  71. cd "$DIR"/vim/bundle/YouCompleteMe
  72. ./install.sh
  73. fi
  74. echo ""
  75. if prompt "Auto compile exuberant-ctags?" N; then
  76. echo ""
  77. git clone git://github.com/jakedouglas/exuberant-ctags.git "$DIR"/exuberant-ctags
  78. cd "$DIR"/exuberant-ctags
  79. ./configure
  80. make
  81. sudo make install
  82. rm -rf "$DIR"/exuberant-ctags
  83. fi
  84. echo ""