-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
44 lines (39 loc) · 1.66 KB
/
Copy pathinstall.ps1
File metadata and controls
44 lines (39 loc) · 1.66 KB
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
[CmdletBinding()]
param(
[switch]$Force,
[switch]$Larp,
[switch]$SkipTerminalAppearance
)
$ErrorActionPreference = 'Stop'
$repoRoot = $PSScriptRoot
$fastfetchConfig = if ($Larp) { 'larp.jsonc' } else { 'config.jsonc' }
$links = @{
(Join-Path $repoRoot 'PowerShell\Microsoft.PowerShell_profile.ps1') = $PROFILE.CurrentUserCurrentHost
(Join-Path $repoRoot ".config\fastfetch\$fastfetchConfig") = (Join-Path $HOME '.config\fastfetch\config.jsonc')
(Join-Path $repoRoot '.config\fastfetch\earth.txt') = (Join-Path $HOME '.config\fastfetch\earth.txt')
(Join-Path $repoRoot '.config\oh-my-posh\star.omp.json') = (Join-Path $HOME '.config\oh-my-posh\star.omp.json')
}
foreach ($source in $links.Keys) {
$destination = $links[$source]
$destinationDirectory = Split-Path -Parent $destination
New-Item -ItemType Directory -Force -Path $destinationDirectory | Out-Null
if (Test-Path -LiteralPath $destination) {
$item = Get-Item -LiteralPath $destination -Force
if ($item.LinkType -and $item.Target -eq $source) {
Write-Host "Linked: $destination"
continue
}
if (-not $Force) {
Write-Warning "Skipped existing file: $destination (run with -Force to replace it)"
continue
}
$backup = "$destination.bak.$(Get-Date -Format 'yyyyMMddHHmmss')"
Move-Item -LiteralPath $destination -Destination $backup
Write-Host "Backed up: $backup"
}
New-Item -ItemType HardLink -Path $destination -Target $source | Out-Null
Write-Host "Linked: $destination"
}
if (-not $SkipTerminalAppearance) {
& (Join-Path $repoRoot 'WindowsTerminal\Set-Acrylic.ps1')
}