My dotfiles. Period.

mklinks 1.1KB

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