Skip to content

Instantly share code, notes, and snippets.

@CN-CODEGOD
Created January 6, 2025 02:22
Show Gist options
  • Save CN-CODEGOD/46b148f2443b71a83568a9b211ba97d7 to your computer and use it in GitHub Desktop.
Save CN-CODEGOD/46b148f2443b71a83568a9b211ba97d7 to your computer and use it in GitHub Desktop.
如何用powershell获取iterm2的theme json 直接复制粘贴
# 定义目标路径
$directoryPath = "C:\path\to\your\json\files"
# 获取该路径下所有的 JSON 文件
$jsonFiles = Get-ChildItem -Path $directoryPath -Filter "*.json"
# 初始化一个空数组来存储所有 JSON 对象
$jsonArray = @()
# 遍历每个 JSON 文件
foreach ($jsonFile in $jsonFiles) {
# 读取 JSON 文件内容
$jsonContent = Get-Content -Path $jsonFile.FullName | Out-String
# 解析 JSON 内容
$jsonObj = $jsonContent | ConvertFrom-Json
# 将 JSON 对象添加到数组
$jsonArray += $jsonObj
}
# 将整个数组转换为 JSON 字符串并输出
$jsonArrayString = $jsonArray | ConvertTo-Json -Depth 10
# 输出处理后的 JSON 字符串(或保存到文件)
$jsonArrayString|clip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment