当前位置: 首页 > news >正文

Powershell模拟实现Linux下的tree命令

Powershell模拟实现Linux下的tree命令

代码

环境: P o w e r s h e l l 7 Powershell\ 7 Powershell 7

function Get-Tree {param([string]$directory = ".",[int]$d = 1,[switch]$f)$absolutePath = Resolve-Path -Relative $directoryWrite-Host $absolutePathfunction Recurse-Tree {param([string]$currentDir,[int]$currentDepth)$indent = "    " * $currentDepth$items = Get-ChildItem -Path $currentDirforeach ($item in $items) {if ($item.PSIsContainer -or $f) {Write-Host ("{0}|-- {1}" -f $indent, $item.Name)if ($item.PSIsContainer -and ($currentDepth -lt $d -or $d -eq -1)) {Recurse-Tree -currentDir $item.FullName -currentDepth ($currentDepth + 1)}}}}Recurse-Tree -currentDir $directory -currentDepth 0
}
New-Alias -Name tree -Value Get-Tree

将上述代码拷贝到"C:\Users\${username}\Documents\PowerShell\profile.ps1"

如果是 P o w e r s h e l l 5 Powershell\ 5 Powershell 5

拷贝到"C:\Users\${username}\Documents\WindowsPowerShell\profile.ps1"

效果

运行:

tree D:\py-projects -d 1

打印效果

D:\py-projects
|-- CartPole-actor-critic-based|-- __pycache__|-- .vscode|-- A2C|-- PPO|-- REINFORCE|-- result
|-- checkpoints
|-- cliff_walk
|-- crack_detection_mp|-- .vscode|-- backend|-- model_deploy|-- mp-weixin
|-- CustomEnv|-- __pycache__|-- .vscode|-- result
|-- deep-in-python-use
|-- faster-rcnn-deploy|-- .vscode|-- checkpoints|-- datasets|-- flagged|-- mmdeploy|-- mmdeploy_model|-- mmdetection
|-- GridWorld-value-based|-- .idea|-- .vscode|-- A2C|-- backup|-- DQN|-- REINFORCE
|-- gym-examples|-- gym_examples
|-- open-resume|-- public|-- src
|-- Pendulum-actor-critic-based|-- .vscode|-- bkp|-- DDPG|-- result|-- SAC|-- TD3
|-- pycharm-projects|-- .idea
|-- QQFlacMusicDownloader|-- .idea|-- flaskSystem|-- md|-- music|-- WebSourceCode
|-- reinforcejs|-- agentzoo|-- external|-- img|-- lib
|-- RL_test|-- __pycache__
|-- RL-notes
|-- stitp_deploy|-- checkpoints|-- mmdeploy|-- mmdeploy_model|-- mmdeploy-1.2.0-windows-amd64-cuda11.3|-- mmdetection|-- mmpretrain|-- work_dir
http://www.lryc.cn/news/160850.html

相关文章:

  • 嵌入式基础-电路
  • 【JS面试题】如何通过闭包漏洞在外部修改函数中的变量
  • 【华为OD机试】按身高和体重排队【2023 B卷|100分】
  • TCP原理(全网最详细)
  • react 初级基础
  • linux学习书籍推荐
  • LeetCode 428. Serialize and Deserialize N-ary Tree【树,BFS,DFS】困难
  • javascript | 变量、函数、属性的命名规则
  • 手写Ribbon基本原理
  • k8s集群中ETCD备份和恢复
  • node版本问题
  • 四)Stable Diffussion使用教程:图生图
  • yolov7简化yaml配置文件
  • pprof火焰图性能优化
  • Greenplum 查找数据目录占用最大的表
  • Java 基于 SpringBoot 的酒店管理系统,附源码和数据库
  • LinkedList(4):多线程LinkedList 不安全情况
  • 3D印刷电路板在线渲染查看工具
  • 【mysql】出现 slow sql 问题及建议
  • element树形筛选
  • 打字侠:一款专业的中文打字网站
  • C++ std::default_random_engine的使用
  • 软件设计模式(二):工厂、门面、调停者和装饰器模式
  • pdf文件签名的问题解决
  • Node.js安装使用
  • sql:SQL优化知识点记录(七)
  • 机器学习:基于梯度下降算法的线性拟合实现和原理解析
  • 关键点数据增强
  • 最小化安装移动云大云操作系统--BCLinux-for-Euler-22.10-everything-x86_64-230316版
  • 003传统图机器学习、图特征工程