-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnvim-setup.ps1
More file actions
52 lines (45 loc) · 1.27 KB
/
nvim-setup.ps1
File metadata and controls
52 lines (45 loc) · 1.27 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
45
46
47
48
49
50
51
52
Import-Module .\Test-ReparsePoint.psm1
Import-Module .\Convert-Decision.psm1
$target_dir = "$HOME\AppData\Local\"
$target_folder = "nvim"
$base_src_dir = (Get-Item .).FullName
$src_dir = Join-Path -Path $base_src_dir -ChildPath "config"
$src_dir = Join-Path -Path $src_dir -ChildPath "nvim"
# Check if folder exists
$folder_exists = $false
Get-ChildItem $target_dir | Foreach-Object {
#Write-Output $_.Name
if ($_.Name -eq $target_folder)
{
$folder_exists = $true
$folder_is_symlink = Test-ReparsePoint($_)
}
}
if ($folder_exists)
{
Write-Output "Folder exists"
$folder_exists = $true
if($folder_is_symlink)
{
Write-Output "Folder exists as a symlink!"
}
else
{
$decision = Read-Host -Prompt "Do you want to remove the folder to create a symlink? Warning: This will remove everything within the folder`n"
$decision = Convert-Decision($decision)
if($decision) {
$target = Join-Path -Path $target_dir -ChildPath $target_folder
Write-Output "Deleting $target"
Remove-Item -Recurse -Force $target
}
}
}
else
{
Write-Output "nvim folder does not exist, creating symlink"
}
if ($decision -or -not($folder_exists))
{
New-Item -ItemType SymbolicLink -Path (Join-Path -Path $target_dir -ChildPath $target_folder) -Target $src_dir
Write-Output "Symlink created"
}