123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #!/bin/sh
-
- # ============================================
- # mklinks
- # --------------------------------------------
- #
- # usage: mklinks DOTROOT [PREFIX]
- #
- #
- # This script will go through each file or
- # sub-folder of DOTROOT and create symbolic
- # link to it under your HOME named with "."
- # prefix.
- #
- # This is useful for sharing your dotfiles
- # (e.g. using service like Dropbox or keeping
- # them in a shared VCS repository like git)
- #
- # DOTROOT - path where your shared dot-files
- # are.
- # PREFIX - where you want your links to
- # dot-files to be created ($HOME
- # by default)
- #
- # --------------------------------------------
- # By Alois Mahdal; no warranty
- # ============================================
-
-
- if [ -z "$1" ];
- then echo "usage: $0: DOTROOT [PREFIX]";
- exit 1;
- fi;
-
- dotroot=$1
- prefix=$HOME
-
- if [ -n "$2" ];
- then prefix=$2;
- fi;
-
-
- ls $dotroot | while read item;
- do
- source=$dotroot/$item;
- target=$prefix/.$item;
- if [ -e $target ];
- then
- echo "target exists: $target" 1>&2;
- else
- ln -s $source $target;
- fi;
- done;
|