-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path4_WindowsTerminal.ps1
31 lines (25 loc) · 1.13 KB
/
4_WindowsTerminal.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
[CmdletBinding()]
param(
[switch]$Force
)
$terminalLocalState = Join-Path $Env:LOCALAPPDATA 'Packages' 'Microsoft.WindowsTerminal_8wekyb3d8bbwe' 'LocalState'
if (!(Test-Path -Path $TerminalLocalState -PathType Container)) {
throw 'Windows Terminal is not installed.'
}
$consoleProfiles = Join-Path $env:OneDriveConsumer '\Documents\.ConsoleProfiles'
$terminalSettings = Join-Path $consoleProfiles 'windows_terminal.json'
if (!(Test-Path $terminalSettings)) {
throw "Settings file '$terminalSettings' was not found. No symlink created."
}
$linkTarget = Join-Path $terminalLocalState 'settings.json'
if (Test-Path $linkTarget) {
if ((Get-Item $linkTarget).ItemType -ne 'SymbolicLink') {
if (!$Force.IsPresent) {
throw "Settings file '$linkTarget' already exists as a file. Use the -Force parameter to overwrite."
}
}
}
New-Item -ItemType SymbolicLink -Path $linkTarget -Target $terminalSettings -Force | Out-Null
# Set user environment variables that contains the path to custom terminal images
$ImagesPath = Join-Path $consoleProfiles 'Images'
[Environment]::SetEnvironmentVariable('WINDOWSTERMINAL_IMAGES', "$ImagesPath", 'User')