List directory as tree from your terminal

brew install tree

Then you can type tree -help to see how it works. Recommended!

tree: Invalid argument -`e'.
usage: tree [-acdfghilnpqrstuvxACDFJQNSUX] [-L level [-R]] [-H [-]baseHREF]
	[-T title] [-o filename] [-P pattern] [-I pattern] [--gitignore]
	[--gitfile[=]file] [--matchdirs] [--metafirst] [--ignore-case]
	[--nolinks] [--hintro[=]file] [--houtro[=]file] [--inodes] [--device]
	[--sort[=]name] [--dirsfirst] [--filesfirst] [--filelimit[=]#] [--si]
	[--du] [--prune] [--charset[=]X] [--timefmt[=]format] [--fromfile]
	[--fromtabfile] [--fflinks] [--info] [--infofile[=]file] [--noreport]
	[--hyperlink] [--scheme[=]schema] [--authority[=]host] [--opt-toggle]
	[--version] [--help] [--] [directory ...]
tree -a
tree -h
[ 384]  .
├── [ 743]  Dockerfile
├── [ 642]  cloudbuild.yaml
├── [ 128]  cmd
│   └── [ 160]  api
│       ├── [  88]  dump.rdb
│       ├── [6.4K]  index.html
│       └── [9.4K]  main.go
├── [4.0K]  go.mod
├── [ 27K]  go.sum
└── [  96]  public
    └── [6.4K]  index.html

4 directories, 8 files
ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/'

which gives output like this:

   |-cmd
   |---api
   |-public

If you want to copy this, simply add "| pbcopy" to the command above and everything it outputs will be saved in your Clipboard and you can then paste into Email, MS-Word documents or wherever you like.

ls -R | grep ":" | sed -e 's/://' -e 's/[^-][^\/]*\//--/g' -e 's/^/   /' -e 's/-/|/' | pbcopy

add "| pbcopy" to all of these to copy the output to the Clipboard.