install.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #! /bin/bash
  2. #
  3. # Link dotifles and bin into $HOME
  4. #
  5. set -e -u
  6. # Get the path to this (install.sh) script.
  7. # See http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in
  8. SOURCE="${BASH_SOURCE[0]}"
  9. while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
  10. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  11. SOURCE="$(readlink "$SOURCE")"
  12. [[ $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
  13. done
  14. DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
  15. # ~/bin will be an actual directory because in different contexts and
  16. # scopes with different projects/people it might have
  17. # different/additional things.
  18. mkdir -p $HOME/bin
  19. bin/link2 -r bin/link2 ~/bin/link2
  20. bin/link2 -r bin/linkall ~/bin/linkall
  21. # link the rest of bin/
  22. ~/bin/linkall $DIR/bin ~/bin/
  23. link2=./bin/link2
  24. # link .dotfiles into ~
  25. linkTo=$HOME
  26. linkThese=( .bashrc .gitconfig .hushlogin .signature)
  27. for linkThis in ${linkThese[@]}; do
  28. ${link2} -r $linkThis $linkTo
  29. done
  30. # link rc.local files in to ~/rc.local/
  31. mkdir -p ~/rc.local
  32. linkTo=$HOME/rc.local
  33. linkThese=( rc.local/*.sh)
  34. for linkThis in ${linkThese[@]}; do
  35. ${link2} -r $linkThis $linkTo
  36. done