From 9a30a349fb08cc782264a28c061062e8bdbdfd2f Mon Sep 17 00:00:00 2001 From: John Doty Date: Wed, 5 Nov 2014 05:52:43 -0800 Subject: [PATCH] Scripts to move config out of home directory --- setup.cmd | 1 + setup.ps1 | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 setup.cmd create mode 100644 setup.ps1 diff --git a/setup.cmd b/setup.cmd new file mode 100644 index 0000000..096dda5 --- /dev/null +++ b/setup.cmd @@ -0,0 +1 @@ +@powershell -ExecutionPolicy unrestricted %~dp0setup.ps1 diff --git a/setup.ps1 b/setup.ps1 new file mode 100644 index 0000000..620e38f --- /dev/null +++ b/setup.ps1 @@ -0,0 +1,23 @@ +function new-link($link, $target) { + if (test-path $target -PathType Container) { + cmd /c mklink /j $link $target + } else { + cmd /c mklink /h $link $target + } +} + +$ignore = @(".gitignore", "setup.ps1") + +Get-ChildItem . | + ? { !$ignore.Contains($_.Name) } | + % { + $l = split-path -leaf $_.FullName + $p = split-path -parent (split-path -parent $_.FullName) + $t = join-path $p $l + + if (test-path $t) { + remove-item -recurse -force $t + } + + new-link $t $($_.FullName) + }