You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
744 B

13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
  1. #!/bin/sh
  2. info() { echo "$$: $*"; }
  3. err() { echo "E: $$: $*" >&2; }
  4. FILES="$(pwd -P)"
  5. for x; do
  6. if [ -d "$x" ]; then
  7. true # skip dirs
  8. elif [ -L "$HOME/$x" ]; then
  9. d0="$(readlink "$HOME/$x")"
  10. d1="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')"
  11. d1="$(readlink -f "$d1")"
  12. if [ "$d0" != "$d1" ]; then
  13. err "$x: relinking, was [$d0]"
  14. ln -snf "$d1" "$HOME/$x"
  15. fi
  16. else
  17. d="$(dirname "$x")"
  18. if [ ! -d "$HOME/$d/" ]; then
  19. info "$d: creating dir"
  20. mkdir -p "$HOME/$d/"
  21. fi
  22. d="$(echo "$FILES/$x" | sed -e 's,/\./,/,g')"
  23. if [ -e "$HOME/$x" ]; then
  24. info "$x: importing changes and linking"
  25. rm "$d"
  26. cp -a "$HOME/$x" "$d"
  27. else
  28. info "$x: linking"
  29. d="$(readlink -f "$d")"
  30. fi
  31. ln -snf "$d" "$HOME/$x"
  32. fi
  33. done