My dotfiles. Period.

mklinks 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. # ============================================
  3. # mklinks
  4. # --------------------------------------------
  5. #
  6. # usage: mklinks DOTROOT [PREFIX]
  7. #
  8. #
  9. # This script will go through each file or
  10. # sub-folder of DOTROOT and create symbolic
  11. # link to it under your HOME named with "."
  12. # prefix.
  13. #
  14. # This is useful for sharing your dotfiles
  15. # (e.g. using service like Dropbox or keeping
  16. # them in a shared VCS repository like git)
  17. #
  18. # DOTROOT - path where your shared dot-files
  19. # are.
  20. # PREFIX - where you want your links to
  21. # dot-files to be created ($HOME
  22. # by default)
  23. #
  24. # --------------------------------------------
  25. # By Alois Mahdal; no warranty
  26. # ============================================
  27. if [ -z "$1" ];
  28. then echo "usage: $0: DOTROOT [PREFIX]";
  29. exit 1;
  30. fi;
  31. dotroot=$1
  32. prefix=$HOME
  33. if [ -n "$2" ];
  34. then prefix=$2;
  35. fi;
  36. ls $dotroot | while read item;
  37. do
  38. source=$dotroot/$item;
  39. target=$prefix/.$item;
  40. if [ -e $target ];
  41. then
  42. echo "target exists: $target" 1>&2;
  43. else
  44. ln -s $source $target;
  45. fi;
  46. done;