.bashrc: don't source file for non-bash shells
[cmccabe-etc] / install-symlinks.sh
1 #!/bin/bash
2
3 #
4 # install-symlinks.sh
5 #
6 # Script for installing symlinks to these rc files into your home directory.
7 # It's assumed that your home directory is the directory immediately above this
8 # one.
9 #
10 # Colin McCabe
11 #
12
13 die() {
14         echo "$@"
15         exit 1
16 }
17
18 BASEDIR=`pwd`
19 for file in ${BASEDIR}/.[^.]*; do
20         # get base file name, like ".gitconfig"
21         basefile=`basename ${file}`
22
23         # get relative file name, like "cmccabe-etc/.gitconfig"
24         relfile=`echo ${file} | sed 's_.*/\([^/]*/[^/]*\)$_\1_'`
25
26         # skip files which we don't want to link
27         [ "${basefile}" == ".git" ] && continue
28         [ "${basefile}" == ".gitignore" ] && continue
29
30         pushd .. > /dev/null
31         if [ -L ${basefile} ]; then
32                 # Someone already created this link. Pass over it in silence
33                 :
34         elif [ ! -a ${basefile} ]; then
35                 # Create the link
36                 ln -s ${relfile} || die "failed to link ${relfile}"
37                 echo "created ${relfile}..."
38         elif [ -f ${basefile} ]; then
39                 echo "${basefile} already exists as a regular file"
40         else
41                 echo "${basefile} already exists"
42         fi
43         popd > /dev/null
44 done