Instructions on how to install the tree command on macOS from source.
macOS Command Line Tools need to be installed on your local computer.
To install the Command Line Tools run the following command:
xcode-select --installTo obtain the tree source code run the following commands:
mkdir -p ~/.src/tree
curl -sL --retry 3 --insecure "http://mama.indstate.edu/users/ice/tree/src/tree-2.0.4.tgz" | tar xz --no-same-owner --strip-components=1 -C ~/.src/tree/
cd ~/.src/treeTo configure the source to be compiled for macOS run the following commands:
sed -i '.orig' -e '/SIP/,/HP/{//!s/#//;}' MakefileTo build the source code run the following command:
makeTo install the tool run the following commands:
sudo make PREFIX='/usr/local' MANDIR='${PREFIX}/share/man' installRun the following command on a terminal window:
tree --versionAfter installing the tool you can remove the downloaded source code using the following commands:
cd ~
rm -rf ~/.src
Thanks!
If you use the brew, just type it.
brew install tree