add .inputrc to work around jline bug
[cmccabe-etc] / install-symlinks.sh
1 #!/usr/bin/env 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 copy_ssh_old=0
19 for file in .bashrc .ssh .profile; do
20     if [ -f ../$file ]; then
21         if [ -L ../$file ]; then
22             :
23         else
24             echo "moving old $file to $file-old"
25             mv -f ../$file ../$file-old
26             if [ $file == .ssh ]; then
27                 copy_ssh_old=1
28             fi
29         fi
30     fi
31 done
32
33 BASEDIR=`pwd`
34 for file in ${BASEDIR}/.[^.]*; do
35         # get base file name, like ".gitconfig"
36         basefile=`basename ${file}`
37
38         # get relative file name, like "cmccabe-etc/.gitconfig"
39         relfile=`echo ${file} | sed 's_.*/\([^/]*/[^/]*\)$_\1_'`
40
41         # skip files which we don't want to link
42         [ "${basefile}" == ".git" ] && continue
43         [ "${basefile}" == ".gitignore" ] && continue
44
45         pushd .. > /dev/null
46         if [ -L ${basefile} ]; then
47                 # Someone already created this link. Pass over it in silence
48                 :
49         elif [ ! -a ${basefile} ]; then
50                 # Create the link
51                 ln -s ${relfile} || die "failed to link ${relfile}"
52                 echo "created ${relfile}..."
53         elif [ -f ${basefile} ]; then
54                 echo "${basefile} already exists as a regular file"
55         else
56                 echo "${basefile} already exists"
57         fi
58         popd > /dev/null
59 done
60
61 if [ $copy_ssh_old -eq 1 ]; then
62     echo "copying files from .ssh-old to .ssh"
63     cp -f ../.ssh-old/* ../.ssh
64     echo "chmod 600 ../.ssh/config"
65     chmod 600 ../.ssh/*
66 fi