DEV Community

Discussion on: Shell Bonsai with tree

Collapse
moopet profile image
Ben Sinclair • Edited

I think maybe you could use git check-ignore * instead of reaching for the local .gitignore file, because then it would work in subdirectories as well as the project root. Something like this works for me:

alias treo='tree -C -I $(git check-ignore * 2>/dev/null | tr "\n" "|").git'

I dug into this because your alias wouldn't work for me on my Mac (I have to use Macs at work...) and I couldn't quite figure out why.

Things I've learnt from your post include:

  • Using a single & as a separator
  • passing stuff into printf with xargs
  • tree can take colours

Neat!

Collapse
dmfay profile image
Dian Fay Author

I didn't know about git check-ignore! That makes this a lot simpler :)