-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.ps1
More file actions
92 lines (78 loc) · 2.35 KB
/
Copy pathinstall.ps1
File metadata and controls
92 lines (78 loc) · 2.35 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# cd to directory of dotfiles based on this script.
$DOTFILES = Split-Path $SCRIPT:MyInvocation.MyCommand.Path -Parent
Set-Location $DOTFILES
$VSCODE = "$env:APPDATA\Code\User"
function main() {
install "vimrc"
install_cp "gitconfig"
install "gitignore"
install "welcome"
install_as "nvim" "$env:LOCALAPPDATA\nvim"
install_as "ahk\misc.ahk" "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\misc.ahk"
mkdir (Split-Path $profile)
install_as "Microsoft.PowerShell_profile.ps1" $profile
install_as "win-terminal\settings.json" "$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json"
install_as "vscode\keybindings.json" "$VSCODE\keybindings.json"
install_as "vscode\settings.json" "$VSCODE\settings.json"
install_as "vscode\snippets" "$VSCODE\snippets"
Write-Host ""
Write-Host -Background Red -Foreground Black " Don't forget to use OpenSSH for 1Password "
Write-Host ""
Write-Host "git config --global core.sshCommand ""C:/Windows/System32/OpenSSH/ssh.exe"""
}
function install($path) {
install_as $path "$HOME\.$path"
}
function install_cp($path) {
Copy-Item $path "$HOME\.$path"
}
function install_as($path, $dest) {
$src = "$DOTFILES\$path"
show $src $dest
if (Test-Path $dest) {
if (is_symlink $dest) {
Remove-Item -Recurse -Force $dest
} else {
if (-Not (confirm "Replace $dest with symlink?")) {
return
}
Remove-Item -Recurse -Force $dest
}
}
$dir = Split-Path -Path $path
maybe_create_prefix $dir
link_it_up $src $dest
}
function show($src, $dest) {
Write-Host -NoNewline -Foreground Green $src
Write-Host -NoNewline -Foreground Blue " -> "
Write-Host -NoNewline -Foreground Red $dest
Write-Host
}
function link_it_up($src, $dest) {
if (Test-Path -PathType Container -Path $src) {
cmd /c mklink /d $dest $src | Out-Null
} else {
cmd /c mklink $dest $src | Out-Null
}
}
function maybe_create_prefix($path) {
if (($path -Eq $null) -Or ($path -Eq "")) {
return
}
if (-Not (Test-Path -PathType Container $path)) {
New-Item $path
}
}
function confirm($title) {
$message = ""
$choices = @("y", "n")
$answer = $host.ui.PromptForChoice($title, $message, $choices, 1)
return $answer -eq 0
}
function is_symlink($path) {
Get-Item $path | Where-Object {
$_.Attributes -match "ReparsePoint"
}
}
main