git bash in git tutorial doesn't support tree command

git bash in git tutorial doesn't support tree command ...
Popular science time
Back to the point
Lazy direct
Review summary
git bash in git tutorial doesn't support tree command

Tree command package download address: https://jaist.dl.sourceforge.net/project/gnuwin32/tree/1.5.2.2/tree-1.5.2.2-bin.zip

git bash   yes   Windows   User installation   git   The command line tool installed by default not only has a beautiful interface, but also has good functions. It can be replaced in most cases   Windows   Native   cmd   Command line

However, git bash   The command line is not a panacea and cannot be completely replaced   cmd  , For details, please refer to   mintty   Official website Relevant description.

mintty is not a full replacement for the Windows Console window

git bash   The command line is used by default   mintty   As a terminal simulator, and   mintty   Guan Xuan said he could not completely replace him   CMD, which means   git bash   May not have some   cmd   Command

For a simple example, if you want to view the file structure of the current directory, it's best to display it in the form of directory tree. Smart, you can get the guessed tree   Command

git bash   Enter in the command line   tree   The command found no such command

Copy
snowdreams1006@home MINGW64 /g/sublime/test $ tree bash: tree: command not found

For verification, No   tree   Command, let's open it directly   git bash   Supported command file directory, check whether there is   tree.exe   Documents

stay   git bash   Right click the desktop shortcut and select the open file location. It is currently in   git   Enter the installation directory of. \ usr\bin   folder.

After verification, git bash   The supported command files were not found   tree.exe   File, so it is really not supported   tree   Command

However, CMD   Enter in the built-in command line   tree   It was found that the directory tree can be output. It turned out that   cmd   support   tree   Command

Copy
G:\sublime\test>tree Folder for working volumes PATH list The volume serial number is 00000081 CC3C:50D0 G:. ├─cmd └─git

tree   The command actually calls   tree.com   Not common   tree.exe   Format

Popular science time #

Now we know   git bash   Some are not supported by the provided terminal emulator   linux   Commands, but why not and how can I support them?

These problems must wait until we find out   mintty   The above-mentioned problems can be better solved through a good circle of friends. Next, let's simply popularize science   mintty   A circle of friends

For the source of popular science knowledge, please refer to the previous article: < < circle of friends behind git bash > >

mintty   What is it? #

Mintty   yes   Cygwin,MSYS   or   Msys2   Terminal emulators, derived projects, and   WSL.

mintty   Open source terminal simulator, based on   putty   Terminal simulation and   Windows   Front page

mintty   As an excellent terminal simulator, it is not only the default terminal on other systems, but also   git bash   Default terminal for

Copy
$ mintty --help Usage: mintty [OPTION]... [ PROGRAM [ARG]... | - ] Start a new terminal session running the specified program or the user's shell. If a dash is given instead of a program, invoke the shell as a login shell. Options: -c, --config FILE Load specified config file -e, --exec Treat remaining arguments as the command to execute -h, --hold never|start|error|always Keep window open after command finishes -i, --icon FILE[,IX] Load window icon from file, optionally with index -l, --log FILE|- Log output to file or stdout -o, --option OPT=VAL Override config file option with given value -p, --position X,Y Open window at specified coordinates -s, --size COLS,ROWS Set screen size in characters -t, --title TITLE Set window title (default: the invoked command) -u, --utmp Create a utmp entry -w, --window normal|min|max|full|hide Set initial window state --class CLASS Set window class name (default: mintty) -H, --help Display help and exit -V, --version Print version information and exit

If you want to customize   mintty   Terminal, in   git bash   Right click the command line interface and select option settings to open the settings page

mingw   What is it? #

mingw   yes   Minimalist GNU for Windows   The abbreviation for is   Microsoft Windows   A minimalist development environment for applications

msys   What is it? #

MSYS   yes   Minimal SYStem   The abbreviation for is   Bourne Shell   Command line interpreter system. As   Microsoft   of   cmd.exe   It provides a general command line environment, especially suitable for working with   MinGW   Used together to port many open source applications to   MS Windows platform; It is   Cygwin-1.3   It contains a small part   Unix   Tools can help achieve this goal

cygwin   What is it? #

of large number   GNU   And open source tools that provide similar   Windows   Upper   Linux   Features of the distribution

gnu   What is it? #

GNU   yes   GNU's Not Unix   Recursive abbreviation for free software operating system

Sorting out the relationship between the circle of friends #

git bash   use   mintty   As a terminal simulator, and   mintty   Terminal is   mingw  , msys2   and   cygwin's default terminal, these "operating systems" are more or less   GNU   Part of the

GNU   It is the result of the free software movement. It puts forward the concept of free software and free software operating system

Because of this, there are talented people from generation to generation. Predecessors plant trees and later generations enjoy the cool, Cygwin   As   GNU   One member, proposed to   Windows   Create   Linux   Develop a complete set of solutions

Perhaps because this scheme is too complete and fully functional, the software package is huge, so   MinGW   and   MSYS   Based on it, we carry out simplification and reconstruction, retain the simplest function, and develop a "minimalist GNU"

The power of open source is sustainable. Slowly, the built-in terminal functions of these operating systems are also extracted separately, mintty   As their default terminal, they also gradually provide terminal simulator service independently, which can be easily installed and integrated with various systems

When it comes to open source, nature is indispensable   git   However, distributed version control system, an excellent tool, should benefit all mankind   git   Only classes are supported per se   Unix   System, not provided   WIndows   System support

Git For Windows   The number of organizations increased   git   yes   Windows   The technology behind the system is mostly inseparable from the above introduction   GNU   Operating system

Git Bash Here   then is   Git For Windows   The terminal simulator used is the star simulator   mintty.

Back to the point #

How can it help us solve the problem after we find out the context of the matter?

Great help, the root shaving problem has found the source, and the problem will be solved naturally!

I advise teenagers to give up #

Are you sure you're not teasing me? Let me just give up?

Pro, I'm really sorry. Giving up is the fastest way to solve the problem!

...

Talk about why you give up?

