65 lines
1.9 KiB
PowerShell
65 lines
1.9 KiB
PowerShell
# setup.ps1
|
|
# $dotfiles = "$HOME\.dotfiles"
|
|
$dotfiles = $PSScriptRoot
|
|
|
|
$mappings = @(
|
|
@{
|
|
Src = "$dotfiles\alacritty\alacritty.toml"
|
|
Dst = "$HOME\AppData\Roaming\alacritty\alacritty.toml"
|
|
}
|
|
@{
|
|
Src = "$dotfiles\emacs\init.el"
|
|
Dst = "$HOME\.emacs.d\init.el"
|
|
}
|
|
@{
|
|
Src = "$dotfiles\emacs\themes"
|
|
Dst = "$HOME\.emacs.d\themes"
|
|
}
|
|
@{
|
|
Src = "$dotfiles\oh-my-posh-themes"
|
|
Dst = "$HOME\oh-my-posh-themes"
|
|
}
|
|
@{
|
|
Src = "$dotfiles\powershell\profile.ps1"
|
|
Dst = $PROFILE
|
|
}
|
|
|
|
# @{ Src = "$dotfiles\nvim\init.lua"; Dst = "$HOME\AppData\Local\nvim\init.lua" }
|
|
# @{ Src = "$dotfiles\powershell\profile.ps1"; Dst = $PROFILE }
|
|
# @{ Src = "$dotfiles\wezterm\.wezterm.lua"; Dst = "$HOME\.wezterm.lua" }
|
|
)
|
|
|
|
function New-Symlink($src, $dst) {
|
|
$dir = Split-Path $dst
|
|
if (!(Test-Path $dir)) {
|
|
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
|
Write-Host " Created dir: $dir" -ForegroundColor DarkGray
|
|
}
|
|
|
|
if (Test-Path $dst) {
|
|
$existing = Get-Item $dst -Force
|
|
if ($existing.LinkType -eq "SymbolicLink" -and $existing.Target -eq $src) {
|
|
Write-Host " [skip] Already linked: $dst" -ForegroundColor DarkGray
|
|
return
|
|
} else {
|
|
Write-Host " [warn] Already exists (not a matching symlink): $dst" -ForegroundColor Yellow
|
|
Write-Host " Remove it manually if you want to replace it."
|
|
return
|
|
}
|
|
}
|
|
|
|
if (!(Test-Path $src)) {
|
|
Write-Host " [error] Source not found: $src" -ForegroundColor Red
|
|
return
|
|
}
|
|
|
|
New-Item -ItemType SymbolicLink -Path $dst -Target $src | Out-Null
|
|
Write-Host " [ok] $dst -> $src" -ForegroundColor Green
|
|
}
|
|
|
|
Write-Host "`nSetting up dotfile symlinks...`n"
|
|
foreach ($m in $mappings) {
|
|
New-Symlink $m.Src $m.Dst
|
|
}
|
|
Write-Host "`nDone.`n"
|