Tarquin note
Tarquin note
本文迁移自 wl.do 原文,已按本站 2024 归档规则保留原文结构。
Fastfetch 是一个类似 Neofetch 的系统信息展示工具, 主要使用 C 语言编写, 注重性能和可定制性。它能够以美观的方式获取和显示系统信息。

# Debian 13 及更高版本
apt install fastfetch
# Debian 11+ / Ubuntu 20.04+ - 下载 deb 包安装
wget https://github.com/fastfetch-cli/fastfetch/releases/download/VERSION/fastfetch-linux-<架构>.deb
sudo dpkg -i fastfetch-linux-<架构>.deb
Bash
pacman -S fastfetch
Bash
dnf install fastfetch
Bash
emerge --ask app-misc/fastfetch
Bash
apk add --upgrade fastfetch
Bash
nix-shell -p fastfetch
Bash
zypper install fastfetch
Bash
xbps-install fastfetch
Bash
如果你的发行版没有打包或版本过旧:
brew install fastfetch
Bash
brew install fastfetch
Bash
sudo port install fastfetch
Bash
scoop install fastfetch
Bash
choco install fastfetch
Bash
winget install fastfetch
Bash
pacman -S mingw-w64-<子系统>-<架构>-fastfetch
Bash
pkg install fastfetch
Bash
pkgin in fastfetch
Bash
pkg_add fastfetch
Bash
pkg install fastfetch
Bash
pkg install fastfetch
Bash
安装完成后, 直接运行:
fastfetch
Bash
这将使用默认配置显示系统信息和 ASCII Logo。
# 查看所有选项
fastfetch --help
# 查看特定选项的帮助
fastfetch -h <选项名>
# 查看模块格式帮助
fastfetch -h <模块名>-format
Bash
# 列出所有可用模块
fastfetch --list-modules
# 列出所有可用 Logo
fastfetch --list-logos
# 列出所有预设配置
fastfetch --list-presets
# 列出配置文件搜索路径
fastfetch --list-config-paths
# 列出数据文件搜索路径
fastfetch --list-data-paths
# 列出编译支持的特性
fastfetch --list-features
Bash
fastfetch -c all.jsonc
Bash
这将显示所有支持的模块, 帮助你了解可用功能。
默认配置文件路径:
~/.config/fastfetch/config.jsonc
配置文件搜索顺序:
# 生成最小配置文件
fastfetch --gen-config
# 生成完整配置文件(包含所有可选项)
fastfetch --gen-config-full
# 生成到指定路径
fastfetch --gen-config /path/to/config.jsonc
# 强制覆盖现有配置
fastfetch --gen-config-force
# 输出到标准输出
fastfetch --gen-config -
Bash
Fastfetch 使用JSONC(JSON with Comments) 格式, 支持注释。
基本结构:
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
// Logo 配置
},
"display": {
// 显示设置
},
"modules": [
// 模块列表
]
}
在配置文件开头添加$schema字段可以在支持的编辑器 (如 VS Code、Helix) 中获得智能提示和语法检查:
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json"
}
JSON
# 使用自定义配置文件
fastfetch -c /path/to/config.jsonc
# 使用预设配置
fastfetch -c neofetch
fastfetch -c hardware
fastfetch -c paleofetch
# 禁用配置加载
fastfetch -c none
Bash
使用-s或--structure指定要显示的模块 (用冒号分隔):
fastfetch -s title:separator:os:kernel:uptime:memory
# 只显示操作系统信息
fastfetch -s os
# 显示多个模块
fastfetch -s OS:Kernel:Packages:Terminal:Memory:Locale
Bash
# 使用内置 Logo
fastfetch --logo arch
# 禁用 Logo
fastfetch --logo none
fastfetch -l none
# 使用自定义图片
fastfetch -l /path/to/logo.png
# 使用 ASCII 艺术文件
fastfetch --logo /path/to/ascii-art.txt
Bash
# 修改 Logo 颜色
fastfetch --logo-color-1 red --logo-color-2 green
# 使用小型 Logo
fastfetch --logo-type small
Bash
# JSON 格式输出
fastfetch --format json
fastfetch -j
# 查看特定模块的 JSON 数据
fastfetch -s os:kernel --format json
Bash
# 显示每个模块的执行时间
fastfetch --stat
Bash
将当前命令行选项保存为配置文件:
fastfetch -s os:kernel:memory --logo arch --gen-config
Bash
常用模块包括:
系统信息
硬件信息
软件信息
网络信息
其他
使用字符串形式启用默认配置:
{
"modules": [
"title",
"separator",
"os",
"kernel",
"uptime"
]
}
使用对象形式自定义模块:
{
"modules": [
{
"type": "os",
"key": "操作系统",
"keyColor": "blue",
"format": "{name} {version}"
},
{
"type": "cpu",
"key": " CPU",
"format": "{name} ({cores}核)"
},
{
"type": "memory",
"key": " 内存",
"format": "{used} / {total} ({percentage}%)"
}
]
}
每个模块支持自定义格式字符串:
{
"type": "cpu",
"format": "{name} ({cores-physical}C/{cores-logical}T) @ {freq-max}"
}
查看模块支持的格式占位符:
fastfetch -h cpu-format
fastfetch -h memory-format
fastfetch -h disk-format
Bash
添加自定义文本或分隔线:
{
"type": "custom",
"format": "┌─────────── 硬件信息 ───────────┐"
}
执行命令并显示输出:
{
"type": "command",
"key": "编辑器",
"text": "$EDITOR --version | head -1"
}
⚠️警告: Command 模块可以执行任意 Shell 命令, 请勿使用来自不可信来源的配置文件。
{
"logo": {
"type": "auto", // Logo 类型
"source": "arch", // Logo 源
"width": 65, // 宽度(字符)
"height": 35, // 高度(字符)
"padding": {
"top": 0,
"left": 0,
"right": 2
},
"color": {
"1": "blue",
"2": "cyan"
}
}
}
# 命令行方式
fastfetch --logo arch
# 配置文件方式
{
"logo": {
"type": "builtin",
"source": "arch"
}
}
Bash
创建一个文本文件custom-logo.txt, 使用颜色占位符$1到$9:
$1 ████████
$1 ██$2╔════╝
$1 ██$2║
$1 ██$2║
$1 ╚═╝
然后在配置中引用:
{
"logo": {
"type": "file",
"source": "~/.config/fastfetch/custom-logo.txt",
"color": {
"1": "blue",
"2": "yellow"
}
}
}
或命令行:
fastfetch -l ~/custom-logo.txt --logo-color-1 blue --logo-color-2 yellow
Bash
# 自动选择协议
fastfetch -l ~/Pictures/logo.png
# 指定宽度
fastfetch -l ~/Pictures/logo.png --logo-width 30
Bash
Mintty / Wezterm:
{
"logo": {
"type": "iterm",
"source": "C:/path/to/image.png",
"width": 30
}
}
Windows Terminal(需要 Sixel 支持):
{
"logo": {
"type": "sixel",
"source": "C:/path/to/image.png",
"width": 30,
"height": 20
}
}
颜色占位符$1到$9对应 9 种颜色:
{
"logo": {
"color": {
"1": "red",
"2": "green",
"3": "yellow",
"4": "blue",
"5": "magenta",
"6": "cyan",
"7": "white",
"8": "bright-red",
"9": "bright-green"
}
}
}
支持的颜色名称:
格式字符串包含占位符\{name\}或\{index\}:
"值: {1} ({2})"
使用值 "First" 和 "Second" 会产生:值: First (Second)
使用有意义的名称代替数字:
fastfetch --title-format '{user-name}@{host-name}'
Bash
查看支持的标签:
fastfetch -h title-format
Bash
# 截断为 5 个字符
{user-name:5}
# 截断并添加省略号
{user-name:-5}
Bash
# 左对齐,填充到 20 个字符
{user-name<20}
# 右对齐,填充到 20 个字符
{user-name>20}
Bash
# 前 5 个字符
{~0,5}
# 后 5 个字符
{~-5,}
# 从第 3 个到倒数第 2 个
{~2,-2}
Bash
{$HOME} # 环境变量
{$NUM} # 常量(需在 display.constants 中定义)
Bash
空占位符自动使用递增索引:
"值: {} ({})" # 等同于 "值: {1} ({2})"
Bash
{?2} 第二个值: {2}{?}
Bash
仅当第 2 个值存在时才显示。
{/2}值不可用{/}
Bash
仅当第 2 个值不存在时才显示。
{?2}{2}{?}{/2}备用值{/}
Bash
如果第 2 个值存在则显示它, 否则显示 "备用值"。
使用\{#\}添加颜色:
# ANSI 颜色代码
{#4;35}彩色文本{#}
# 命名颜色
{#underline_magenta}彩色文本{#}
# 重置颜色
{#0} 或 {#}
Bash
查看支持的颜色:
fastfetch -h color
Bash
{
"type": "cpu",
"format": "{#blue}{name}{#} ({cores}核) @ {freq-max} GHz"
},
{
"type": "memory",
"format": "{used:8} / {total:8} ({percentage}%)"
},
{
"type": "disk",
"format": "{?1}{1}: {/}{2} / {3} ({4}%)"
}
fastfetch --list-presets
Bash
# Neofetch 风格
fastfetch -c neofetch
# 硬件信息
fastfetch -c hardware
# 软件信息
fastfetch -c software
# 极简风格
fastfetch -c paleofetch
# 所有模块
fastfetch -c all
Bash
| 预设名称 | 说明 |
|---|---|
| neofetch.jsonc | 模仿 Neofetch 风格 |
| paleofetch.jsonc | 极简风格 |
| hardware.jsonc | 专注硬件信息 |
| software.jsonc | 专注软件信息 |
| ci.jsonc | 适合 CI 环境 |
| all.jsonc | 显示所有模块 |
将自定义预设保存到:
~/.local/share/fastfetch/presets/
然后使用:
fastfetch -c my-preset
Bash
A:
A: 默认位置是~/.config/fastfetch/config.jsonc。Fastfetch 不会自动生成配置文件, 需要手动生成:
fastfetch --gen-config
Bash
A: 不会。本地 IP 地址 (10.x.x.x, 172.x.x.x, 192.168.x.x) 只在局域网内有意义, 不涉及隐私问题。如果不想显示, 可以在配置文件中禁用localip模块。
A: 将键设置为空格:
{
"type": "os",
"key": " "
}
A: 使用format字段:
{
"type": "gpu",
"format": "{name}" // 只显示 GPU 名称
}
查看模块支持的格式:
fastfetch -h gpu-format
Bash
A: 确保你的终端支持 256 色或 True Color。可以尝试:
fastfetch --pipe false
Bash
强制启用彩色模式。
A: 将fastfetch命令放在p10k-instant-prompt初始化之前, 或使用:
fastfetch --pipe false
Bash
A:
A: 在 Debian/Ubuntu 系统上, 需要更新 PCI ID 数据库:
# 下载并更新 pci.ids
sudo wget https://pci-ids.ucw.cz/v2.2/pci.ids -O /usr/share/hwdata/pci.ids
# AMD GPU 还需要更新 amdgpu.ids
sudo wget https://gitlab.freedesktop.org/mesa/drm/-/raw/main/data/amdgpu.ids -O /usr/share/libdrm/amdgpu.ids
Bash
或使用驱动专用检测:
fastfetch --gpu-driver-specific
Bash
A: 设置 XAUTHORITY 环境变量:
export XAUTHORITY=$HOME/.Xauthority
Bash
A: 在 Shell 配置文件中添加:
Bash(~/.bashrc):
fastfetch
Bash
Zsh(~/.zshrc):
fastfetch
Bash
Fish(~/.config/fish/config.fish):
fastfetch
如果遇到问题, 可以添加延迟:
sleep 0.2 && fastfetch
Bash
全局显示设置:
{
"display": {
"separator": " → ",
"color": {
"keys": "blue",
"title": "cyan"
},
"key": {
"width": 12,
"type": "both" // string, icon, both, none
},
"bar": {
"width": 15,
"char": {
"elapsed": "█",
"total": "░"
},
"border": true
},
"percent": {
"type": 9, // 1=数字, 2=条形, 3=两者, 9=彩色数字
"color": {
"green": "green",
"yellow": "yellow",
"red": "red"
}
}
}
}
{
"display": {
"temp": {
"green": 60,
"yellow": 80
}
}
}
{
"type": "disk",
"key": " 磁盘",
"folders": "/:/home:/boot",
"format": "{1}: {2} / {3} ({4}%)"
}
fastfetch --battery-temp
Bash
# 使用驱动专用方法
fastfetch --gpu-driver-specific
# 指定检测方法
fastfetch --gpu-detection-method auto
Bash
保持 Fastfetch 运行并定时更新:
fastfetch --dynamic-interval 1000 # 每秒更新
Bash
在配置文件中定义常量:
{
"display": {
"constants": {
"MY_TEXT": "自定义文本"
}
},
"modules": [
{
"type": "custom",
"format": "{$MY_TEXT}"
}
]
}
{
"modules": [
{
"type": "custom",
"format": "┌─────────── 硬件信息 ───────────┐"
},
"host",
"cpu",
"gpu",
"memory",
{
"type": "custom",
"format": "├─────────── 软件信息 ───────────┤"
},
"os",
"kernel",
"shell",
"packages",
{
"type": "custom",
"format": "└────────────────────────────────┘"
}
]
}
# 安装 pyfiglet 和 jq
pyfiglet -s -f small_slant $(fastfetch -s os --format json | jq -r '.[0].result.name') && fastfetch -l none
Bash
完整配置示例:
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "auto",
"source": "arch",
"padding": {
"right": 2
},
"color": {
"1": "blue",
"2": "bright-blue"
}
},
"display": {
"separator": ": ",
"color": {
"keys": "blue",
"title": "cyan"
},
"key": {
"width": 12
},
"bar": {
"width": 15,
"char": {
"elapsed": "■",
"total": "-"
}
}
},
"modules": [
"title",
"separator",
{
"type": "os",
"key": "OS",
"format": "{name} {version}"
},
{
"type": "kernel",
"key": "Kernel"
},
{
"type": "uptime",
"key": "Uptime"
},
{
"type": "packages",
"key": "Packages"
},
{
"type": "shell",
"key": "Shell"
},
{
"type": "terminal",
"key": "Terminal"
},
{
"type": "cpu",
"key": "CPU",
"format": "{name} ({cores}核)"
},
{
"type": "gpu",
"key": "GPU"
},
{
"type": "memory",
"key": "Memory",
"format": "{used} / {total} ({percentage}%)"
},
{
"type": "disk",
"key": "Disk",
"folders": "/",
"format": "{used} / {total} ({percentage}%)"
},
"separator",
"colors"
]
}