在Mac或Linux终端上,可以获取目录内容的颜色列表;例如,文件与文件夹的颜色不同(忽略用于Stackoverflow着色的引号):
>ls
README.md 'src' 'tests' .gitignore
是否可以在Powershell中以类似的颜色突出显示Get-ChildItem
命令的输出?
答案 0 :(得分:0)
是的,这很容易做到。
$List = gci –path 'C:\yourpathhere\' -rec
foreach ($item in $List) {
if ($item.PSIsContainer) {
write-host $item.Name -foregroundcolor "magenta"
} else {
write-host $item.Name -foregroundcolor "yellow"
}
}