git bash   The command line uses   mintty   Terminal, and   mintty   The terminal cannot be completely replaced   cmd  , There is also no package management tool for us to extend third-party commands

So by default, if some commands are not provided, we have to give up   git bash   Use these commands on the command line

If this road is blocked, we will naturally seek other solutions, such as using   cmd   Command line or other third-party software, there is no need to insist on using git bash!

Since this article is   tree   For the discussion triggered by the command, let's talk about the skills related to the topic, otherwise it's not off the topic?

tree   Command although   git bash   No, but   cmd   But it's built in

It is worth noting that cmd   Provided   tree   Commands are special and not common  . exe   End file, but  . com   End of file

therefore   git bash   Medium input   tree   Command itself  / usr/bin   Not in   tree.exe   File, and there are no files in the system   tree.exe   Command, then you will be prompted that you can't find the command!

Manual completion command #

Then the first calling method is to complete the suffix, so it can be called naturally   cmd   of   tree.com   Command

git bash   Not recognized  . com   Suffix commands, entering   tree   I thought it was when I ordered it   tree.exe  , actually   tree   The command should be   tree.com   Short for

According to my many years of development experience, the problem of garbled code is mostly caused by coding problems, so modifying the coding settings of the terminal should be able to solve the problem

Right click in the command line window to pop up   mintty   On the setting page of the terminal, select the localization configuration in text, select simplified Chinese (zh_CN), and set the character set to UTF-8

Instantly beaten in the face, whether it's the original git bash   The command line window is still a new command line window, and it is still garbled!

However, I will not admit being beaten in the face. The world is drunk and I wake up alone. It must be   bug, ha ha!

In fact, Chinese garbled code is really   bug  , It's officially recognized   bug   Oh, I haven't been beaten in the face. I'll introduce it later

call   cmd   program #

Since git bash   Not provided   tree   Command, and it happens   cmd   Provided   tree   Command, then why not use the hand of others to achieve their own goals?

stay   cmd   Used in   tree   You can get the directory tree structure by directly entering the command, but now you need to   git bash   Call in   cmd   Medium   tree   Command

Copy
# Directly enter the 'tree' command and respond correctly without Chinese garbled code G:\sublime\test>tree Folder for working volumes PATH list The volume serial number is 00000093 CC3C:50D0 G:. ├─cmd └─git # Enter 'cmd tree' command, although there is no error, but there is no correct response G:\sublime\test>cmd tree Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. All rights reserved.

cmd   Direct input in   tree   Command is OK without passing   cmd tree   In this way, I thought you were going to call   cmd   Orders!

Therefore, we need to tell git bash   To pass   cmd   Go call   tree   Command

Copy
# Note that the prefix is` snowdreams1006@home MINGW64 ` indicates that you are currently in the 'git bash' environment snowdreams1006@home MINGW64 /g/sublime/test # Enter 'cmd tree' command, although there is no error, but there is no correct response, and there are still Chinese garbled codes $ cmd tree Microsoft Windows [▒Fen 6.3.9600] (c) 2013 Microsoft Corporation▒▒▒▒▒▒▒▒▒▒Ȩ▒▒▒▒ # Output the 'tree' command and respond correctly, but there are Chinese garbled codes. At this time, the command line prefix has been changed to 'G: \ sublime \ test >' indicating that it is no longer in the 'git bash' environment! G:\sublime\test>tree tree ▒▒ ▒▒▒▒ ▒▒▒ļ▒▒▒ PATH ▒б▒ ▒▒▒▒▒к▒Ϊ 0000006B CC3C:50D0 G:. ▒▒▒▒cmd ▒▒▒▒git

From the above operation results, it is not difficult to find the following problems

  • cmd tree   Command switch to   cmd   Environment, and tree   The command was not executed
    In other words, cmd tree   and   cmd dir   perhaps   cmd   The same function is to switch the current   bash   environment
  • get into   cmd   Command line run   tree   Can get the correct response, but there is Chinese garbled code
  • Want to quit   cmd   Environment, Ctrl + C   Combine to return to   git bash   environment

It can be seen that without adding any parameters, you venture into   cmd   The environment is still troublesome, so the following commands with parameters are provided to help us burn after reading

cmd //c tree   The command will burn immediately after reading, indicating that you exit immediately after execution

Copy
snowdreams1006@home MINGW64 /g/sublime/test $ cmd //c tree ▒▒ ▒▒▒▒ ▒▒▒ļ▒▒▒ PATH ▒б▒ ▒▒▒▒▒к▒Ϊ 00000008 CC3C:50D0 G:. ▒▒▒▒cmd ▒▒▒▒git snowdreams1006@home MINGW64 /g/sublime/test $

We were there before and after the order   git bash   Environment and in   cmd   To get the correct response results, the only difference is to add more  // c   Parameter to exit immediately after executing the command   cmd   environment

Elegant call   cmd #

In a brief summary, how to   git bash   With the help of   cmd   realization   tree   Command

  • tree.com  : Complete the suffix of the calling command and directly call the system command
  • cmd //c tree  : With the help of   cmd   function   tree   Command to implement the call   tree   The purpose of
  • Both methods have the problem of Chinese garbled code. Even if the terminal coding method is set, it does not solve the garbled code

call   tree   The purpose of the command has been achieved. The unsolved problem is Chinese garbled code

The fastest way to solve the problem is to Baidu or seek help from the official website. This time I choose the latter, because everyone can baidu, so I don't have to talk about it again!

Briefly explain the meaning of this paragraph:

If in   mintty   Terminal call native   cmd   There is no problem with simple output instructions, and there may be problems with interactive instructions
Therefore, it is recommended to use   winpty   Wrap and call native   cmd   Procedure

winpty   Is a method of providing and cmd   Communication software package, please refer to https://github.com/rprichard/winpty

What's the magic? Might as well add   winpty   have a try!

