Skip to content

Instantly share code, notes, and snippets.

@Profesor08
Last active May 18, 2021 19:36
Show Gist options
  • Save Profesor08/c29f43e2545658374d4537a01c6d097f to your computer and use it in GitHub Desktop.
Save Profesor08/c29f43e2545658374d4537a01c6d097f to your computer and use it in GitHub Desktop.
Open in Windows Terminal
<#
Hint: Allowing opening tabs in same directory
1. Open Windows Terminal settings
2. Navigate to Profiles and select one
3. Find Starting Directory config
4. Activate checkbox "Use parent process directory"
5. Repeat 2-4 for all profiles
#>
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs;
exit
}
$source = "https://raw.githubusercontent.com/microsoft/terminal/main/res/terminal.ico"
$destination = "$($env:LOCALAPPDATA)\Microsoft\WindowsApps\terminal.ico"
$path = "Registry::HKCR\Directory\background\shell\WindowsTerminal"
Invoke-WebRequest -Uri $source -OutFile $destination
New-Item -Path $path -Value "Open in Windows Terminal"
New-ItemProperty -Path $path -Name "Icon" -PropertyType String -Value $destination
New-Item -Path "$($path)/command" -Value "wt.exe -p `"Windows PowerShell`" -d `"%V\.`""
Start-Sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment