Date
Sep. 8th, 2024
 
2024年 8月 6日

Post: OS X : 使用tree指令

OS X : 使用tree指令

Published 12:09 Sep 15, 2015.

Created by @ezra. Categorized in #Programming, and tagged as #macOS.

Source format: Markdown

Table of Content

如何在 OS X 下使用 tree 呢?

1、通过tree源码编译安装

下载源码:

curl -O ftp://mama.indstate.edu/linux/tree/tree-1.6.0.tgz

解压源码:

tar xzvf tree-1.6.0.tgz

修改Makefile文件

cd 到解压后的tree-1.6.0目录,直接vi Makefile

tree 默认的是 linux 的编译环境,因此需要注释掉linux的编译选项:

# Linux defaults:
#CFLAGS=-ggdb -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
#CFLAGS=-O4 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
#LDFLAGS=-s

启用mac的编译:

# Uncomment for OS X:
CC=cc
CFLAGS=-O2 -Wall -fomit-frame-pointer -no-cpp-precomp
LDFLAGS=
OBJS+=strverscmp.o

接着 make

然后 sudo make install

2、通过brew安装

brew install tree

当然,首先你的Mac需要安装brew

Pinned Message
HOTODOGO
The Founder and CEO of Infeca Technology.
Developer, Designer, Blogger.
Big fan of Apple, Love of colour.
Feel free to contact me.
反曲点科技创始人和首席执行官。
程序猿、设计师、奇怪的博主。
苹果死忠、热爱色彩斑斓的世界。
如有意向请随时 与我联系