Copy
snowdreams1006@home MINGW64 /g/sublime/test # `winpty` + `tree.com `: normal output without Chinese garbled code $ winpty tree.com Folder for working volumes PATH list The volume serial number is 00000074 CC3C:50D0 G:. ├─cmd └─git snowdreams1006@home MINGW64 /g/sublime/test # `winpty` + `cmd //c tree `: normal output without Chinese garbled code $ winpty cmd //c tree Folder for working volumes PATH list The volume serial number is 000000 B3 CC3C:50D0 G:. ├─cmd └─git snowdreams1006@home MINGW64 /g/sublime/test $

Sure enough, it's a magic medicine. It cured my old cold legs for many years at once!

  • winpty tree.com  : Call the system command directly instead of the nickname
  • winpty cmd //c tree  : Using the hand of others to call system commands in a disguised form

As mentioned above, setting the file code should be able to solve the problem of Chinese garbled code. As a result, there is still garbled code. Guess so   bug  , Not in the face now?

Now that the solution has been provided, should the article stop here?

No, no, no, it's far from over. It's just an appetizer. The good play is still ahead

Moreover, this command is too long to remember!

It's very simple. You can set an alias and set common commands as aliases, so you can remember!

input   alias   The command does not report an error, indicating that the current environment supports setting aliases

Copy
snowdreams1006@home MINGW64 /g/sublime/test $ alias alias ll='ls -l' alias ls='ls -F --color=auto --show-control-chars' alias node='winpty node.exe'

according to   linux   The operation habit of the command line is generally temporary. If you want to take effect permanently, you should write it to the file. Of course, this alias should be set as a permanent file once and for all

Copy
snowdreams1006@home MINGW64 /g/sublime/test $ cat /etc/bashrc cat: /etc/bashrc: No such file or directory snowdreams1006@home MINGW64 /g/sublime/test $ cat ~/.bashrc cat: /c/Users/snowdreams1006/.bashrc: No such file or directory

Even the configuration file does not exist?

Of course it doesn't exist! Wake up, you're   Windows   Not on the system   Linux   System, where can I get these configuration files for you?

The basic question of philosophy flashed into my mind: who am I, where am I, and what am I doing?

I am   Windows   System user, in progress   git bash   An attempt was made to set an alias on the command line, but a similar error was not found   linux   Configuration file

Now that you know where you came out, go there and see if you found anything?

