Skip to content

Instantly share code, notes, and snippets.

@fscm
Last active February 28, 2024 12:15
Show Gist options
  • Save fscm/9eee2784f101f21515d66321180aef0f to your computer and use it in GitHub Desktop.
Save fscm/9eee2784f101f21515d66321180aef0f to your computer and use it in GitHub Desktop.
[macOS] Install 'tree' command from source

[macOS] Install 'tree' command from source

Instructions on how to install the tree command on macOS from source.

Prerequisites

macOS Command Line Tools need to be installed on your local computer.

To install the Command Line Tools run the following command:

xcode-select --install

Get the source

To 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/tree

Configure

To configure the source to be compiled for macOS run the following commands:

sed -i '.orig' -e '/SIP/,/HP/{//!s/#//;}' Makefile

Build

To build the source code run the following command:

make

Install

To install the tool run the following commands:

sudo make PREFIX='/usr/local' MANDIR='${PREFIX}/share/man' install

Verify

Run the following command on a terminal window:

tree --version

Clean up

After installing the tool you can remove the downloaded source code using the following commands:

cd ~
rm -rf ~/.src
@hmkim
Copy link

hmkim commented Oct 18, 2022

Thanks!

If you use the brew, just type it.

brew install tree

@Wrinklytech
Copy link

Many thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment