一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

tlrc:实践指南

时间:2026-09-11 15:34:01 编辑:袖梨 来源:一聚教程网

团队讨论tlrc时,我会先把用途说清楚:用 Rust 编写的官方 tldr 客户端。一旦进入日常自动化环节,输入边界、依赖和失败处理如果不清楚就很难稳定复用会直接影响交付,这也是我最关心的风险。与其反复读介绍,不如用一项范围明确的真实任务完成最小试跑,再依据配置时间、输出质量、异常信息和维护痕迹做取舍。它更像给愿意先做小范围验证并复查原始文档的团队准备的可审查方案,是否长期使用应由试跑数据决定。

总览

用 Rust 编写的 tldr 客户端。

安装

Linux/macOS 使用自制程序

使用 Homebrew 安装 tlrc:

brew install tlrc

Linux/macOS 使用 Nix

从 nixpkgs 安装 tlrc。

架构Linux

从 AUR 安装 tlrc(来自源)或 tlrc-bin(预构建)。

虚空Linux

安装 tlrc 和 XBPS:

xbps-install tlrc

openSUSE

使用 Zypper 安装 tlrc:

zypper install tlrc

使用 Winget 的 Windows

使用 Winget 安装 tlrc:

winget install tldr-pages.tlrc

使用 Scoop 的 Windows

使用 Scoop 安装 tlrc:

scoop install tlrc

macOS 使用 MacPorts

安装 tlrc 和 MacPorts:

port install tlrc

NetBSD

安装 tlrc 和 pkgin

pkgin install tlrc

Linux/macOS/Windows 使用 Conda

使用 Conda 安装 tlrc:

conda install conda-forge::tlrc
# if using mamba
# mamba install conda-forge::tlrc

来自 crates.io

要从源 tarball 构建 tlrc,请运行:

cargo install tlrc --locked

[!NOTE] Shell 完成文件和手册页不会以这种方式安装。

来自 GitHub 发布

您可以在[此处][最新版本]找到预构建的二进制文件和 Debian 软件包。

用途

请参阅 man tldr 或 在线联机帮助页。如需简要说明,您还可以运行:

tldr --help

配置

可以使用 TOML 配置文件自定义 Tlrc。要获取系统的默认路径,请运行:

tldr --config-path

要生成默认配置文件,请运行:

tldr --gen-config > "$(tldr --config-path)"

或者复制下面的例子。

配置选项

[cache]
# Override the cache directory ('~' will be expanded to your home directory).
dir = "/path/to/cache"
# Override the base URL used for downloading tldr pages.
# The mirror must provide files with the same names as the official tldr pages repository:
# mirror/tldr.sha256sums            must point to the SHA256 checksums of all assets
# mirror/tldr-pages.LANGUAGE.zip    must point to a zip archive that contains platform directories with pages in LANGUAGE
mirror = "https://github.com/tldr-pages/tldr/releases/latest/download"
# Automatically update the cache if it's older than max_age hours.
auto_update = true
# Perform the automatic update after the page is shown (the default is to update first, then show the page).
defer_auto_update = false
max_age = 336 # 336 hours = 2 weeks
# Specify a list of desired page languages. If it's empty, languages specified in
# the LANG and LANGUAGE environment variables are downloaded.
# English is implied and will always be downloaded.
# You can see a list of language codes here: https://github.com/tldr-pages/tldr
# Example: ["de", "pl"]
languages = []

[output]
# Show the title in the rendered page.
show_title = true
# Show the platform name ('common', 'linux', etc.) in the title.
platform_title = false
# Prefix descriptions of examples with hyphens.
show_hyphens = false
# Display a link to edit the shown page on GitHub.
edit_link = false
# Use a custom string instead of a hyphen.
example_prefix = "- "
# Set the max line length. 0 means to use the terminal width.
# If a description is longer than this value, it will be split
# into multiple lines.
line_length = 0
# Strip empty lines from output.
compact = false
# In option placeholders, show the specified option style.
# Example: {{[-s|--long]}}
# short  : -s
# long   : --long
# both   : [-s|--long]
option_style = "long"
# Print pages in raw markdown.
raw_markdown = false

# Number of spaces to put before each line of the page.
[indent]
# Command name.
title = 2
# Command description.
description = 2
# Descriptions of examples.
bullet = 2
# Example command invocations.
example = 4

# Style for the title of the page (command name).
[style.title]
# Fixed colors:       "black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "default",
#                     "bright_black", "bright_red", "bright_green", "bright_yellow", "bright_blue",
#                     "bright_magenta", "bright_cyan", "bright_white"
# 256color ANSI code: { color256 = 50 }
# RGB:                { rgb = [0, 255, 255] }
# Hex:                { hex = "#ffffff" }
color = "magenta"
background = "default"
bold = true
underline = false
italic = false
dim = false
strikethrough = false

# Style for the description of the page.
[style.description]
color = "magenta"
background = "default"
bold = false
underline = false
italic = false
dim = false
strikethrough = false

# Style for descriptions of examples.
[style.bullet]
color = "green"
background = "default"
bold = false
underline = false
italic = false
dim = false
strikethrough = false

# Style for command examples.
[style.example]
color = "cyan"
background = "default"
bold = false
underline = false
italic = false
dim = false
strikethrough = false

# Style for URLs inside the description.
[style.url]
color = "red"
background = "default"
bold = false
underline = false
italic = true
dim = false
strikethrough = false

# Style for text surrounded by backticks (`).
[style.inline_code]
color = "yellow"
background = "default"
bold = false
underline = false
italic = true
dim = false
strikethrough = false

# Style for placeholders inside command examples.
[style.placeholder]
color = "red"
background = "default"
bold = false
underline = false
italic = true
dim = false
strikethrough = false

对于类似于 tldr-python-client 的样式,请将其添加到您的配置中:

[output]
show_hyphens = true
compact = true

[style]
title.color = "default"
title.bold = true
description.color = "default"
bullet.color = "green"
example.color = "red"
placeholder.color = "default"

热门栏目