Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Does that work for you? (Second answer with the shell script) Mac OS X equivalent of the Ubuntu “tree” command –  slhck Jan 10 '13 at 18:52
3  
What is wrong with the tree command in the cmd propmpt on your windows box? –  EBGreen Jan 10 '13 at 18:54
    
@EBGreen If the OP wants the files to show, he should use (Command Prompt) tree /f –  BenjiWiebe Jan 10 '13 at 18:56
    
@BenjiWiebe that is why I asked what is wrong with the windows tree command. –  EBGreen Jan 10 '13 at 18:57
    
@EBGreen I meant that if the OP did not like tree, he should use tree /f to display the files, not just the directories. –  BenjiWiebe Jan 10 '13 at 18:59

1 Answer 1

up vote 2 down vote accepted

http://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 http://superuser.com/users/105575/ahmed-masud

share|improve this answer
    
Any idea how to color code the directories to a different color? Or reuse your directory listing colors? –  Jen S. 19 hours ago
    
Sorry, no. Sounds like a good question on its own though. –  jcollum 9 hours ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.