linux配置fastfetch

这篇文章用于记录如何在ubuntu24.04中安装fastfetch并配置样式

美化样式

创建配置文件

路径为 ~/.config/fastfetch/config.toml

个人比较喜欢这一套,直接复制即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "small",
"padding": {
"top": 1
}
},
"display": {
"separator": " "
},
"modules": [
{
"key": "╭───────────╮",
"type": "custom"
},
{
"key": "│  user │",
"type": "title",
"format": "{user-name}"
},
{
"key": "│ 󰇅 hname │",
"type": "title",
"format": "{host-name}"
},
{
"key": "│ 󰅐 uptime │",
"type": "uptime"
},
{
"key": "│ {icon} distro │",
"type": "os"
},
{
"key": "│  kernel │",
"type": "kernel"
},
{
"key": "│ 󰇄 desktop │",
"type": "de"
},
{
"key": "│  term │",
"type": "terminal"
},
{
"key": "│  shell │",
"type": "shell"
},
{
"key": "│ 󰍛 cpu │",
"type": "cpu",
"showPeCoreCount": true
},
/* {
"key": "│ 󰍹 gpu │", // ★ GPU 模块
"type": "gpu"
},*/
{
"key": "│ 󰉉 disk │",
"type": "disk",
"folders": "/"
},
{
"key": "│  memory │",
"type": "memory"
},
{
"key": "│ 󰩟 network │",
"type": "localip",
"format": "{ipv4} ({ifname})"
},
{
"key": "├───────────┤",
"type": "custom"
},
{
"key": "│  colors │",
"type": "colors",
"symbol": "circle"
},
{
"key": "╰───────────╯",
"type": "custom"
}
]
}

配置启动规则

我使用zsh,因此配置在~/.zshrc

打开终端自动运行fastfetch

只需要在文件中添加

1
fastfetch

这一行即可

但是这会引出其他问题,我并不希望在任何地方,一打开终端就运行它,就比如vscode,cursor,nvim中

配置启动规则

为了不让fastfetch在任何地方都启动,需要添加规则

把配置文件中的fastfetch更改为下面这一段

1
2
3
4
5
# fastfetch
# Run fastfetch only when NOT in VSCode terminal or nvim
if [[ "$TERM_PROGRAM" != "vscode" && -z "$VSCODE_INJECTION" && -z "$NVIM" ]]; then
fastfetch
fi

这样就可以保证fastfetch只有在打开终端软件时才会运行

可能出现的问题

解决可能会变成黑白的问题

今天突然发现Ubuntu中配置的fastfetch在打开终端时,默认运行的那次fastfetch是黑白的

解决方法:
~/.zshrc中的配置文件改成下面这样

1
2
3
4
5
# fastfetch
# Run fastfetch only when NOT in VSCode terminal or nvim
if [[ "$TERM_PROGRAM" != "vscode" && -z "$VSCODE_INJECTION" && -z "$NVIM" ]]; then
fastfetch --pipe false
fi

相关链接:
fastfetch README


linux配置fastfetch
http://example.com/2025/05/06/linux配置fastfetch/
作者
prawn
发布于
2025年5月6日
许可协议