当我开始探索 Linux 时,man 手册是我的首选资源。 当然,man
是初学者开始熟悉命令行世界时最常用的命令。 但是,man 手册具有大量的选项和参数列表,可能很难理解,这使得理解您想知道的内容变得困难。 如果您想要一个基于示例输出的更简单的解决方案,我认为 tldr 是最佳选择。
什么是 Tealdeer?
Tealdeer 是 tldr 在 Rust 中的一个非常棒的实现。 这是一个社区驱动的 man 手册,它给出了命令如何工作的非常简单的例子。 Tealdeer 最好的部分是它几乎拥有您通常会使用的每个命令。
安装 Tealdeer
在 Linux 上,您可以从您的软件仓库安装 Tealdeer。 例如,在 Fedora 上
$ sudo dnf install tealdeer
在 macOS 上,使用 MacPorts 或 Homebrew。
或者,您可以使用 Rust 的 Cargo 包管理器构建和安装该工具
$ cargo install tealdeer
使用 Tealdeer
输入 tldr --list
返回 tldr 支持的 man 手册列表,例如 touch
、tar
、dnf
、docker
、zcat
、zgrep
等
$ tldr --list
2to3
7z
7za
7zr
[
a2disconf
a2dismod
a2dissite
a2enconf
a2enmod
a2ensite
a2query
[...]
将 tldr
与特定命令(例如 tar
)一起使用会显示基于示例的 man 手册,这些手册描述了您可以使用该命令执行的所有选项
$ tldr tar
Archiving utility.
Often combined with a compression method, such as gzip or bzip2.
More information: <https://gnu.ac.cn/software/tar>.
[c]reate an archive and write it to a [f]ile:
tar cf target.tar file1 file2 file3
[c]reate a g[z]ipped archive and write it to a [f]ile:
tar czf target.tar.gz file1 file2 file3
[c]reate a g[z]ipped archive from a directory using relative paths:
tar czf target.tar.gz --directory=path/to/directory .
E[x]tract a (compressed) archive [f]ile into the current directory [v]erbosely:
tar xvf source.tar[.gz|.bz2|.xz]
E[x]tract a (compressed) archive [f]ile into the target directory:
tar xf source.tar[.gz|.bz2|.xz] --directory=directory
[c]reate a compressed archive and write it to a [f]ile, using [a]rchive suffix to determine the compression program:
tar caf target.tar.xz file1 file2 file3
控制缓存
$ tldr --update
$ tldr --clear-cache
您可以使用 --color
选项为 Tealdeer 输出添加一些颜色,将其设置为 always
、auto
和 never
。 默认值为 auto
,但我喜欢颜色提供的额外上下文,所以我通过将它添加到我的 ~/.bashrc
文件中来使其永久化
alias tldr='tldr --color always'
结论
Tealdeer 的优点是您不需要网络连接即可使用它,除非您正在更新缓存。 因此,即使您处于离线状态,您仍然可以搜索和了解您最喜欢的新命令。 有关更多信息,请参阅该工具的 文档。
您会使用 Tealdeer 吗? 或者您已经在使用了? 请在下面的评论中告诉我们您的想法。
1 条评论