Copy
snowdreams1006@home MINGW64 /g/sublime/test $ cd /e/git snowdreams1006@home MINGW64 /e/git $ winpty tree.com Folder for volume software PATH list The volume serial number is 00000063 223 E:7300 E:. ├─bin ├─cmd ├─dev │ ├─mqueue │ └─shm ├─etc │ ├─pkcs11 │ ├─pki │ │ └─ca-trust │ │ ├─extracted │ │ │ ├─java │ │ │ ├─openssl │ │ │ └─pem │ │ └─source │ │ └─anchors │ ├─profile.d │ └─ssh ├─mingw64 │ ├─bin │ ├─doc │ │ └─git-credential-manager │ ├─etc │ │ ├─pkcs11 │ │ └─pki │ │ └─ca-trust │ │ └─extracted │ │ ├─java │ │ ├─openssl │ │ └─pem │ ├─lib │ │ ├─dde1.4 │ │ ├─engines │ │ ├─itcl4.0.4 │ │ ├─p11-kit │ │ ├─pkcs11 │ │ ├─reg1.3 │ │ ├─sqlite3.11.0 │ │ ├─tcl8 │ │ │ ├─8.4 │ │ │ │ └─platform │ │ │ ├─8.5 │ │ │ └─8.6 │ │ │ └─tdbc │ │ ├─tcl8.6 │ │ │ ├─encoding │ │ │ ├─http1.0 │ │ │ ├─msgs │ │ │ ├─opt0.4 │ │ │ └─tzdata │ │ │ ├─Africa │ │ │ ├─America │ │ │ │ ├─Argentina │ │ │ │ ├─Indiana │ │ │ │ ├─Kentucky │ │ │ │ └─North_Dakota │ │ │ ├─Antarctica │ │ │ ├─Arctic │ │ │ ├─Asia │ │ │ ├─Atlantic │ │ │ ├─Australia │ │ │ ├─Brazil │ │ │ ├─Canada │ │ │ ├─Chile │ │ │ ├─Etc │ │ │ ├─Europe │ │ │ ├─Indian │ │ │ ├─Mexico │ │ │ ├─Pacific │ │ │ ├─SystemV │ │ │ └─US │ │ ├─thread2.7.3 │ │ └─tk8.6 │ │ ├─demos │ │ │ └─images │ │ ├─images │ │ ├─msgs │ │ └─ttk │ ├─libexec │ │ └─git-core │ │ └─mergetools │ ├─share │ │ ├─antiword │ │ ├─doc │ │ │ ├─connect │ │ │ ├─git-doc │ │ │ │ ├─howto │ │ │ │ └─technical │ │ │ └─nghttp2 │ │ ├─gettext-0.19.7 │ │ │ └─its │ │ ├─git │ │ │ ├─bindimage.txt │ │ │ └─completion │ │ ├─git-core │ │ │ └─templates │ │ │ ├─hooks │ │ │ └─info │ │ ├─git-gui │ │ │ └─lib │ │ ├─gitweb │ │ │ └─static │ │ ├─licenses │ │ │ ├─bzip2 │ │ │ ├─expat │ │ │ ├─gcc-libs │ │ │ ├─gettext │ │ │ │ ├─gettext-runtime │ │ │ │ │ ├─intl │ │ │ │ │ └─libasprintf │ │ │ │ ├─gettext-tools │ │ │ │ │ └─gnulib-lib │ │ │ │ │ └─libxml │ │ │ │ └─gnulib-local │ │ │ │ └─lib │ │ │ │ └─libxml │ │ │ ├─libffi │ │ │ ├─libiconv │ │ │ │ └─libcharset │ │ │ ├─libssh2 │ │ │ ├─libsystre │ │ │ ├─libtasn1 │ │ │ ├─libtre │ │ │ ├─libwinpthread │ │ │ │ └─mingw-w64-libraries │ │ │ │ └─winpthreads │ │ │ ├─openssl │ │ │ ├─wineditline │ │ │ └─zlib │ │ ├─nghttp2 │ │ ├─p11-kit │ │ │ └─modules │ │ ├─perl5 │ │ │ └─site_perl │ │ │ └─Git │ │ │ └─SVN │ │ │ └─Memoize │ │ └─pki │ │ └─ca-trust-source │ └─ssl │ └─certs ├─tmp └─usr ├─bin │ ├─core_perl │ └─vendor_perl ├─lib │ ├─awk │ ├─coreutils │ ├─gawk │ ├─gnupg │ │ └─gnupg │ ├─openssl │ │ └─engines │ ├─p11-kit │ ├─perl5 │ │ ├─core_perl │ │ │ ├─auto │ │ │ │ ├─arybase │ │ │ │ ├─attributes │ │ │ │ ├─B │ │ │ │ ├─Compress │ │ │ │ │ └─Raw │ │ │ │ │ ├─Bzip2 │ │ │ │ │ └─Zlib │ │ │ │ ├─Cwd │ │ │ │ ├─Data │ │ │ │ │ └─Dumper │ │ │ │ ├─DB_File │ │ │ │ ├─Devel │ │ │ │ │ ├─Peek │ │ │ │ │ └─PPPort │ │ │ │ ├─Digest │ │ │ │ │ ├─MD5 │ │ │ │ │ └─SHA │ │ │ │ ├─Encode │ │ │ │ │ ├─Byte │ │ │ │ │ ├─CN │ │ │ │ │ ├─EBCDIC │ │ │ │ │ ├─JP │ │ │ │ │ ├─KR │ │ │ │ │ ├─Symbol │ │ │ │ │ ├─TW │ │ │ │ │ └─Unicode │ │ │ │ ├─Fcntl │ │ │ │ ├─File │ │ │ │ │ ├─DosGlob │ │ │ │ │ └─Glob │ │ │ │ ├─Filter │ │ │ │ │ └─Util │ │ │ │ │ └─Call │ │ │ │ ├─GDBM_File │ │ │ │ ├─Hash │ │ │ │ │ └─Util │ │ │ │ │ └─FieldHash │ │ │ │ ├─I18N │ │ │ │ │ └─Langinfo │ │ │ │ ├─IO │ │ │ │ ├─IPC │ │ │ │ │ └─SysV │ │ │ │ ├─List │ │ │ │ │ └─Util │ │ │ │ ├─Math │ │ │ │ │ └─BigInt │ │ │ │ │ └─FastCalc │ │ │ │ ├─MIME │ │ │ │ │ └─Base64 │ │ │ │ ├─mro │ │ │ │ ├─NDBM_File │ │ │ │ ├─ODBM_File │ │ │ │ ├─Opcode │ │ │ │ ├─PerlIO │ │ │ │ │ ├─encoding │ │ │ │ │ ├─mmap │ │ │ │ │ ├─scalar │ │ │ │ │ └─via │ │ │ │ ├─POSIX │ │ │ │ ├─re │ │ │ │ ├─SDBM_File │ │ │ │ ├─Socket │ │ │ │ ├─Storable │ │ │ │ ├─Sys │ │ │ │ │ ├─Hostname │ │ │ │ │ └─Syslog │ │ │ │ ├─threads │ │ │ │ │ └─shared │ │ │ │ ├─Tie │ │ │ │ │ └─Hash │ │ │ │ │ └─NamedCapture │ │ │ │ ├─Time │ │ │ │ │ ├─HiRes │ │ │ │ │ └─Piece │ │ │ │ ├─Unicode │ │ │ │ │ └─Collate │ │ │ │ ├─Win32 │ │ │ │ ├─Win32API │ │ │ │ │ └─File │ │ │ │ └─Win32CORE │ │ │ ├─B │ │ │ ├─Compress │ │ │ │ └─Raw │ │ │ ├─CORE │ │ │ ├─Data │ │ │ ├─Devel │ │ │ ├─Digest │ │ │ ├─Encode │ │ │ │ ├─CN │ │ │ │ ├─JP │ │ │ │ ├─KR │ │ │ │ ├─MIME │ │ │ │ │ └─Header │ │ │ │ └─Unicode │ │ │ ├─File │ │ │ │ └─Spec │ │ │ ├─Filter │ │ │ │ └─Util │ │ │ ├─Hash │ │ │ │ └─Util │ │ │ ├─I18N │ │ │ ├─IO │ │ │ │ └─Socket │ │ │ ├─IPC │ │ │ ├─List │ │ │ │ └─Util │ │ │ ├─Math │ │ │ │ └─BigInt │ │ │ ├─MIME │ │ │ ├─PerlIO │ │ │ ├─Scalar │ │ │ ├─Sub │ │ │ ├─Sys │ │ │ ├─threads │ │ │ ├─Tie │ │ │ │ └─Hash │ │ │ ├─Time │ │ │ ├─Unicode │ │ │ │ └─Collate │ │ │ └─Win32API │ │ └─vendor_perl │ │ ├─auto │ │ │ ├─HTML │ │ │ │ └─Parser │ │ │ ├─Net │ │ │ │ └─SSLeay │ │ │ ├─SVN │ │ │ │ ├─_Client │ │ │ │ ├─_Core │ │ │ │ ├─_Delta │ │ │ │ ├─_Fs │ │ │ │ ├─_Ra │ │ │ │ ├─_Repos │ │ │ │ └─_Wc │ │ │ └─Term │ │ │ └─ReadKey │ │ ├─HTML │ │ ├─Net │ │ │ └─SSLeay │ │ ├─SVN │ │ └─Term │ ├─pkcs11 │ ├─sasl2 │ ├─ssh │ ├─tar │ └─terminfo │ ├─63 │ ├─64 │ └─78 ├─libexec ├─share │ ├─bash-completion │ │ └─completions │ ├─cygwin │ ├─git │ ├─gnupg │ ├─licenses │ │ ├─curl │ │ ├─dos2unix │ │ ├─expat │ │ ├─file │ │ ├─gcc-libs │ │ ├─libffi │ │ ├─libsasl │ │ ├─libsqlite │ │ ├─libssh2 │ │ ├─mintty │ │ ├─ncurses │ │ ├─openssh │ │ ├─openssl │ │ ├─p11-kit │ │ ├─perl-Net-SSLeay │ │ ├─perl-TermReadKey │ │ ├─unzip │ │ ├─vim │ │ └─zlib │ ├─misc │ ├─p11-kit │ │ └─modules │ ├─perl5 │ │ ├─core_perl │ │ │ ├─App │ │ │ │ └─Prove │ │ │ │ └─State │ │ │ │ └─Result │ │ │ ├─Archive │ │ │ │ └─Tar │ │ │ ├─Attribute │ │ │ ├─autodie │ │ │ │ ├─exception │ │ │ │ └─Scope │ │ │ ├─B │ │ │ ├─Carp │ │ │ ├─Class │ │ │ ├─Compress │ │ │ ├─Config │ │ │ │ └─Perl │ │ │ ├─CPAN │ │ │ │ ├─Exception │ │ │ │ ├─FTP │ │ │ │ ├─HTTP │ │ │ │ ├─Kwalify │ │ │ │ ├─LWP │ │ │ │ ├─Meta │ │ │ │ └─Plugin │ │ │ ├─DBM_Filter │ │ │ ├─Devel │ │ │ ├─Digest │ │ │ ├─Encode │ │ │ ├─encoding │ │ │ ├─Exporter │ │ │ ├─ExtUtils │ │ │ │ ├─CBuilder │ │ │ │ │ └─Platform │ │ │ │ │ └─Windows │ │ │ │ ├─Command │ │ │ │ ├─Constant │ │ │ │ ├─Liblist │ │ │ │ ├─MakeMaker │ │ │ │ │ └─version │ │ │ │ ├─ParseXS │ │ │ │ └─Typemaps │ │ │ ├─File │ │ │ ├─Filter │ │ │ ├─Getopt │ │ │ ├─HTTP │ │ │ ├─I18N │ │ │ │ └─LangTags │ │ │ ├─IO │ │ │ │ ├─Compress │ │ │ │ │ ├─Adapter │ │ │ │ │ ├─Base │ │ │ │ │ ├─Gzip │ │ │ │ │ ├─Zip │ │ │ │ │ └─Zlib │ │ │ │ ├─Socket │ │ │ │ └─Uncompress │ │ │ │ └─Adapter │ │ │ ├─IPC │ │ │ ├─JSON │ │ │ │ └─PP │ │ │ ├─Locale │ │ │ │ ├─Codes │ │ │ │ └─Maketext │ │ │ ├─Math │ │ │ │ ├─BigFloat │ │ │ │ └─BigInt │ │ │ ├─Memoize │ │ │ ├─Module │ │ │ │ ├─CoreList │ │ │ │ └─Load │ │ │ ├─Net │ │ │ │ └─FTP │ │ │ ├─overload │ │ │ ├─Params │ │ │ ├─Parse │ │ │ │ └─CPAN │ │ │ ├─Perl │ │ │ ├─PerlIO │ │ │ │ └─via │ │ │ ├─Pod │ │ │ │ ├─Perldoc │ │ │ │ ├─Simple │ │ │ │ └─Text │ │ │ ├─Search │ │ │ ├─TAP │ │ │ │ ├─Formatter │ │ │ │ │ ├─Console │ │ │ │ │ └─File │ │ │ │ ├─Harness │ │ │ │ └─Parser │ │ │ │ ├─Iterator │ │ │ │ ├─Result │ │ │ │ ├─Scheduler │ │ │ │ ├─SourceHandler │ │ │ │ └─YAMLish │ │ │ ├─Term │ │ │ ├─Test │ │ │ │ ├─Builder │ │ │ │ │ ├─IO │ │ │ │ │ └─Tester │ │ │ │ ├─Tester │ │ │ │ └─use │ │ │ ├─Text │ │ │ ├─Thread │ │ │ ├─Tie │ │ │ ├─Time │ │ │ ├─Unicode │ │ │ │ └─Collate │ │ │ │ └─CJK │ │ │ ├─unicore │ │ │ │ ├─lib │ │ │ │ │ ├─Age │ │ │ │ │ ├─Alpha │ │ │ │ │ ├─Bc │ │ │ │ │ ├─BidiC │ │ │ │ │ ├─BidiM │ │ │ │ │ ├─Blk │ │ │ │ │ ├─Bpt │ │ │ │ │ ├─Cased │ │ │ │ │ ├─Ccc │ │ │ │ │ ├─CE │ │ │ │ │ ├─CI │ │ │ │ │ ├─CompEx │ │ │ │ │ ├─CWCF │ │ │ │ │ ├─CWCM │ │ │ │ │ ├─CWKCF │ │ │ │ │ ├─CWL │ │ │ │ │ ├─CWT │ │ │ │ │ ├─CWU │ │ │ │ │ ├─Dash │ │ │ │ │ ├─Dep │ │ │ │ │ ├─DI │ │ │ │ │ ├─Dia │ │ │ │ │ ├─Dt │ │ │ │ │ ├─Ea │ │ │ │ │ ├─Ext │ │ │ │ │ ├─Gc │ │ │ │ │ ├─GCB │ │ │ │ │ ├─GrBase │ │ │ │ │ ├─Hex │ │ │ │ │ ├─Hst │ │ │ │ │ ├─Hyphen │ │ │ │ │ ├─IDC │ │ │ │ │ ├─Ideo │ │ │ │ │ ├─IDS │ │ │ │ │ ├─In │ │ │ │ │ ├─Jg │ │ │ │ │ ├─Jt │ │ │ │ │ ├─Lb │ │ │ │ │ ├─LOE │ │ │ │ │ ├─Lower │ │ │ │ │ ├─Math │ │ │ │ │ ├─NChar │ │ │ │ │ ├─NFCQC │ │ │ │ │ ├─NFDQC │ │ │ │ │ ├─NFKCQC │ │ │ │ │ ├─NFKDQC │ │ │ │ │ ├─Nt │ │ │ │ │ ├─Nv │ │ │ │ │ ├─PatSyn │ │ │ │ │ ├─PatWS │ │ │ │ │ ├─Perl │ │ │ │ │ ├─QMark │ │ │ │ │ ├─SB │ │ │ │ │ ├─Sc │ │ │ │ │ ├─Scx │ │ │ │ │ ├─SD │ │ │ │ │ ├─STerm │ │ │ │ │ ├─Term │ │ │ │ │ ├─UIdeo │ │ │ │ │ ├─Upper │ │ │ │ │ ├─WB │ │ │ │ │ ├─XIDC │ │ │ │ │ └─XIDS │ │ │ │ └─To │ │ │ ├─User │ │ │ ├─version │ │ │ ├─warnings │ │ │ └─Win32API │ │ │ └─File │ │ └─vendor_perl │ │ ├─Authen │ │ │ └─SASL │ │ │ └─Perl │ │ ├─Convert │ │ ├─Date │ │ │ └─Language │ │ ├─Encode │ │ ├─Error │ │ ├─File │ │ ├─HTML │ │ ├─HTTP │ │ │ ├─Cookies │ │ │ ├─Headers │ │ │ └─Request │ │ ├─IO │ │ │ └─Socket │ │ │ └─SSL │ │ ├─LWP │ │ │ ├─Authen │ │ │ └─Protocol │ │ ├─Mail │ │ │ ├─Field │ │ │ └─Mailer │ │ ├─MIME │ │ │ ├─Decoder │ │ │ ├─Field │ │ │ └─Parser │ │ ├─Net │ │ │ ├─HTTP │ │ │ └─SMTP │ │ ├─Time │ │ ├─URI │ │ │ ├─file │ │ │ └─urn │ │ └─WWW │ │ └─RobotRules │ ├─pki │ │ └─ca-trust-source │ ├─tabset │ ├─terminfo │ │ ├─63 │ │ ├─64 │ │ └─78 │ └─vim │ └─vim74 │ ├─autoload │ │ └─xml │ ├─colors │ ├─compiler │ ├─doc │ ├─ftplugin │ ├─indent │ ├─keymap │ ├─macros │ │ ├─hanoi │ │ ├─life │ │ ├─maze │ │ └─urm │ ├─pack │ │ └─dist │ │ └─opt │ │ ├─dvorak │ │ │ ├─dvorak │ │ │ └─plugin │ │ ├─editexisting │ │ │ └─plugin │ │ ├─justify │ │ │ └─plugin │ │ ├─matchit │ │ │ ├─doc │ │ │ └─plugin │ │ ├─shellmenu │ │ │ └─plugin │ │ └─swapmouse │ │ └─plugin │ ├─plugin │ ├─print │ ├─spell │ ├─syntax │ ├─tools │ └─tutor └─ssl ├─certs └─misc

