mirror of
https://github.com/NaomiAmethyst/dots.git
synced 2025-04-13 09:30:06 +00:00
if "davesdots" is in the home dir, use rel symlink
This commit is contained in:
parent
bddbd53417
commit
ed573dafbd
1 changed files with 16 additions and 0 deletions
16
install.pl
16
install.pl
|
@ -86,6 +86,13 @@ my %links = (
|
|||
gdbinit => '.gdbinit',
|
||||
);
|
||||
|
||||
my $contained = (substr $scriptdir, 0, length($home)) eq $home;
|
||||
my $prefix = undef;
|
||||
if ($contained) {
|
||||
$prefix = substr $scriptdir, length($home);
|
||||
($prefix) = $prefix =~ m{^\/? (.+)? [^/]+ $}x;
|
||||
}
|
||||
|
||||
my $i = 0; # Keep track of how many links we added
|
||||
for my $file (keys %links) {
|
||||
# See if this file resides in a directory, and create it if needed.
|
||||
|
@ -108,6 +115,15 @@ for my $file (keys %links) {
|
|||
unlink($dest) || warn "Couldn't unlink '$dest': $!\n";
|
||||
}
|
||||
|
||||
if ($contained) {
|
||||
chdir $home;
|
||||
$dest = "$links{$file}";
|
||||
$src = "$prefix$file";
|
||||
if ($path) {
|
||||
$src = "../$src";
|
||||
}
|
||||
}
|
||||
|
||||
symlink($src => $dest) ? $i++ : warn "Couldn't link '$src' to '$dest': $!\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue