Skip to content

Filter for tree command. It can indent without using indentation line.

License

Notifications You must be signed in to change notification settings

loftkun/indent-filter-for-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

indent filter for tree

What it is?

filter for tree command.
can indent directories and files without using indentation line.
for linux ( filter.sh ) and windows ( filter.ps1 ).

for Linux

Prerequisites

  • jq
  • python3.x

Usage

tree [${TARGET_DIRECTORY}] -J | ./filter.sh

example

tree command only

$ tree ./directory0
./directory0
├── directory1
│   ├── directory2
│   │   ├── directory3
│   │   └── file3
│   └── file2
└── file1

tree commnad with filter

$ tree ./directory0 -J | ./filter.sh
./directory0/
        directory1/
                directory2/
                        directory3/
                        file3
                file2
        file1
$

for Windows

Prerequisites

  • Windows Powershell

Usage

create filter (see filter.ps1.)

PS C:\test> filter IndentFilter {
% { $_ -replace "^(.*[+,\\\\]-.*)$","$&\" } |
% { $_ -replace "\|   " ,"`t" }  |
% { $_ -replace "\+---" ,"`t" }  |
% { $_ -replace "\\---" ,"`t" }  |
% { $_ -replace "    "  ,"`t" }  |
% { If ( $_ -notmatch "`t+$" ){$_} }
}

use filter

tree /F /A [TARGET_DIRECTORY] | IndentFilter

example

tree command only

PS C:\test> tree .\directory0 /F /A
C:\TEST\DIRECTORY0
|   file1
|
\---directory1
    |   file2
    |
    \---directory2
        |   file3
        |
        \---directory3
PS C:\test>

tree commnad with filter

PS C:\test> tree .\directory0 /F /A | IndentFilter
C:\TEST\DIRECTORY0
        file1
        directory1\
                file2
                directory2\
                        file3
                        directory3\
PS C:\test>

About

Filter for tree command. It can indent without using indentation line.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published