[TOC]

概述

文章参考:https://cn.starbytecomputers.com/using-mac-equivalent-unix-tree-command-view-folder-trees-terminal

文章参考:https://blog.51cto.com/u_12179846/3194649

安装Mac命令行的“树”

如果你想要更多地控制“树”,比如指定目录的能力,或者你只想要来自unix世界的确切“树”等价物,你可以使用homebrew或macports直接在macOS和Mac中安装树OS X:

使用Homebrew安装’tree’

1
brew install tree

使用MacPorts安装’tree’

1
sudo port install tree

我倾向于使用自制软件,但请使用适用于您的软件。 从其中任何一个安装后,键入“tree”将显示Mac上任何目录的文件夹树。

请注意,为避免冲突,您不希望在第一步中使用树别名,然后再安装树命令。 您可以实现这两种方法,但您可能希望将别名重命名为“treed”或类似内容。

报错

1
2
3
4
5
6
7
(base)  frewen@FreweniMacBookPro  ~  brew install tree
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core, skipping update!
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/tree-2.0.2.monterey.bottle.tar.gz
Already downloaded: /Users/frewen/Library/Caches/Homebrew/downloads/5e40b31f97c82e0a9be31e97c9ee810b6d72d4fa18a98cfaf561a317662a0127--tree-2.0.2.monterey.bottle.tar.gz
fatal: not in a git directory
Error: Command failed with exit 128: git

解决方法:https://www.cnblogs.com/layezi/p/16216085.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
(base)  ✘ frewen@FreweniMacBookPro  ~  brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Suspicious https://github.com/Homebrew/brew git origin remote found.
The current git origin is:
https://mirrors.ustc.edu.cn/brew.git

With a non-standard origin, Homebrew won't update properly.
You can solve this by setting the origin remote:
git -C "/usr/local/Homebrew" remote set-url origin https://github.com/Homebrew/brew

Warning: Homebrew/homebrew-cask was not tapped properly! Run:
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask"
brew tap homebrew/cask

Warning: Homebrew/homebrew-core was not tapped properly! Run:
rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
brew tap homebrew/core

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
/Users/frewen/Library/AFrewenLib/anaconda3/bin/icu-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/krb5-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/freetype-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/xslt-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/libpng16-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/libpng-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/xml2-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/python3.9-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/python3-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/curl-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/ncursesw6-config
/Users/frewen/Library/AFrewenLib/anaconda3/bin/pre-commit-validate-config

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
/usr/local/lib/libshuttle_p11v220.1.0.0.dylib
(base) ✘ frewen@FreweniMacBookPro  ~  rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask"
(base) frewen@FreweniMacBookPro  ~  rm -rf "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core"
(base) frewen@FreweniMacBookPro  ~  git -C "/usr/local/Homebrew" remote set-url origin https://github.com/Homebrew/brew
(base) frewen@FreweniMacBookPro  ~  brew install tree
Warning: No remote 'origin' in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-services, skipping update!
Running `brew update --preinstall`...
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Enumerating objects: 1227237, done.
remote: Counting objects: 100% (67/67), done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 1227237 (delta 37), reused 58 (delta 29), pack-reused 1227170
Receiving objects: 100% (1227237/1227237), 489.04 MiB | 10.68 MiB/s, done.
Resolving deltas: 100% (847310/847310), done.
Updating files: 100% (6516/6516), done.
Tapped 3 commands and 6185 formulae (6,527 files, 536.6MB).
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/tree-2.0.2.monterey.bottle.tar.gz
Already downloaded: /Users/frewen/Library/Caches/Homebrew/downloads/5e40b31f97c82e0a9be31e97c9ee810b6d72d4fa18a98cfaf561a317662a0127--tree-2.0.2.monterey.bottle.tar.gz
==> Pouring tree-2.0.2.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/tree/2.0.2: 8 files, 151.0KB
==> Running `brew cleanup tree`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).