
sh function for "tree" command
By: a guest on
Apr 13th, 2012 | syntax:
Bash | size: 0.43 KB | hits: 27 | expires: Never
# Add this to your .bashrc or .zshrc or wherever
# Copyright (C) 2012 by Adam Katz <http://www.khopis.com/scripts>, GPLv3+
# see also http://www.commandlinefu.com/commands/view/10592/
function tree() {
local dirs_only=''
case $1 in
-d ) dirs_only="-type d"; shift ;;
-?* ) [ ! -r "$1" ] && echo "Usage: tree [-d] [PATH...]" && return 1 ;;
esac
find "${@:-.}" $dirs_only |sed 's:[^-][^/]*/:--:g; s/^-/ |/'
}