@@ -10,16 +10,59 @@ function makeDir($dir){
1010 }
1111}
1212
13- function makeSymbolickLink ($destination , $source ){
14- if (Test-Path $destination ) {
15- if ((Get-ItemProperty $destination ).Mode.Substring(0 , 1 ) -ne ' l' ){
16- Remove-Item $destination - Force - Recurse
17- New-Item - ItemType SymbolicLink - Path $destination - Value " $source "
13+ function makeSymbolickLink {
14+ param (
15+ [Parameter (Mandatory )]
16+ [string ]$Destination ,
17+
18+ [Parameter (Mandatory )]
19+ [string ]$Source
20+ )
21+
22+ $item = Get-Item - LiteralPath $Destination - Force - ErrorAction SilentlyContinue
23+ $sourceFull = [System.IO.Path ]::GetFullPath($Source )
24+
25+ if ($null -ne $item ) {
26+ $isSymbolicLink = ($item.PSObject.Properties.Name -contains ' LinkType' ) -and ($item.LinkType -eq ' SymbolicLink' )
27+
28+ if ($isSymbolicLink ) {
29+ $currentTargetRaw = $null
30+
31+ if (($item.PSObject.Properties.Name -contains ' LinkTarget' ) -and $item.LinkTarget ) {
32+ $currentTargetRaw = $item.LinkTarget
33+ }
34+ elseif (($item.PSObject.Properties.Name -contains ' Target' ) -and $item.Target ) {
35+ $currentTargetRaw = $item.Target
36+ }
37+
38+ if ($currentTargetRaw -is [array ]) {
39+ $currentTargetRaw = $currentTargetRaw [0 ]
40+ }
41+
42+ $currentTargetFull = $null
43+ if ($currentTargetRaw ) {
44+ if ([System.IO.Path ]::IsPathRooted($currentTargetRaw )) {
45+ $currentTargetFull = [System.IO.Path ]::GetFullPath($currentTargetRaw )
46+ }
47+ else {
48+ $baseDir = Split-Path - Parent $item.FullName
49+ $currentTargetFull = [System.IO.Path ]::GetFullPath((Join-Path $baseDir $currentTargetRaw ))
50+ }
51+ }
52+
53+ if ($currentTargetFull -ine $sourceFull ) {
54+ Remove-Item - LiteralPath $Destination - Force
55+ New-Item - ItemType SymbolicLink - Path $Destination - Target $Source | Out-Null
56+ }
57+ }
58+ else {
59+ Remove-Item - LiteralPath $Destination - Force - Recurse
60+ New-Item - ItemType SymbolicLink - Path $Destination - Target $Source | Out-Null
61+ }
62+ }
63+ else {
64+ New-Item - ItemType SymbolicLink - Path $Destination - Target $Source | Out-Null
1865 }
19- # (Get-ItemProperty $destination).LinkTarget
20- }else {
21- New-Item - ItemType SymbolicLink - Path $destination - Value " $source "
22- }
2366}
2467
2568function Exist-Command ($Name ){
@@ -176,5 +219,21 @@ if (-not $moduleList.Contains("git-completion")) {
176219 Install-Module git- completion
177220}
178221
222+ $dotConfig = " $env: USERPROFILE \.config"
223+ $dotfiles = (ghq list -- full- path -- exact yqYo1/ dotfiles)
224+ makeDir $dotConfig
225+
226+ makeSymbolickLink " $Env: USERPROFILE \.gitconfig" " $dotfiles \git\config"
227+ makeSymbolickLink " $Env: APPDATA \CorvusSKK" " $dotfiles \CorvusSKK"
228+ makeSymbolickLink " $Env: APPDATA \bat\config" " $dotfiles \bat\config"
229+ makeSymbolickLink " $Env: APPDATA \bat\themes" " $ ( ghq list -- full- path -- exact catppuccin/ bat) /themes"
230+ makeSymbolickLink " $Env: LOCALAPPDATA \aicommit2" " $dotfiles \aicommit2"
231+ makeSymbolickLink " $Env: LOCALAPPDATA \lazygit" " $dotfiles \lazygit"
232+ makeSymbolickLink " $Env: LOCALAPPDATA \nvim" " $dotfiles \nvim"
233+ makeSymbolickLink " $dotConfig \aquaproj-aqua\aqua.yaml" " $dotfiles \aquaproj-aqua\aqua.yaml"
234+ makeSymbolickLink " $dotConfig \starship.toml" " $dotfiles \starship.toml"
235+ makeSymbolickLink " $dotConfig \wezterm" " $dotfiles \wezterm"
236+ makeSymbolickLink " $env: USERPROFILE \Documents\PowerShell\Profile.ps1" " $dotfiles \PowerShell\Profile.ps1"
237+
179238bat cache -- build
180239Pop-Location
0 commit comments