| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 | 
							- #!/usr/bin/perl
 - 
 - # ============================================
 - # 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
 - # ============================================
 - 
 - 
 - use strict;
 - use warnings;
 - use Getopt::Long;
 - 
 - sub usage { print STDERR "usage: $0: DOTROOT [PREFIX]\n"; exit 1; }
 - 
 - my $dotroot;
 - my $prefix;
 - 
 - my $opts = GetOptions(
 -     'dotroot=s' =>  \$dotroot,
 -     'prefix=s' =>   \$prefix
 - ) or usage;
 - 
 - $dotroot = $dotroot // shift;
 - $prefix = $prefix // shift;
 - $prefix = $prefix // $ENV{HOME};
 - $dotroot or usage;
 - 
 - sub mklinks {
 -     my $dotroot = shift;
 -     my $prefix = shift;
 -     -d $dotroot or die "not a directory: $dotroot";
 -     my @dirs = `ls $dotroot`;
 -     foreach my $dir (@dirs) {
 -         chomp $dir;
 -         my $source = "$dotroot/$dir";
 -         my $target = "$prefix/.$dir";
 -         `mkdir -p $prefix`;
 -         if (-e $target) {
 -             warn "target exists: $target\n";
 -         } else {
 -             `ln -s $source $target`;
 -         }
 -     }
 - }
 - 
 - mklinks($dotroot, $prefix);
 
 
  |