Skip to content

Instantly share code, notes, and snippets.

@jongalloway
Last active March 14, 2026 03:02
Show Gist options
  • Select an option

  • Save jongalloway/29e128c6dc514e22381ca339c5e044c3 to your computer and use it in GitHub Desktop.

Select an option

Save jongalloway/29e128c6dc514e22381ca339c5e044c3 to your computer and use it in GitHub Desktop.
Setup GitHub Copilot Windows Terminal profile with icon
# Setup GitHub Copilot Windows Terminal Profile
# Run: irm <gist-raw-url> | iex
$ErrorActionPreference = "Stop"
function Write-Step([string]$Message) {
Write-Host "[OK] $Message"
}
# 0. Choose the best Copilot command available
$profileLaunchCommand = $null
if (Get-Command copilot -ErrorAction SilentlyContinue) {
$profileLaunchCommand = 'pwsh -NoExit -Command "copilot"'
Write-Step "Detected Copilot CLI"
}
elseif (Get-Command gh -ErrorAction SilentlyContinue) {
$ghCopilotAvailable = $false
try {
gh copilot --help *> $null
$ghCopilotAvailable = $true
}
catch {
$ghCopilotAvailable = $false
}
if (-not $ghCopilotAvailable) {
Write-Host "GitHub Copilot extension not found in gh. Installing github/gh-copilot..."
gh extension install github/gh-copilot
gh copilot --help *> $null
Write-Step "Installed gh-copilot extension"
}
$profileLaunchCommand = 'pwsh -NoExit -Command "gh copilot"'
Write-Step "Using gh copilot fallback"
}
else {
throw "Neither 'copilot' nor 'gh' was found in PATH. Install Copilot CLI or GitHub CLI first."
}
# 1. Save a recognizable GitHub/Copilot icon (PNG first)
$iconDir = Join-Path $env:LOCALAPPDATA "terminal-icons"
New-Item -ItemType Directory -Path $iconDir -Force | Out-Null
$iconCandidates = @(
[PSCustomObject]@{
Url = "https://github.githubassets.com/images/modules/site/copilot/copilot.png"
FileName = "github-copilot.png"
},
[PSCustomObject]@{
Url = "https://github.githubassets.com/images/modules/site/copilot/copilot-logo.svg"
FileName = "github-copilot.svg"
},
[PSCustomObject]@{
Url = "https://raw.githubusercontent.com/github/explore/main/topics/github/github.png"
FileName = "github.png"
}
)
$downloaded = $false
$iconPath = $null
foreach ($candidate in $iconCandidates) {
$candidatePath = Join-Path $iconDir $candidate.FileName
try {
Invoke-WebRequest -Uri $candidate.Url -OutFile $candidatePath -UseBasicParsing
if ((Test-Path $candidatePath) -and ((Get-Item $candidatePath).Length -gt 0)) {
$iconPath = $candidatePath
Write-Step "Downloaded icon from $($candidate.Url)"
$downloaded = $true
break
}
}
catch {
Write-Host "[WARN] Could not download icon from $($candidate.Url)"
}
}
if (-not $downloaded -or -not $iconPath) {
throw "Failed to download a recognizable icon from all known sources."
}
# 2. Add/update profile in all Windows Terminal settings files
$settingsPaths = @(
"$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json",
"$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe\LocalState\settings.json",
"$env:LOCALAPPDATA\Packages\Microsoft.WindowsTerminalCanary_8wekyb3d8bbwe\LocalState\settings.json",
"$env:LOCALAPPDATA\Microsoft\Windows Terminal\settings.json"
)
$existingSettingsPaths = $settingsPaths | Where-Object { Test-Path $_ }
if (-not $existingSettingsPaths) {
throw "Windows Terminal settings not found. Is Windows Terminal installed?"
}
$profileGuid = "{a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d}"
$updatedCount = 0
foreach ($settingsPath in $existingSettingsPaths) {
$settings = Get-Content $settingsPath -Raw | ConvertFrom-Json
if (-not $settings.profiles) {
$settings | Add-Member -MemberType NoteProperty -Name profiles -Value ([PSCustomObject]@{ list = @() })
}
if (-not $settings.profiles.list) {
$settings.profiles | Add-Member -MemberType NoteProperty -Name list -Value @()
}
$profile = $settings.profiles.list | Where-Object { $_.guid -eq $profileGuid } | Select-Object -First 1
if ($profile) {
$profile.commandline = $profileLaunchCommand
$profile.icon = $iconPath
$profile.name = "GitHub Copilot"
$profile.hidden = $false
Write-Step "Updated GitHub Copilot profile in $settingsPath"
}
else {
$newProfile = [PSCustomObject]@{
commandline = $profileLaunchCommand
guid = $profileGuid
icon = $iconPath
name = "GitHub Copilot"
hidden = $false
}
$settings.profiles.list = @($newProfile) + @($settings.profiles.list)
Write-Step "Added GitHub Copilot profile to $settingsPath"
}
$settings | ConvertTo-Json -Depth 20 | Set-Content $settingsPath -Encoding UTF8
$updatedCount++
}
Write-Host ""
Write-Host "Done! Updated $updatedCount Windows Terminal settings file(s)."
Write-Host "Restart Windows Terminal to see the new profile."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment