当我开始探索Linux的时候,手册页是我的首选资源。当然,当一个初学者开始熟悉命令行的世界时,man 是最经常使用的命令。但是,手册页上有大量的选项和参数列表,可能很难破译,这使得你很难理解你想知道的东西。如果你想要一个更简单的解决方案,有基于例子的输出,我认为tldr是最好的选择。
什么是Tealdeer?
Tealdeer是Rust中tldr的一个很好的实现。它是一个社区驱动的手册页,给出了非常简单的命令工作的例子。Tealdeer最棒的地方在于它几乎拥有你通常会用到的所有命令。
安装Tealdeer
在Linux上,你可以从你的软件仓库安装Tealdeer。例如,在Fedora上。
$ sudo dnf install rust-tealdeer
另外,你也可以用Rust的Cargo软件包管理器来构建和安装该工具。
$ cargo install tealdeer
使用Tealdeer
输入tldr --list ,会返回tldr支持的man page列表,如touch,tar,dnf,docker,zcat,zgrep ,等等。
$ tldr --list
2to3
7z
7za
7zr
[a2disconfa2dismoda2dissitea2enconfa2enmoda2ensitea2query[...]
使用tldr 和一个特定的命令(如tar )会显示基于例子的man页,描述你可以用该命令做的所有选项。
$ tldr tar
Archiving utility.
Often combined with a compression method, such as gzip or bzip2.
More information: <https://www.gnu.org/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吗?或者你已经在使用它了?请在下面的评论中告诉我们你的想法。