See familiar  ./ etc/bash.bashrc   The file is very friendly at once. Set the alias again

Copy
snowdreams1006@home MINGW64 /e/git $ echo "# Set alias for tree command" >> ./etc/bash.bashrc snowdreams1006@home MINGW64 /e/git $ echo "alias tree='winpty tree.com'" >> ./etc/bash.bashrc snowdreams1006@home MINGW64 /e/git $ source ./etc/bash.bashrc

Now test whether the directory tree can be printed correctly:

Copy
snowdreams1006@home MINGW64 /e/git $ cd /g/sublime/test snowdreams1006@home MINGW64 /g/sublime/test $ tree Folder for working volumes PATH list The volume serial number is 000000 A3 CC3C:50D0 G:. ├─cmd └─git

The pro test is effective, and the command can be simplified by setting an alias, so as to realize the   git bash   Elegant call in   tree   Command

A stubborn young man is determined to go his own way #

Since the boy doesn't listen to advice, I have to go my own way with you

git bash   I won't support it   tree   Command means   mintty   Terminal does not support   tree   Command, but   mintty   Since as an excellent terminal simulator, it is impossible not to support it   tree   Command, otherwise   cygwin  , msys2   and   mingw   Such systems cannot use it as the default terminal

Recall   linux   System, and the minimum installation version is not supported   tree   Command, which can be extended by the package management tool   tree   Command

