-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync.ps1
45 lines (38 loc) · 1.15 KB
/
sync.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
function Write-Part ([string] $Text) {
Write-Host $Text -NoNewline
}
function Write-Emphasized ([string] $Text) {
Write-Host $Text -NoNewLine -ForegroundColor "Cyan"
}
function Write-Done {
Write-Host " > " -NoNewline
Write-Host "OK" -ForegroundColor "Green"
}
function Write-NG {
Write-Host " > " -NoNewline
Write-Host "ERROR" -ForegroundColor "Red"
}
$items = @{
"$HOME\.config\ripgrep.conf" = ".\.config\ripgrep.conf"
"$HOME\.config\starship.toml" = ".\.config\starship.toml"
"$PROFILE" = ".\win\Microsoft.PowerShell_profile.ps1"
}
foreach ($item in $items.GetEnumerator()) {
try {
if (Compare-Object (Get-Content $item.Key) (Get-Content $item.Value)) {
Write-Part "Updating "
Write-Emphasized $(Split-Path -Leaf $item.Key)
Copy-Item -Path $item.Key -Destination $item.Value -ErrorAction Stop
Write-Done
}
else {
Write-Part "Skipping "
Write-Emphasized $(Split-Path -Leaf $item.Key)
Write-Host
}
}
catch {
Write-NG
Write-Host (' ' + $_.Exception.Message)
}
}