Просмотр исходного кода

Improve install process and update for new configuration files.

Drew 12 лет назад
Родитель
Сommit
2d045714a7
1 измененных файлов с 48 добавлено и 23 удалено
  1. 48 23
      bashrc

+ 48 - 23
bashrc

@@ -1,44 +1,69 @@
 #!/bin/bash
 
-DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
 
-for i in $(ls "$DIR"); do
-  if [ "$i" != "install" ] && [ "$i" != "UpdateVimPlugins" ] && [ "$i" != "README.md" ]; then
-    if [ -e "$HOME/.$i" ]; then
-      read -p "$HOME/.$i exists! Delete? [y/N] " -n 1 -r
-      if [[ $REPLY =~ ^[Yy]$ ]]; then
-        #probably would be better to explicitly check
-        #if directory before -r and -n
-        rm -rf "$HOME/.$i"
-        ln -sn "$DIR/$i" "$HOME/.$i"
-      fi
-      echo ""
-    else
-      ln -sn "$DIR/$i" "$HOME/.$i"
+elemIn() {
+  for e in "${@:2}"; do
+    [[ "$e" = "$1" ]] && return 1
+  done
+  return 0
+}
+
+link() {
+  if [ -e "$1/.$2" ]; then
+    read -p "$1/.$2 exists! Delete? [y/N] " -n 1 -r
+    if [[ $REPLY =~ ^[Yy]$ ]]; then
+      rm -rf "$1/.$2"
+      ln -sn "$DIR/$2" "$1/.$2"
     fi
+    echo ""
+  else
+    ln -sn "$DIR/$2" "$1/.$2"
+  fi
+}
+
+exclude=("scripts" "README.md")
+configs=("conky" "openbox" "tint2")
+for i in $(ls "$DIR"); do
+  elemIn "$i" "${exclude[@]}"
+  if [[  $? == 1 ]]; then continue; fi
+  elemIn "$i" "${configs[@]}"
+  if [[ $? == 1 ]]; then
+    link "$HOME/.config" "$i"
+  else
+    link "$HOME" "$i"
   fi
 done
 
 git submodule update --init --recursive
 git submodule foreach git pull origin master
 ln -fsn "$DIR"/vim/pathogen/autoload "$DIR"/vim/
-mkdir -p "$HOME"/.local/share/vim/{backup,swap,undo}
+mkdir -p "$DIR"/vim/tmp/{backup,swap,undo}
 
 #Very specific to Arch
-yaourt -S boost python-powerline-git
+read -p "Install boost and powerline? [y/N] " -n 1 -r
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+  yaourt -S boost python2-powerline-git
+fi
+echo ""
 
-echo "Compiling YouCompleteMe"
-cd "$DIR"/vim/bundle/YouCompleteMe
-./install.sh
+read -p "Auto compile YouCompleteMe? [y/N] " -n 1 -r
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+  echo ""
+  echo "Compiling YouCompleteMe"
+  cd "$DIR"/vim/bundle/YouCompleteMe
+  ./install.sh
+fi
+echo ""
 
-read -p "Auto install exuberant-ctags? [y/N] " -n 1 -r
+read -p "Auto compile exuberant-ctags? [y/N] " -n 1 -r
 if [[ $REPLY =~ ^[Yy]$ ]]; then
   echo ""
-  git clone git://github.com/jakedouglas/exuberant-ctags.git "$HOME"/exuberant-ctags
-  cd "$HOME"/exuberant-ctags
+  git clone git://github.com/jakedouglas/exuberant-ctags.git "$DIR"/exuberant-ctags
+  cd "$DIR"/exuberant-ctags
   ./configure
   make
   sudo make install
-  rm -rf "$HOME"/exuberant-ctags
+  rm -rf "$DIR"/exuberant-ctags
 fi
 echo ""