Therefore, there are two kinds of ideas, such as   linux   Then install through the package management tool   tree   Command, or extended by source code compilation   tree   Command

The first requires a package management tool, and git bash   Using   mintty   The terminal does not provide corresponding package management tools
So I want to install it through the package management tool   tree   There is no way to command

Package management tool installation #

If we can provide package management tools, we can   linux   The installation of third-party commands is the same as that of the system   tree   The order was given

The first thought is   mintty   Is there any relevant explanation on the official website? Unfortunately, mintty   It is generally installed through the package management tool. A separate terminal does not have a package management environment, so it is unable to call relevant commands

Copy
Administrator@snowdreams1006 MINGW64 /f/workspace/test $ mingw-get bash: mingw-get: command not found Administrator@snowdreams1006 MINGW64 /f/workspace/test $ pacman bash: pacman: command not found

However, a small setback will not give up easily, since   mintty   If the official website can't provide effective help, let's go back to the initial installation   git   Take a look   git   Can you provide relevant package management tools

Frequent occurrence   Git for Windows   Noun, according to the command rules of the software, Git for Windows   It may be independent software, not to mention   git bash   Integrated terminals are not self-developed terminals, but third-party ones   mintty   Terminal

So we have reason to believe   Git for Windows   Another team is maintaining, not   Git   Team

git-for-windows   Official website:   https://gitforwindows.org/

According to the official instructions, relevant dependencies are being downloaded after installation. If the download speed is slow, please solve it yourself

After downloading, the original   cmd   The window automatically closes and opens a new one   git bash   Window

