Browse files

improve install script

  • Loading branch information...
1 parent f48ab42 commit 54f571c2cf52a8eabd21043602f3bbfca430fd84 @adamv committed Sep 28, 2011
Showing with 13 additions and 10 deletions.
  1. +13 −10 install
View
23 install
@@ -1,24 +1,27 @@
#!/bin/bash
-function relink() {
+# relink target-file source-file
+relink() {
if [[ -h "$1" ]]; then
echo "Relinking $1"
# Symbolic link? Then recreate.
rm "$1"
ln -sn "$2" "$1"
elif [[ ! -e "$1" ]]; then
- echo "Linking $1"
+ echo "Linking $1 to $2"
ln -sn "$2" "$1"
else
echo "$1 exists as a real file, skipping."
fi
}
-cd ~
-relink .bash_profile ~/.dotfiles/bash_profile
-relink .bashrc ~/.dotfiles/bashrc
-relink .gitconfig ~/.dotfiles/git-config
-relink .gitignore ~/.dotfiles/git-ignore-global
-relink .hgrc ~/.dotfiles/hgrc
-relink .inputrc ~/.dotfiles/inputrc
-relink bin ~/.dotfiles/bin
+DIR=$( cd "$( dirname "$0" )" && pwd )
+
+relink ~/.bash_profile $DIR/bash_profile
+relink ~/.bashrc $DIR/bashrc
+relink ~/.gitconfig $DIR/git-config
+relink ~/.gitignore $DIR/git-ignore-global
+relink ~/.hgrc $DIR/hgrc
+relink ~/.inputrc $DIR/inputrc
+
+relink ~/bin $DIR/bin

0 comments on commit 54f571c

Please sign in to comment.