























aitree 命令 ai配合重要命令 powershell vscode
tree /f | Out-File -Encoding utf8 tree.txt
下面创建一个aitree命令,将当前目录和整个tree 结构复制到剪切板,支持中文
用 code $PROFILE 打开文件 cv到最后就可以了。
function aitree {
# 1. 构建树状结构字符串
$currentPath = "当前目录: " + $PWD.Path
$treeOutput = Get-ChildItem -Recurse | ForEach-Object {
$depth = ($_.FullName.Replace($PWD.Path, "").Split('\').Count - 2)
$indent = " " * $depth
if ($_.PSIsContainer) { "$indent|-- $($_.Name)\" } else { "$indent|-- $($_.Name)" }
} | Out-String
$fullContent = $currentPath + "`r`n`r`n" + $treeOutput
# 2. 核心:通过 .NET 直接设置剪贴板内容(这是最底层的处理方式)
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.Clipboard]::SetText($fullContent)
Write-Host "✅ 已通过 .NET 底层接口强制写入剪贴板,彻底避开乱码!" -ForegroundColor Green
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。