Copy
Administrator@snowdreams1006 MINGW64 / (master) $ sdk help The 'sdk' shell function helps you to get up and running with the Git for Windows SDK. The available subcommands are: create-desktop-icon: install a desktop icon that starts the Git for Windows SDK Bash. cd <project>: initialize/update a worktree and cd into it. Known projects: git git-extra msys2-runtime installer build-extra MINGW-packages MSYS2-packages mingw-w64-busybox mingw-w64-curl mingw-w64-cv2pdb mingw-w64-git mingw-w64-git-credential-manager mingw-w64-git-lfs mingw-w64-git-sizer mingw-w64-wintoast bash curl gawk git-flow gnupg heimdal mintty nodejs openssh openssl perl perl-HTML-Parser perl-Locale-Gettext perl-Net-SSLeay perl-TermReadKey perl-XML-Parser perl-YAML-Syck subversion tig init <project>: initialize and/or update a worktree. Known projects are the same as for the 'cd' command. build <project>: builds one of the following: git-and-installer git git-extra msys2-runtime installer mingw-w64-busybox mingw-w64-curl mingw-w64-cv2pdb mingw-w64-git mingw-w64-git-credential-manager mingw-w64-git-lfs mingw-w64-git-sizer mingw-w64-wintoast bash curl gawk git-flow gnupg heimdal mintty nodejs openssh openssl perl perl-HTML-Parser perl-Locale-Gettext perl-Net-SSLeay perl-TermReadKey perl-XML-Parser perl-YAML-Syck subversion tig edit <file>: edit a well-known file. Well-known files are: git-sdk.sh sdk.completion ReleaseNotes.md install.iss reload: reload the 'sdk' function.

Now after the installation is complete, we open it again   Git for Windows   It is not difficult to find that the project uses   MSYS2   Project, then the problem can be solved easily

According to popular science knowledge, we know   MSYS2   and   MinGW   Are operating systems, and   Git For Windows   Combine the two and use by default   MSYS2   Package management tools for

Copy
Administrator@snowdreams1006 MINGW64 / (master) $ Pacman -h usage: Pacman <operation> [...] operation: Pacman {-h --help} Pacman {-V --version} Pacman {-D --database} <option> <software package> Pacman {-F --files} [option] [software package] Pacman {-Q --query} [option] [software package] Pacman {-R --remove} [option] <software package> Pacman {-S --sync} [option] [software package] Pacman {-T --deptest} [option] [software package] Pacman {-U --upgrade} [option] <file> use 'Pacman {-h --help}' And an action to see the available options

Exciting moment is coming, in official use   Pacman   install   tree   In addition to the command, we check the current system environment again to ensure that there is no   git bash   Cannot call   tree   Command

Copy
Administrator@snowdreams1006 MINGW64 / (master) $ tree bash: tree: Command not found

call   Pacman -S tree   Command installation   tree   Command

