美文网首页
gitbash 添加 tree 命令

gitbash 添加 tree 命令

作者: shadow123 | 来源:发表于2023-01-02 11:21 被阅读0次

tree 命令以树形显示文件目录结构,方便浏览。windows 安装的gitbash 默认没有tree 命令,下面介绍下如何安装和使用

下载 tree

下载地址

找到 Binarises ,点击 Zip 下载

下载好的文件为 tree-1.5.2.2-bin.zip

解压文件

解压 tree-1.5.2.2-bin.zip , 在解压后找到bin目录下的tree.exe, 拷贝 tree.exe 文件到 gitbash 安装的l路径的 usr/bin 目录下,

我的文件:·D:\Program Files\Git\usr\bin`

拷贝好后,就可以使用了

使用tree

在 gitbash 命令行窗口,执行 tree 命令查看文件层级目录。

先看下帮助手册

$ tree --help
usage: tree [-adfghilnpqrstuvxACDFNS] [-H baseHREF] [-T title ] [-L level [-R]]
        [-P pattern] [-I pattern] [-o filename] [--version] [--help] [--inodes]
        [--device] [--noreport] [--nolinks] [--dirsfirst] [--charset charset]
        [--filelimit #] [<directory list>]
  -a            All files are listed. # 列出了所有的文件
  -d            List directories only. # 仅限列表目录
  -l            Follow symbolic links like directories. # 遵循符号链接,如目录
  -f            Print the full path prefix for each file. # 打印每个文件的完整路径前缀
  -i            Don't print indentation lines. # 不打印缩进线
  -q            Print non-printable characters as '?'. # 将不可打印的字符打印为“?”
  -N            Print non-printable characters as is. # 正常地打印不可打印的字符
  -p            Print the protections for each file. # 打印每个文件的保护文件
  -u            Displays file owner or UID number. # 显示文件所有者或UID编号
  -g            Displays file group owner or GID number. # 显示文件组所有者或GID号
  -s            Print the size in bytes of each file. # 打印每个文件的字节大小
  -h            Print the size in a more human readable way. # 以更人性化的方式打印尺寸
  -D            Print the date of last modification. # 打印上次修改的日期
  -F            Appends '/', '=', '*', or '|' as per ls -F. # 根据ls-F追加“/”、“=”、“*”或“|”
  -v            Sort files alphanumerically by version. # 按版本按字母数字排序文件
  -r            Sort files in reverse alphanumeric order. # 按相反的字母数字顺序排序文件
  -t            Sort files by last modification time. # 按上次修改时间排序文件
  -x            Stay on current filesystem only. # 仅保留当前文件系统
  -L level      Descend only level directories deep. # 限制目录层级
  -A            Print ANSI lines graphic indentation lines. # 打印ANSI线条图形缩进线条
  -S            Print with ASCII graphics indentation lines. # 使用ASCII图形缩进线打印
  -n            Turn colorization off always (-C overrides). # 始终关闭着色(-C覆盖)
  -C            Turn colorization on always. # 始终启用着色
  -P pattern    List only those files that match the pattern given. # 仅列出与给定模式匹配的文件
  -I pattern    Do not list files that match the given pattern. # 不列出与给定模式匹配的文件
  -H baseHREF   Prints out HTML format with baseHREF as top directory. # 打印以baseHREF作为顶级目录的HTML格式
  -T string     Replace the default HTML title and H1 header with string. # 用字符串替换默认HTML标题和H1标题
  -R            Rerun tree when max dir level reached. # 当达到最大dir级别时,重新运行树
  -o file       Output to file instead of stdout. # 输出到文件
  --inodes      Print inode number of each file. # 打印每个文件的索引节点号
  --device      Print device ID number to which each file belongs. # 打印每个文件所属的设备ID号
  --noreport    Turn off file/directory count at end of tree listing. # 在树列表末尾关闭文件/目录计数
  --nolinks     Turn off hyperlinks in HTML output. # 关闭HTML输出中的超链接
  --dirsfirst   List directories before files. # 在文件之前列出目录
  --charset X   Use charset X for HTML and indentation line output. # 将字符集X用于HTML和缩进行输出
  --filelimit # Do not descend dirs with more than # files in them. # 不要有超过‘#’文件的目录

如果要限制目录层级,可以通过-L level参数展示,例如只显示当前目录下的第一层文件和目录

tree -L 1

$ tree -L 1
.
|-- README.md
|-- babel.config.js
|-- node_modules
|-- package-lock.json
|-- package.json
|-- public
|-- src
|-- vue.config.js
`-- yarn.lock

3 directories, 6 files

中文乱码解决

tree -N > filename.txt

在文件里查看

相关文章

  • GitBash添加tree命令

    1.说明 Tree命令以树形显示文件目录结构,非常适合展示文件目录的组成,在Windows中安装的GitBash默...

  • gitbash 添加 tree 命令

    tree 命令以树形显示文件目录结构,方便浏览。windows 安装的gitbash 默认没有tree 命令,下面...

  • cygwin或windows下gitBash实现alias长久有

    修改文件: 添加alias命令到文件末尾 在cywin窗口或者gitBash窗口执行命令: 一般装有git,即带有...

  • 命令行小记

    GitBash 兼容Linux ,gitbash是一个支持很多命令的软件, 包含git命令, 所以以下命令可以在 ...

  • 解决Maven jar包版本冲突

    在pom里添加 运行命令mvn dependency:tree -Dverbose -D= 输出...

  • 有关于git的使用-初级篇

    作个记录,仅作备忘用。本文包括webstorm配置git,和使用gitbash命令行的操作。 gitbash命令行...

  • Ubuntu 16.04 用 tree 查看目录结构

    关于 Mac 上使用 tree 命令,参照 Mac 安装 tree 命令 1 安装 tree 命令 安装 tree...

  • Gitbash中执行npm以及adb命令错误

    gitbash中执行npm以及adb Push错误 在gitbash中执行adb push命令时,会出现路径找不到...

  • linux命令行

    windows用户建议在gitbash下面运行 gitbash 常见命令 ~这个符号代表的是根目录 ..两个点代表...

  • Git

    安装GitBash (gitbash不是git,,是命令行作用) 找一个目录,在目录上右键点击,然后选中「Git ...

网友评论

      本文标题:gitbash 添加 tree 命令

      本文链接:https://www.haomeiwen.com/subject/dxbhcdtx.html