Skip to content

Instantly share code, notes, and snippets.

@theapache64
Created November 21, 2020 18:26
Show Gist options
  • Save theapache64/9492d00abade1a38c781bd061fcc10ae to your computer and use it in GitHub Desktop.
Save theapache64/9492d00abade1a38c781bd061fcc10ae to your computer and use it in GitHub Desktop.
function git-ls {
# tree respecting gitignore
local ignored=$(git ls-files -ci --others --directory --exclude-standard)
local ignored_filter=$(echo "$ignored" \
| egrep -v "^#.*$|^[[:space:]]*$" \
| sed 's~^/~~' \
| sed 's~/$~~' \
| tr "\\n" "|")
tree --prune -I ".git|${ignored_filter: : -1}" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment