From a52fadc70df8054a6017d899f53a635f4fcdb82f Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Thu, 18 Feb 2010 15:18:30 -0800 Subject: [PATCH] Add the install-symlinks.sh script --- install-symlinks.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+), 0 deletions(-) create mode 100755 install-symlinks.sh diff --git a/install-symlinks.sh b/install-symlinks.sh new file mode 100755 index 0000000..3588ed2 --- /dev/null +++ b/install-symlinks.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +# +# install-symlinks.sh +# +# Script for installing symlinks to these rc files into your home directory. +# It's assumed that your home directory is the directory immediately above this +# one. +# +# Colin McCabe +# + +die() { + echo "$@" + exit 1 +} + +FULLPATH=`readlink -f $0` +BASEDIR=`dirname ${FULLPATH}` +for file in ${BASEDIR}/.[^.]*; do + # get base file name, like ".gitconfig" + basefile=`basename ${file}` + + # get relative file name, like "cmccabe-etc/.gitconfig" + relfile=`echo ${file} | sed 's_.*/\([^/]*/[^/]*\)$_\1_'` + + # skip files which we don't want to link + if [ "${basefile}" == ".git" ]; then + continue; + fi + + pushd .. > /dev/null + if [ -L ${basefile} ]; then + # Someone already created this link. Pass over it in silence + : + elif [ -z ${basefile} ]; then + # Create the link + ln -s ${relfile} || die "failed to link ${relfile}" + echo "created ${relfile}..." + elif [ -f ${basefile} ]; then + echo "${basefile} already exists as a regular file" + else + echo "${basefile} already exists" + fi + popd > /dev/null +done -- 1.6.6.rc1.39.g9a42