linux - How to get tree -a to ignore .git directories?

08
2014-07
  • Luiz Berti

    I love using tree to list directories, and I have a git repository with all my dotfiles. For me to be able to see them I need to do tree -a, but that will also list the contents inside the .git directory, which most people (myself included) never dare touching.

    How would I get tree -a to exclude only the .git directory?

  • Answers
  • JP de la Torre

    You need to use the -I flag to exclude a pattern:

    tree -a -I '.git'
    

    Hope it helps.


  • Related Question

    osx - Only show hidden files in certain directories
  • Joseph Silvashy

    On a Unix system (or more specifically on Mac OS X) is it possible to show hidden files in only some directories? For example as a developer I want to see the hidden files in my Ruby on Rails projects but not on my desktop as well.

    I guess I'm just tired of seeing all these .DS_Store and .trashes files swimming around, any remedies not directly related are welcome too!


  • Related Answers
  • Arko

    Opening your project directory with a text editor such as TextMate (Great for RoR!), shows you all the files.

    If not, it may be useful to add ".*|" at the beginning of the file pattern you will find in TextMate's Preferences > Advanced > File Pattern:

    P.S. I'm not aware of any way to show invisible files only for a given directory. But i would rather not do it if it is possible. I prefer working with the terminal for this sort of things. It's even cooler with TextMate's Command line tool, type:

    $ mate any_file_or_directory
    

    ...to open it in TextMate

  • unrelativity

    Undirectly related solutions welcome?

    Well, I recently came across this tutorial which allows you to use the Shift-Cmd-Period shortcut that's already usable in open/save dialog boxes inside Finder as well. It does involve restarting Finder, but since all the windows are all restored it's relatively seamless.

    Quite stupid that Finder doesn't have such functionality built in if the open/save dialogs do have such functionality, but ah well.

  • user31894

    you can write a shell script, eg with bash

    shopt -s dotglob
    for file in my_rails_directory1/.*  my_rails_directory2/.*
    do
     echo $file
    done 
    
  • trolle3000

    Does not do precisely what you want, but I use the hiddenfiles widget to toggle visibility. This affects all folders off course, but it's quick to use.