-
Notifications
You must be signed in to change notification settings - Fork 0
/
link.ps1
73 lines (54 loc) · 2.92 KB
/
link.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#Requires -RunAsAdministrator
# Ensure this is running on Powershell core
if ($PSVersionTable.PSEdition -ne "Core") {
Write-Warning "This script is intended to run on PowerShell Core. Please run it using PowerShell Core."
return
}
function Write-FramedString {
param(
[Parameter(Mandatory=$true, Position=0)]
[string]$InputString
)
$frameLineLength = ([string]$InputString).Length + 12 # Adjust the frame length
$frameLine = "-" * $frameLineLength
$output = "$frameLine`n-$(' ' * 5)$InputString$(' ' * 5)-`n$frameLine"
Write-Host $output
}
# Include Powershell functions, needed for the `ln` alias
. powershell\.powershell\functions.ps1
## Git Section
Write-FramedString "Linking Git Config"
# Link the .gitconfig to home. TODO: Change assumed "git_repos\dotfiles" path to use scriptDirectory
deleteitem "${Env:UserProfile}\.gitconfig"
ln "${Env:UserProfile}\git_repos\dotfiles\.gitconfig" "${Env:UserProfile}\.gitconfig"
## Windows Terminal Section
Write-FramedString "Linking Windows Terminal Settings"
# TODO: Change assumed "git_repos\dotfiles" path to use scriptDirectory
# Due to differences in machine configuration, the `settings.json` should be copied,
# not linked. The `settings.json` in this repo is only meant to be a starting point
$WindowsTerminalDirectory = "$Env:LocalAppData\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState"
if (Test-Path -Path $WindowsTerminalDirectory) {
cp "${Env:UserProfile}\git_repos\dotfiles\settings.json" $WindowsTerminalDirectory
} else {
Write-Warning "Cannot find the Windows Terminal settings at $WindowsTerminalDirectory"
}
## Vim Section
Write-FramedString "Linking Vim Config"
# Remove any existing Vim config files
deleteitem "${Env:UserProfile}\scoop\apps\vim\current\_gvimrc"
deleteitem "${Env:UserProfile}\scoop\apps\vim\current\_vimrc"
deleteitem "${Env:UserProfile}\.gvimrc"
deleteitem "${Env:UserProfile}\.vimrc"
deleteitem "${Env:UserProfile}\.vim"
deleteitem "${Env:UserProfile}\AppData\Local\nvim\init.vim"
# Link the .gitconfig to home. TODO: Change assumed "git_repos\dotfiles" path to use scriptDirectory
ln "${Env:UserProfile}\git_repos\dotfiles\.vimrc" "${Env:UserProfile}\.vimrc"
# Link the gvimrc
ln "${Env:UserProfile}\git_repos\dotfiles\.gvimrc" "${Env:UserProfile}\.gvimrc" # Put the gvimrc next to the vimrc
# ln "${Env:UserProfile}\git_repos\dotfiles\.gvimrc" "${Env:UserProfile}\scoop\apps\vim\current\_gvimrc"
# Link the Windows vimfiles to Unix style location
ln "${Env:UserProfile}\vimfiles" "${Env:UserProfile}\.vim"
# Link the init.vim to nvim AppData. TODO: Change assumed "git_repos\dotfiles" path to use scriptDirectory
ln "${Env:UserProfile}\git_repos\dotfiles\nvim\init.lua" "${Env:UserProfile}\AppData\Local\nvim\init.lua"
ln "${Env:UserProfile}\git_repos\dotfiles\nvim\lua" "${Env:UserProfile}\AppData\Local\nvim\lua"
ln "${Env:UserProfile}\git_repos\dotfiles\nvim\after" "${Env:UserProfile}\AppData\Local\nvim\after"