Skip to content

Instantly share code, notes, and snippets.

@Xainey
Created August 27, 2016 00:06
Show Gist options
  • Save Xainey/733a76913b2692fc92a7bf3646f7b662 to your computer and use it in GitHub Desktop.
Save Xainey/733a76913b2692fc92a7bf3646f7b662 to your computer and use it in GitHub Desktop.
Helper Script to Install Themes for ConEmu.
param
(
[string] $ThemeURL,
[string] $ConfigPath = "~\AppData\Roaming\ConEmu.xml"
)
cls
$ErrorActionPreference = "Stop"
#Config
$ConfigFile = Resolve-Path $ConfigPath
# Load XML
[xml] $Theme = (wget $ThemeURL)
[xml] $ConEmu = Get-Content $ConfigFile
$colors = $ConEmu.SelectSingleNode("//key[@name='Colors']")
if($colors -eq $null)
{
Write-Host "Use Settings>Features>Colors and save a random scheme to generate missing XML. Then run again."
return
}
$presentNames = $colors.SelectNodes("key//value[@name='Name']").data
$newName = $theme.SelectNodes("key//value[@name='Name']").data
# Add theme if it doesnt already exist in $ConfigFile
if(!$presentNames.contains($newName))
{
Write-Host ("Adding Theme: {0}" -f $newName)
$colors.value.data = (1 + $colors.value.data).ToString()
$Theme.key.name = "Palette{0}" -f $colors.value.data
$colors.AppendChild($ConEmu.ImportNode($Theme.key, $true)) | Out-Null
}
#Save
Write-Host "Saving..."
$ConEmu.Save($ConfigFile)
@Xainey
Copy link
Author

Xainey commented Aug 27, 2016

For installing Themes from https://github.com/joonro/ConEmu-Color-Themes

ConEmu.xml in default location: ~\AppData\Roaming\ConEmu.xml

$ThemeURL = 'https://raw.githubusercontent.com/joonro/ConEmu-Color-Themes/master/moe-light.xml'
icm ([scriptblock]::Create(([net.webclient]::new().DownloadString("https://git.io/v6pv7")))) -Args $ThemeUrl

if ConEmu.xml not in default path

$ThemeURL = 'https://raw.githubusercontent.com/joonro/ConEmu-Color-Themes/master/moe-light.xml'
$ConfigPath = 'C:\Path\To\ConEmu.xml'
icm ([scriptblock]::Create(([net.webclient]::new().DownloadString("https://git.io/v6pv7")))) -Args $ThemeUrl, $ConfigPath

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment