Skip to content

Instantly share code, notes, and snippets.

@wesbos
Created April 8, 2016 14:44
Show Gist options
  • Save wesbos/1432b08749e3cd2aea22fcea2628e2ed to your computer and use it in GitHub Desktop.
Save wesbos/1432b08749e3cd2aea22fcea2628e2ed to your computer and use it in GitHub Desktop.
# Put this in your .zshrc or .bashrc file
# Install `tree` first — brew install tree
function t() {
# Defaults to 3 levels deep, do more with `t 5` or `t 1`
# pass additional args after
tree -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst --filelimit 15 -L ${1:-3} -aC $2
}
@mafredri
Copy link

mafredri commented Apr 8, 2016

@azakordonets since you have a function named t, there really is no reason to alias it to t. I don't see this in my zsh but I believe that's the issue, if you want to use an alias, name the function _t for example and then alias t=_t.

Also, it seems like --filelimit and -a are conflicting options, at least when I tried to original function, and it only seems to take one additional parameter after the level parameter, so with these issues in mind, I made the following change:

function _t() {
  # Defaults to 3 levels deep, do more with `t 5` or `t 1`
  # pass additional args after
  local levels=${1:-3}; shift
  tree -I '.git|node_modules|bower_components|.DS_Store' --dirsfirst -L $levels -aC $@
}
alias t=_t

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment