1234567891011121314151617181920212223242526272829303132333435 |
- #! /bin/bash
- #
- # symlink this directory to ${HOME}
- #
- # This is a special case. We have to install link2 and linkall by hand to use them.
- set -e -u
- # Get the path to this (install.sh) script.
- # See http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
- SOURCE="${BASH_SOURCE[0]}"
- while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
- DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
- SOURCE="$(readlink "$SOURCE")"
- [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
- done
- DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
- echo DIR is $DIR
- base=`basename $DIR`
- echo base $base
- # remove previous symlinks if any
- rm -f ${HOME}/${base}
- #bomb out if there is a hard directory
- # link this directory to ${HOME}
- ln -s $DIR ${HOME}
|