bin 916 B

1234567891011121314151617181920212223242526272829303132333435
  1. #! /bin/bash
  2. #
  3. # symlink this directory to ${HOME}
  4. #
  5. # This is a special case. We have to install link2 and linkall by hand to use them.
  6. set -e -u
  7. # Get the path to this (install.sh) script.
  8. # See http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
  9. SOURCE="${BASH_SOURCE[0]}"
  10. while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  11. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  12. SOURCE="$(readlink "$SOURCE")"
  13. [[ $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
  14. done
  15. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  16. echo DIR is $DIR
  17. base=`basename $DIR`
  18. echo base $base
  19. # remove previous symlinks if any
  20. rm -f ${HOME}/${base}
  21. #bomb out if there is a hard directory
  22. # link this directory to ${HOME}
  23. ln -s $DIR ${HOME}