-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.ps1
52 lines (46 loc) · 1.48 KB
/
setup.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
$dotfiles = Split-Path $global:MyInvocation.MyCommand.Path
Push-Location $dotfiles
$originalErrorActionPreference = $ErrorActionPreference
try {
$ErrorActionPreference = 'Stop'
$profileDir = Split-Path $Profile
'- Make symbolic links'
[ordered]@{
'Microsoft.PowerShell_profile.ps1' = $profileDir;
'profile.ps1' = $profileDir;
'Pscx.UserPreferences.ps1' = $profileDir;
'PSReadlineProfile.ps1' = $profileDir;
'posh-git.profile.ps1' = $profileDir;
'jabba-upgrade.ps1' = $profileDir;
'.sbtrc' = $home;
'.gitconfig' = $home;
} | % { $_.GetEnumerator() } | % {
$literal = Join-Path $_.Value $_.Name
$target = Join-Path $dotfiles $_.Name
if (!(Test-Path $literal)) {
if (!(Test-Path -PathType Container (Split-Path $literal))) {
mkdir (Split-Path $literal)
}
if (Test-Path -PathType Container $target) {
cmd /c mklink /d $literal $target
} else {
cmd /c mklink $literal $target
}
} else {
"Skipped $literal"
}
}
"- Create files"
@(
Join-Path $home .gitconfig.local
) | % {
if (!(Test-Path $_)) {
New-Item -ItemType file $_
} else {
"Skipped $_"
}
}
} finally {
$ErrorActionPreference = $originalErrorActionPreference
Pop-Location
}