Explain
Tree is an open source tool that supports Linux, Windows, and other operating system platforms. It can be installed directly in Linux sudo apt install tree.On the Windows platform, this command is published in the Cygwin environment and can be selected and installed in the bin path of Cygwin when selecting Package through Cygwin's installer.
Modify content:
Because this tree command can only be run in Cygwin environment on Windows platform, it is not effective in GBK Chinese environment.So Fork made some changes later:
- Tree can run independently of Cygwin in a Windows environment (for example, by copying the tree command to the Git bash bin directory)
- Supports GBK (CP936) characters to better display the tree structure of directory files
Executable program click link to download: https://github.com/efreykongcn/tree/blob/master/tree.exe
GitHub source address: https://github.com/efreykongcn/tree
Use the Windows compilation environment:
- Compiler: MINGW-W64 8.1.0 GCC
- Development Tools: VS Code & C/C++ Extension
Example run effect:
The following shows the effects of executing native tree commands on the Windows platform, tree.com commands on Windows, and modified commands.
1. Cygwin environment original tree command effect
Running the tree command in Cygwin's Terminal displays all directories and files under the specified folder in a visual tree structure.In the GBK character set environment (the default character set in Windows 10), the program can only display the tree structure of directory files in standard ASCII characters.The Cygwin Terminal runs the tree command as follows:
$ tree . |-- CHANGES |-- color.c |-- doc | |-- tree.1 | |-- tree.1.fr | `-- xml.dtd |-- file.c |-- hash.c |-- html.c |-- INSTALL |-- json.c |-- LICENSE |-- Makefile |-- mingw-w64 | |-- include | | |-- grp.h | | |-- langinfo.h | | |-- pwd.h | | |-- stat.h | | |-- types.h | | `-- unistd.h | |-- mingw-w64-grp.c | |-- mingw-w64-langinfo.c | |-- mingw-w64-pwd.c | `-- mingw-w64-unistd.c |-- README |-- README.md |-- strverscmp.c |-- TODO |-- tree.c |-- tree.exe |-- tree.h |-- unix.c `-- xml.c 3 directories, 31 files
2. Windows native tree.com command effect
Windows has its own tree.com command, but it shows weaker effects and functions. Use the tree.com/f command in PowerShell to see the effect:
Folder PATH listing for volume Windows Volume serial number is 6AA8-4173 C:. │ CHANGES │ color.c │ file.c │ hash.c │ html.c │ INSTALL │ json.c │ LICENSE │ Makefile │ README │ README.md │ strverscmp.c │ TODO │ tree.c │ tree.exe │ tree.h │ unix.c │ xml.c │ ├─.vscode │ c_cpp_properties.json │ launch.json │ tasks.json │ ├─doc │ tree.1 │ tree.1.fr │ xml.dtd │ └─mingw-w64 │ mingw-w64-grp.c │ mingw-w64-langinfo.c │ mingw-w64-pwd.c │ mingw-w64-unistd.c │ └─include grp.h langinfo.h pwd.h stat.h types.h unistd.h
3. The modified tree command effect
This modification came from the discovery that the tree command was not implemented in the windows environment in Git Bash when it was used.Therefore, you plan to port this open source tree command to the Git bash environment.
This modification was made for the purpose of making the tree command independent of the Cygwin environment and enhancing the display in the Chinese environment of Windows.The modified tree runs the tree.exe command in PowerShell as follows:
$ tree . ├── CHANGES ├── color.c ├── doc │ ├── tree.1 │ ├── tree.1.fr │ └── xml.dtd ├── file.c ├── hash.c ├── html.c ├── INSTALL ├── json.c ├── LICENSE ├── Makefile ├── mingw-w64 │ ├── include │ │ ├── grp.h │ │ ├── langinfo.h │ │ ├── pwd.h │ │ ├── stat.h │ │ ├── types.h │ │ └── unistd.h │ ├── mingw-w64-grp.c │ ├── mingw-w64-langinfo.c │ ├── mingw-w64-pwd.c │ └── mingw-w64-unistd.c ├── README ├── README.md ├── strverscmp.c ├── TODO ├── tree.c ├── tree.exe ├── tree.h ├── unix.c └── xml.c 3 directories, 31 files
View the modified version information:
$ tree --version tree v1.8.0 (c) 1996 - 2018 by Steve Baker, Thomas Moore, Francesc Rocher, Florian Sesser, Kyosuke Tokoro MINGW-W64 & GBK support added by Efrey Kong