在 Linux 上使用 Tealdeer 替代手冊頁
Tealder 是 Rust 版本的 tldr,對常用的命令提供了易于理解的說明信息。
手冊頁是我開始探索 Linux 時最常用的資源。當(dāng)然,對于初學(xué)者熟悉命令行指令而言,man
是最頻繁使用的指令。但是手冊頁中有大量的選項和參數(shù)列表,很難被解讀,這使得你很難理解你想知道的東西。如果你想要一個更簡單的解決方案,有基于例子的輸出,我認(rèn)為 tldr (太長不讀)是最好的選擇。
Tealdeer 是什么?
Tealdeer 是 tldr 的一個基于 Rust 的實現(xiàn)。它是一個社區(qū)驅(qū)動的手冊頁,給出了非常簡單的命令工作原理的例子。Tealdeer 最棒的地方在于它幾乎包含了所有你通常會用到的命令。
安裝 Tealdeer
在 Linux 系統(tǒng),你可以從軟件倉庫安裝 Tealdeer,比如在 Fedora 上:
$ sudo dnf install tealdeer
在 macOS 可以使用 MacPorts 或者 Homebrew。 同樣,你可以使用 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 輸出的顏色選項,有三種模式選擇:一直、自動、從不。默認(rèn)選項是自動,但我喜歡顏色提供的額外信息,所以我在我的 ~/.bashrc
文件中增加了這個別名:
alias tldr='tldr --color always'
結(jié)論
Tealdeer 的美妙之處在于不需要網(wǎng)絡(luò)連接就可以使用,只有更新緩存的時候才需要聯(lián)網(wǎng)。因此,即使你處于離線狀態(tài),依然能夠查找和學(xué)習(xí)你新學(xué)到的命令。更多信息,請查看該工具的 說明文檔。