Browse files

a nice installer

  • Loading branch information...
1 parent e16b477 commit d6cf8b5ef33d847b4e58e8975d1d4ad84a20a985 @isaacs committed Nov 2, 2010
Showing with 35 additions and 0 deletions.
  1. +4 −0 Makefile
  2. +31 −0 install.sh
View
4 Makefile
@@ -0,0 +1,4 @@
+all:install
+
+install:
+ ./install.sh
View
31 install.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+fail () {
+ echo "$@" >&2
+ exit 1
+}
+SCRIPT=$0
+SCRIPTDIR=$(dirname -- "$SCRIPT")
+for i in $HOME/.{g,}vim{rc,rc.local}; do
+ if [ -f "$i" ] || [ -d "$i" ]; then
+ echo "backing up $i to $i.bak"
+ mv $i{,.bak} || fail "failed backup"
+ fi
+done
+if ! [ "$SCRIPTDIR" == "$HOME/.vim" ]; then
+ if [ -d "$HOME/.vim" ]; then
+ mv -- "$HOME/.vim"{,.bak}
+ fi
+ echo "copying to $HOME/.vim"
+ cp -r -- $SCRIPTDIR $HOME/.vim || fail "failed copy"
+ cd $HOME/.vim
+ $HOME/.vim/install.sh || fail "failed install"
+ exit $?
+fi
+
+cd $HOME
+ln -s .vim/vimrc .vimrc || fail ".vimrc"
+ln -s .vim/vimrc.local .vimrc.local || fail ".vimrc.local"
+ln -s .vim/gvimrc .gvimrc || fail ".gvimrc"
+ln -s .vim/gvimrc.local .gvimrc.local || fail ".gvimrc.local"
+

0 comments on commit d6cf8b5

Please sign in to comment.