-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSetupWindowsTerminalRightClick.ps1
95 lines (75 loc) · 4.64 KB
/
SetupWindowsTerminalRightClick.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#Author: Carlos Martinez Github @cmartinezone
#Version: 1.1
$host.ui.RawUI.WindowTitle = "WindowsTerminal RightClickMenu setup v.1.0 - GitHub: @cmartinezone"
#Find windows terminal
$getWindowsTerminal = Get-ChildItem -Path $env:LOCALAPPDATA\Packages -Filter *Microsoft.WindowsTerminal*
#Detect Lenguage
$getLeng = Get-WinSystemLocale
#Set user lenguage leyout
$leng = @{} # Hash table for user lenguage
if ($getLeng.Name -match 'es-' -or $getLeng.Name -match 'ES-') {
$leng.PrintUser00 = 'No se ha detectado WindowsTerminal instalado!'
$leng.PrintUser01 = 'Porfavor actualice WindowsTerminal settings.json'
$leng.PrintUser02 = 'En "profiels" configure:'
$leng.PrintUser03 = '!Cierre el bloc de notas cuando haya terminado de editar!'
$leng.PrintUser04 = 'Configurando el registro...'
$leng.PrintUser05 = 'Configuracion Completa!'
$leng.PrintUser06 = 'Disfruta Windows Terminal!'
$leng.SetRegProperty00 = 'Abrir Windows Terminal aqui'
$leng.SetRegProperty01 = 'Abrir Windows Terminal aqui (Administrador)'
}else{
$leng.PrintUser00 = 'No detected WindowsTerminal installation'
$leng.PrintUser01 = 'Please Update WindowsTerminal settings.json'
$leng.PrintUser02 = 'Please update in "profiles":'
$leng.PrintUser03 = '!Close notepad when you are done editing!'
$leng.PrintUser04 = 'Setting Registry...'
$leng.PrintUser05 = 'Done!'
$leng.PrintUser06 = 'Enjoy Windows Terminal!'
$leng.SetRegProperty00 = 'Open Windows Terminal here'
$leng.SetRegProperty01 = 'Open Windows Terminal here (Admin)'
}
#If Windows Terminal is installed
if(-not($getWindowsTerminal)){
Write-Host $leng.PrintUser00
}else {
##EDIT WINDOWS TERMINAL PROPERTIES##
$getWindowsTerminalPath = $getWindowsTerminal | Select-Object -First 1
$getWindowsTerminalPath.fullName
$windowsTerminalProperties = ($getWindowsTerminalPath.FullName+"\LocalState\settings.json")
$getRequireSetting = Get-Content -Path $windowsTerminalProperties
do {
Clear-Host
Write-Host $leng.PrintUser01 -BackgroundColor Yellow -ForegroundColor Blue
Write-Host $leng.PrintUser02 -BackgroundColor Yellow -ForegroundColor Blue
Write-Host @"
"defaults":
{
"startingDirectory": "."
}
"@ -ForegroundColor Yellow
Write-Host $leng.PrintUser03 -ForegroundColor Green
Start-Sleep 2
Start-Process notepad.exe $windowsTerminalProperties -Wait
$getRequireSetting = Get-Content -Path $windowsTerminalProperties
} until ($getRequireSetting -match '"startingDirectory": "."')
##GET WINDOWS TERMINAL INSTALLATION PACKAGE PATH##
$getWinTernInstallationPath = Get-AppxPackage -Name Microsoft.WindowsTerminal
## PRESET REGISTRY VALUES ##
$windowsTerminalIcon = ($getWinTernInstallationPath.InstallLocation +"\WindowsTerminal.exe")
$windowsTerminalCommand = $env:LOCALAPPDATA+"\Microsoft\WindowsApps\wt.exe"
$windowsTerminalAdminCommand = "PowerShell -WindowStyle Hidden -Command Start-Process "+ $env:LOCALAPPDATA+"\Microsoft\WindowsApps\wt.exe" +" -ArgumentList '-d','.' -Verb runAs "
Write-Host $leng.PrintUser04 -ForegroundColor Yellow
## SET REGISTRY VALUES ##
New-Item -Path 'Registry::HKCR\Directory\Background\shell\WinTerm' -Force | Out-Null
New-ItemProperty -Path 'Registry::HKCR\Directory\Background\shell\WinTerm' -Name '(Default)' -PropertyType String -Value $leng.SetRegProperty00 -Force | Out-Null
New-ItemProperty -Path 'Registry::HKCR\Directory\Background\shell\WinTerm' -Name 'Icon' -PropertyType String -Value $windowsTerminalIcon -Force | Out-Null
New-Item -Path 'Registry::HKCR\Directory\Background\shell\WinTerm\command' -Force | Out-Null
New-ItemProperty -Path 'Registry::HKCR\Directory\Background\shell\WinTerm\command' -Name "(Default)" -PropertyType String -Value $windowsTerminalCommand -Force | Out-Null
New-Item -Path 'Registry::HKCR\Directory\Background\shell\WinTermAdmin' -Force | Out-Null
New-ItemProperty -Path 'Registry::HKCR\Directory\Background\shell\WinTermAdmin' -Name '(Default)' -PropertyType String -Value $leng.SetRegProperty01 -Force | Out-Null
New-ItemProperty -Path 'Registry::HKCR\Directory\Background\shell\WinTermAdmin' -Name 'Icon' -PropertyType String -Value $windowsTerminalIcon -Force | Out-Null
New-Item -Path 'Registry::HKCR\Directory\Background\shell\WinTermAdmin\command' -Force | Out-Null
New-ItemProperty -Path 'Registry::HKCR\Directory\Background\shell\WinTermAdmin\command' -Name "(Default)" -PropertyType String -Value $windowsTerminalAdminCommand -Force | Out-Null
Write-Host $leng.PrintUser05 -ForegroundColor Green
Write-Host $leng.PrintUser06 -ForegroundColor Green
}