Zsh function to list file tree

Add this to your .zshrc

lst() {
    if [ "$1" != "" ] # or better, if [ -n "$1" ]
    then
        ls -R $1 | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
    else
        ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'
    fi
}


Then you can run

$ lst spec

It should list all sub directory in spec folder in tree format.

You could change spec to any path you want.

or just use tree

<3

Tino

Get our stories delivered

From us to your inbox weekly.