在 Linux 上使用 Tealdeer 替代手册页
tldr Tealder rust

> 
> Tealder 是 Rust 版本的 tldr，对常用的命令提供了易于理解的说明信息。
> 
> 
> 


![](/data/attachment/album/202107/11/204638catii1ro21jmjzmi.jpg "computer screen ")


手册页是我开始探索 Linux 时最常用的资源。当然，对于初学者熟悉命令行指令而言，`man` 是最频繁使用的指令。但是手册页中有大量的选项和参数列表，很难被解读，这使得你很难理解你想知道的东西。如果你想要一个更简单的解决方案，有基于例子的输出，我认为 [tldr](https://github.com/tldr-pages/tldr) （<ruby> 太长不读 <rt>  too long dnot's read </rt></ruby>）是最好的选择。


### Tealdeer 是什么?


[Tealdeer](https://github.com/dbrgn/tealdeer) 是 tldr 的一个基于 Rust 的实现。它是一个社区驱动的手册页，给出了非常简单的命令工作原理的例子。Tealdeer 最棒的地方在于它几乎包含了所有你通常会用到的命令。


### 安装 Tealdeer


在 Linux 系统，你可以从软件仓库安装 Tealdeer，比如在 [Fedora](https://src.fedoraproject.org/rpms/rust-tealdeer) 上:



```
$ sudo dnf install tealdeer

```

在 macOS 可以使用 [MacPorts](https://opensource.com/article/20/11/macports) 或者 [Homebrew](https://opensource.com/article/20/6/homebrew-mac)。 同样，你可以使用 Rust 的 Cargo 包管理器来编译和安装此工具:



```
$ cargo install tealdeer

```

### 使用 Tealdeer


输入 `tldr-list` 返回 tldr 所支持的手册页，比如 `touch`、`tar`、`dnf`、`docker`、`zcat`、`zgrep` 等：



```
$ tldr --list
2to3
7z
7za
7zr
[
a2disconf
a2dismod
a2dissite
a2enconf
a2enmod
a2ensite
a2query
[...]

```

使用 `tldr` 跟上具体的命令（比如 `tar` ）能够显示基于示例的手册页，描述了你可以用该命令做的所有选项。



```
$ 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

```

你能够控制 Tealdeer 输出的颜色选项，有三种模式选择：一直、自动、从不。默认选项是自动，但我喜欢颜色提供的额外信息，所以我在我的 `~/.bashrc`文件中增加了这个别名：



```
alias tldr='tldr --color always'

```

### 结论


Tealdeer 的美妙之处在于不需要网络连接就可以使用，只有更新缓存的时候才需要联网。因此，即使你处于离线状态，依然能够查找和学习你新学到的命令。更多信息，请查看该工具的 [说明文档](https://dbrgn.github.io/tealdeer/intro.html)。


你会使用 Tealdeer 么？或者你已经在使用了？欢迎留言让我们知道。




---


via: <https://opensource.com/article/21/6/tealdeer-linux>


作者：[Sudeshna Sur](https://opensource.com/users/sudeshna-sur) 选题：[lujun9972](https://github.com/lujun9972) 译者：[ddl-hust](https://github.com/ddl-hust) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
Man pages were my go-to resource when I started exploring Linux. Certainly, `man`

is the most frequently used command when a beginner starts getting familiar with the world of the command line. But man pages, with their extensive lists of options and arguments, can be hard to decipher, which makes it difficult to understand whatever you wanted to know. If you want an easier solution with example-based output, I think [tldr](https://github.com/tldr-pages/tldr) is the best option.

## What's Tealdeer?

[Tealdeer](https://github.com/dbrgn/tealdeer) is a wonderful implementation of tldr in Rust. It's a community-driven man page that gives very simple examples of how commands work. The best part about Tealdeer is that it has virtually every command you would normally use.

## Install Tealdeer

On Linux, you can install Tealdeer from your software repository. For example, on [Fedora](https://src.fedoraproject.org/rpms/rust-tealdeer):

`$ sudo dnf install tealdeer`


On macOS, use [MacPorts](https://opensource.com/article/20/11/macports) or [Homebrew](https://opensource.com/article/20/6/homebrew-mac).

Alternately, you can build and install the tool with Rust's Cargo package manager:

`$ cargo install tealdeer`


## Use Tealdeer

Entering `tldr --list`

returns the list of man pages tldr supports, like `touch`

, `tar`

, `dnf`

, `docker`

, `zcat`

, `zgrep`

, and so on:

```
$ tldr --list
2to3
7z
7za
7zr
[
a2disconf
a2dismod
a2dissite
a2enconf
a2enmod
a2ensite
a2query
[...]
```


Using `tldr`

with a specific command (like `tar`

) shows example-based man pages that describe all the options that you can do with that command:

```
$ 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
```


To control the cache:

```
$ tldr --update
$ tldr --clear-cache
```


You can give Tealdeer output some color with the `--color`

option, setting it to `always`

, `auto`

, and `never`

. The default is `auto`

, but I like the added context color provides, so I make mine permanent with this addition to my `~/.bashrc`

file:

`alias tldr='tldr --color always'`


## Conclusion

The beauty of Tealdeer is you don't need a network connection to use it, except when you're updating the cache. So, even if you are offline, you can still search for and learn about your new favorite command. For more information, consult the tool's [documentation](https://dbrgn.github.io/tealdeer/intro.html).

Would you use Tealdeer? Or are you already using it? Let us know what you think in the comments below.

## 1 Comment