How do I print a tree with files in Bash for Windows?

I've found this command to show a tree of the directories under the current one:

ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'         

Which produces:

 .                          
 |-docs                     
 |-lib                      
 |-node_modules             
 |---connect-file-cache     
 |-----docs                 
 |-----lib                  
 |-----node_modules         
 |-------mime               
 |-------underscore         
 |-----src                  
 |-----test                 
 |-----test_fixtures        
 |---mime                   
 |---snockets               

That's good, but the files aren't there. My bash scripting skills are weak, so I have no idea how to get the files to show in that output.

Since I'm on Windows, I don't think I can get the tree command into mingw32.


Solution 1:

https://superuser.com/a/359728/5200

added this function to .bash_profile:

function ftree {
    SEDMAGIC='s;[^/]*/;|____;g;s;____|; |;g'

    if [ "$#" -gt 0 ] ; then
       dirlist="$@"
    else
       dirlist="."
    fi

    for x in $dirlist; do
         find "$x" -print | sed -e "$SEDMAGIC"
    done

}

It's not pretty, but it does the job. Credit to https://superuser.com/users/105575/ahmed-masud