我正在工作的PowerShell script
,创建了一个Fedora WSL使用docker,它所有的工作,但我不能得到工作的代码部分,设置在settings.json
文件中的图标.
JSON的相关部分:
"profiles":
{
"defaults": {},
"list":
[
{
"commandline": "PATH\\TO\\WSL",
"guid": "{your-guid}",
"hidden": false,
"name": "fedora",
"icon": "PATH\\TO\\ICON"
},
{
"commandline": "cmd.exe",
"guid": "{your-guid}}",
"hidden": false,
"name": "Command Prompt"
},
{
"guid": "{your-guid}}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
以下是我try 过的:
$settings = Get-Content $env:localappdata'\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json' -raw | ConvertFrom-Json
$settings.profiles.list | % {if($_.name -eq $WSLname){$_.icon=$InstallPath\fedora.ico}}
$settings | ConvertTo-Json -depth 32| set-content $env:localappdata'\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json'
Variables are taken from params in first part of the script.
My goal is to chech if the profile name with given input by the user exists, if so, changes or adds the "icon" property to the fedora.ico path.
Edit: This part of the script needs to run after windows terminal has been relaunched.