Copy
Administrator@snowdreams1006 MINGW64 / (master) $ Pacman -S tree Resolving dependencies... Looking for package conflicts... software package (1) tree-1.8.0-1 Download size: 0.05 MiB Full installation size: 0.07 MiB :: Install? [Y/n] y Warning: no /var/cache/pacman/pkg/ Cache exists, creating... :: Getting package...... tree-1.8.0-1-x86_64 51.1 KiB 211K/s 00:00 [#####################] 100% (1/1) Checking key in key ring [#####################] 100% (1/1) Checking package integrity [#####################] 100% (1/1) Loading package file [#####################] 100% (1/1) Checking for file conflicts [#####################] 100% (1/1) Checking for available storage space [#####################] 100% :: Processing package changes... (1/1) Installing tree

Verify that the installation is successful, switch to the test directory and call   tree   The command really prints out the directory tree structure

Copy
Administrator@snowdreams1006 MINGW64 / (master) $ pwd / Administrator@snowdreams1006 MINGW64 / (master) $ cd /f/workspace/test Administrator@snowdreams1006 MINGW64 /f/workspace/test $ tree . ├── cmd └── gitbash 2 directories, 0 files

tree.exe   The file does exist. Of course, any third-party command can be installed in this way!

Copy
Administrator@snowdreams1006 MINGW64 / (master) $ pwd / Administrator@snowdreams1006 MINGW64 / (master) $ ls usr/bin/tree.exe usr/bin/tree.exe* Administrator@snowdreams1006 MINGW64 / (master) $ ls usr/bin/tree.exe usr/bin/tree.exe*

However, the matter is not over yet, although printing the current path shows that  / , But if from the ordinary   git bash   Command line window entry  /, Find that they are not consistent!

Text in the upper left corner of the development version:   SDK-64, normal version, upper left corner:   MinGW64.

Things shouldn't be so complicated. I guess if you enter   git sdk   The installation directory should be the same!

Source code compilation and installation #

There is also a source code compilation and installation method. It can be guessed that it will be more troublesome, not only to install   c   Compiling environment, you may also face how to migrate to   Windows   Environmental issues

Excuse me for taking another step first. Goodbye!

But how can the old driver take it away and leave? Didn't he agree to break into the world together?

However, is too laggy and hard to compile. Installation and testing are really challenges. The most important thing is that computer is too long to wait.

Therefore, we have collected some data to facilitate qualified partners to study!

Download link:  

  • stay   mingw  , msys2   perhaps   cygwin   Compile and install on system   tree   of   c   File, final generation   tree.exe   Executable file
  • Independent installation   c   Compilation environment, generated   tree.exe   Executable files can be compatible again   git bash   Supported  . exe   Type, perhaps without conversion
  • Please refer to   linux   Systematic   tree   Command source code:   http://mama.indstate.edu/users/ice/tree/

I think I can hold on for a while, although I can't compile and generate from scratch   tree.exe   Executable, but after studying so many circle of friends, it's enough for me to find a solution

tree   Command source file compiled into   tree.exe   Executable files are hard, but you can find compiled files

Speaking of this, I have to mention the magic   sourceforge   Website, provide source code and download website

We've been saying before   mintty   Terminal simulator, or   mingw  , msys2   and   cygwin   Operating systems, they are more or less similar to   GNU   There are some connections, and   GNU   Is a free software operating system, the source code will be released with the program

So we should be able to   sourceforge   Some clues are found on the website, and there may be packaged executable files. In that case, we don't need to compile and install manually!

Kung Fu pays off. I actually found it. Search   GNU   Found it   gnuwin32   The project provides complete native commands, including what we need   tree   Command

Download link:   https://sourceforge.net/projects/gnuwin32/files/tree/1.5.2.2/tree-1.5.2.2-bin.zip/download

So download the binary file and find the  / bin/tree.exe   And copy it to  / git/usr/bin   Directory, so   git bash   Support itself   tree   The order was given

First, clear the alias set in the previous step to prevent interference, so as to ensure the authenticity and effectiveness of this binary file

Copy
snowdreams1006@home MINGW64 /g/sublime/test # Switch to the 'git' installation directory $ cd /e/git snowdreams1006@home MINGW64 /e/git # Edit the 'bash.bashrc' configuration file to remove the alias $ vim ./etc/bash.bashrc snowdreams1006@home MINGW64 /e/git # View the contents of the configuration file. Alias settings have been removed $ tail ./etc/bash.bashrc [[ "$-" != *i* ]] && return # Set a default prompt of: user@host, MSYSTEM variable, and current_directory #PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]$MSYSTEM\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n\$ ' # Uncomment to use the terminal colours set in DIR_COLORS # eval "$(dircolors -b /etc/DIR_COLORS)" # Fixup git-bash in non login env shopt -q login_shell || . /etc/profile.d/git-prompt.sh snowdreams1006@home MINGW64 /e/git # Refresh the configuration file to take effect immediately $ source ./etc/bash.bashrc snowdreams1006@home MINGW64 /e/git # Remove the 'tree' alias, which is applicable to command-line settings rather than file settings $ unalias tree snowdreams1006@home MINGW64 /e/git # Run the 'tree' command to ensure that the system's' tree.com 'command cannot be called by alias $ tree bash: tree: command not found

Really successfully added   tree.exe   Command, obvious and   cmd   Self contained   tree.com   Inconsistent command

Copy
snowdreams1006@home MINGW64 /e/git $ cd /g/sublime/test snowdreams1006@home MINGW64 /g/sublime/test # Extended command 'tree' help information $ tree.exe --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. -g Displays file group owner or GID number. -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. -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. -S Print with ASCII graphics indentation lines. -n Turn colorization off always (-C overrides). -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. -T string Replace the default HTML title and H1 header with string. -R Rerun tree when max dir level reached. -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. --noreport Turn off file/directory count at end of tree listing. --nolinks Turn off hyperlinks in HTML output. --dirsfirst List directories before files. --charset X Use charset X for HTML and indentation line output. --filelimit # Do not descend dirs with more than # files in them. snowdreams1006@home MINGW64 /g/sublime/test # Native 'tree.com' help information $ winpty tree.com /? Folder for volume software PATH list The volume serial number is 000000 CA 223E:7300 E:\GIT\? invalid path - \GIT\? No subfolders

Although native   cmd   Self contained   tree.com   Command can also print out the directory structure tree, but with extended third parties   tree.exe   Compared with commands, there are too few configurable options. No wonder stubborn teenagers insist on expanding   tree   Command

Lazy direct #

If you want to   git bash   Call in command line   tree   Command, summarizes the following methods

Note: it is gradually complicated from top to bottom, and you can choose according to your own situation

  • winpty tree.com  : Direct call   cmd   built-in   tree.com   Command
  • winpty cmd //c tree  : notice   cmd   call   tree   Command
  • install   Git For Windows   Development version, Pacman -S tree   install   tree   Command, and then execute   tree   Call
  • download   Compiled   tree.exe   File to   git bash   Under the installation directory  / usr/bin   Directory, and then execute   tree   Command

Review summary #

Git   Not in itself   Windows   System, GIT for windows   Team in order to migrate to   Windows   The platform has made a lot of efforts, and the most intuitive feeling is to provide   Git For Windows   Software.

because   Git for Windows   Your excellent work was well received   Git   It is officially recognized and now downloaded by default   Git   It comes from   Git for Windows.

but   Git   The bottom layer is running on classes   linux   Systematic, this difference is necessary   Windows   reach   Linux   The intermediate processing layer of

Therefore, Git for Window   The technology behind it involves a lot of   GNU   Free software operating system and   WSL   (Windows Subsystem for Linux)

It is precisely because of the countless connections behind it that expand for us   git bash   The command line provides some ideas

be based on   Cygwin   Expand the system, install a complete operating system, and simulate   linux   Operating environment, in   Windows   You can find it on the   linux   The feeling of

Of course, Cygwin   Because it is relatively complete and its volume is quite large, it is derived here   MSYS2   and   MinGW   Operating system

Different paths lead to the same goal. Their underlying architecture is somewhat different, but the purpose is the same. They are all in   Windows   Found on   Linux   And almost all of their terminal command lines are   mintty  .

The third party commands can be easily expanded by calling their respective package management tools in the terminal. Besides, most of them have   c   Compilation environment, so you can also choose to recompile and install

therefore   git bash   The command line looks like   git   Official support is actually provided by   Git for Windows   Organize independently maintained open source projects

default   Git for Windows   The package management tool is not provided, but the development version is integrated by default   MSYS2   Environment. That is to say, we can use   Pacman   To install   tree   Command

Finally, summarize the main points of this article:

  • git bash   The command line is not a complete substitute   cmd   Command, the two complement each other
  • git bash   Call in command line   cmd   The program needs to pass   winpty   Call, for example   winpty tree.com
  • git bash   The default installer does not have advanced functions such as package management tools. If you need to extend custom commands, you should download Git for Windows SDK
  • git bash   Environment compatibility   MSYS2  , MinGW  , Cygwin   And other series of free software, and other similar systems   tree.exe   May not support it

Well, having said so much, my friends get how to be here   git bash   Use (Extended)   tree   Have you ordered?

If you have any questions, please leave a message and let me know!

Classification:   git tutorial label:   git, git bash, git for windows, mintty, winpty, cygwin Reprint link: https://www.cnblogs.com/snowdreams1006/p/10812861.html

4 December 2021, 01:42 | Views: 4965

Add new comment

For adding a comment, please log in
or create account

0 comments