在寫書稿的過程中,經常要把目錄結構圖以tree的格式展現出來,之前一直沒有找到簡潔的方法。後來,“沉默王二”技術交流群中的賢會兄弟提供了思路給我,說在Mac下可直接使用tree指令。
但實際情況下,我在Mac上并沒有發現tree指令,然後網絡上提供了一個别樣的解決方案,通過find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'指令來模仿tree指令的結果,但實際效果并不理想。
于是想通過brew安裝tree指令。
但是Mac上個也沒有brew指令,于是安裝brew
https://brew.sh/index_zh-cn.html指令:
/usr/bin/ruby -e "$(curl -fsSL
https://raw.githubusercontent.com/Homebrew/install/master/install)"不過下載下傳速度堪憂,等吧!
焦躁不安的等待完成安裝後,要重新啟動一個終端,否則無法檢視brew。
maweiqingdeiMac:~ maweiqing$ brew -v
Homebrew 1.3.6
Homebrew/homebrew-core (git revision db80; last commit 2017-11-09)
maweiqingdeiMac:~ maweiqing$
之後,安裝tree指令:
brew install tree
安裝成功後,執行tree指令:
maweiqingdeiMac:bootstrap maweiqing$ tree
.
├── css
│ └── bootstrap.css
├── fonts
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ ├── glyphicons-halflings-regular.woff
│ └── glyphicons-halflings-regular.woff2
└── js
└── bootstrap.js
3 directories, 7 files
嗯,不錯,是我要的結果。