Fish、Kitty 与 Starship 终端美化指南

终端美化指南

目录


环境信息

  • Shell: Fish Shell
  • 终端: Kitty
  • 提示符: Starship
  • 操作系统: Arch Linux (x86_64)
  • 内核版本: 6.14.6-arch1-1

Fish Shell 主题配置

配置文件位置

~/.config/fish/config.fish          # 主配置文件
~/.config/fish/fish_variables       # 通用变量(颜色主题存储于此)
~/.config/fish/conf.d/              # 额外配置目录
~/.config/fish/functions/           # 自定义函数

主题管理命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 查看所有可用主题
fish_config theme show

# 选择主题(临时)
fish_config theme choose <theme_name>

# 保存主题到 fish_variables
fish_config theme save

# 恢复默认主题(跟随终端配色)
# 删除 fish_variables 中的颜色变量
set -Ue fish_color_command fish_color_normal fish_color_param
# 或者删除所有颜色变量
set -Ue fish_color_autosuggestion fish_color_cancel fish_color_command \
fish_color_comment fish_color_cwd fish_color_cwd_root fish_color_end \
fish_color_error fish_color_escape fish_color_history_current \
fish_color_host fish_color_host_remote fish_color_keyword \
fish_color_normal fish_color_operator fish_color_option \
fish_color_param fish_color_quote fish_color_redirection \
fish_color_search_match fish_color_selection fish_color_status \
fish_color_user fish_color_valid_path fish_pager_color_completion \
fish_pager_color_description fish_pager_color_prefix \
fish_pager_color_progress fish_pager_color_selected_background

常用主题

  • default - 跟随终端配色
  • nord - 北极冷色调
  • dracula - 紫色调深色
  • solarized - 经典护眼
  • catppuccin-mocha - 柔和暖色

Fish 配置示例

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
# ~/.config/fish/config.fish

# 禁用欢迎语
set fish_greeting ""

# 添加 PATH
set -p PATH ~/.local/bin
set -gx PATH $PATH ./node_modules/.bin

# 初始化 Starship 提示符
starship init fish | source

# 初始化 zoxide(智能 cd)
zoxide init fish --cmd cd | source

# 自定义函数
function y
set tmp (mktemp -t "yazi-cwd.XXXXXX")
yazi $argv --cwd-file="$tmp"
if read -z cwd < "$tmp"; and [ -n "$cwd" ]; and [ "$cwd" != "$PWD" ]
builtin cd -- "$cwd"
end
rm -f -- "$tmp"
end

function cat
command bat $argv
end

function ls
command eza --icons $argv
end

function lt
command eza --icons --tree $argv
end

# 缩写命令
abbr fa fastfetch
abbr reboot 'systemctl reboot'

Kitty 终端配置

配置文件位置

~/.config/kitty/kitty.conf          # 主配置文件
~/.config/kitty/dank-theme.conf     # 主题颜色配置
~/.config/kitty/dank-tabs.conf      # 标签页配置

Kitty 主题管理

1
2
3
4
5
# 交互式选择主题
kitty +kitten themes

# 重新加载配置(不重启)
kill -SIGUSR1 $(pgrep kitty)

主题颜色配置

主题文件格式(如 dank-theme.conf):

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
# 光标
cursor #e3e2e2
cursor_text_color #c7c6c6

# 前景和背景
foreground #e3e2e2
background #121414

# 选择区域
selection_foreground #293232
selection_background #bec8c8

# URL 颜色
url_color #b8caca

# 16 色调色板
color0 #121414 # 黑色
color1 #e89668 # 红色
color2 #65ca6d # 绿色
color3 #fcf271 # 黄色
color4 #abbfbf # 蓝色
color5 #4e5d5d # 品红
color6 #b8caca # 青色
color7 #c7d4d4 # 白色
color8 #798383 # 亮黑
color9 #ffc19f # 亮红
color10 #9df2a4 # 亮绿
color11 #fff8a5 # 亮黄
color12 #cddede # 亮蓝
color13 #efffff # 亮品红
color14 #f4ffff # 亮青
color15 #f8ffff # 亮白

Kitty 常用配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# ~/.config/kitty/kitty.conf

include dank-tabs.conf
include dank-theme.conf

# 窗口
window_padding_width 5
hide_window_decorations yes
background_opacity 0.8

# 字体
font_family JetBrains Maple Mono
font_size 13.5

# 其他
remember_window_size no
confirm_os_window_close 0
shell fish
cursor_trail 1
cursor_shape block
shell_integration no-cursor

Starship 提示符配置

配置文件位置

~/.config/starship.toml

配置结构

Starship 配置主要包含:

  1. format - 提示符布局格式
  2. palettes - 颜色调色板
  3. 模块配置 - 各个组件的样式

Powerline 风格配置

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
format = """
[](color_orange)\
$os\
$username\
[](bg:color_yellow fg:color_orange)\
$directory\
[](fg:color_yellow bg:color_aqua)\
$git_branch\
$git_status\
[](fg:color_aqua bg:color_blue)\
$nodejs\
$python\
[](fg:color_blue bg:color_bg3)\
$docker_context\
[](fg:color_bg3 bg:color_bg1)\
$time\
[](fg:color_bg1)\
$line_break$character"""

palette = 'colors'

[palettes.colors]
# 定义颜色变量
color_orange = '#bb9af7'
color_fg0 = '#1a1b26'
color_fg1 = '#c0caf5'
# ... 更多颜色

模块样式配置

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
[os]
disabled = false
style = "bg:color_orange fg:color_fg0"

[os.symbols]
Arch = "󰣇"
Windows = "󰍲"
Macos = "󰀵"
# ... 更多系统图标

[username]
show_always = true
style_user = "bg:color_orange fg:color_fg0"
format = '[ $user ]($style)'

[directory]
style = "fg:color_fg0 bg:color_yellow"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"

[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = "󰏔 "
"Music" = "󰝚 "
"Pictures" = "󰉏 "

[git_branch]
symbol = ""
style = "bg:color_aqua"
format = '[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)'

[nodejs]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'

[time]
disabled = false
time_format = "%R"
style = "bg:color_bg1"
format = '[[ $time ](fg:color_fg1 bg:color_bg1)]($style)'

[character]
success_symbol = '[](bold fg:color_green)'
error_symbol = '[](bold fg:color_red)'

常用图标

图标 Unicode 用途
U+E0B0 Powerline 右箭头
U+E0B2 Powerline 左箭头
U+E0B1 Powerline 细右箭头
󰣇 U+F08C7 Arch Linux
U+E718 Node.js
U+E73C Python
U+E7A8 Git
U+F09A3 Docker
U+F0291 时钟

Tokyo Night 配色方案

颜色定义

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[palettes.colors]
# 主色调
color_orange = '#bb9af7' # 紫色(OS/用户名背景)
color_yellow = '#e0af68' # 黄色(目录背景)
color_aqua = '#7dcfff' # 青色(Git背景)
color_blue = '#7aa2f7' # 蓝色(语言背景)
color_bg1 = '#24283b' # 深蓝(时间背景)
color_bg3 = '#414868' # 中蓝(工具背景)

# 文字颜色
color_fg0 = '#1a1b26' # 深色文字
color_fg1 = '#c0caf5' # 浅色文字

# 强调色
color_green = '#9ece6a' # 绿色(成功)
color_red = '#f7768e' # 红色(错误)
color_purple = '#9d7cd8' # 紫色(其他)

完整 Tokyo Night Starship 配置

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"$schema" = 'https://starship.rs/config-schema.json'
format = """
[](color_orange)\
$os\
$username\
[](bg:color_yellow fg:color_orange)\
$directory\
[](fg:color_yellow bg:color_aqua)\
$git_branch\
$git_status\
[](fg:color_aqua bg:color_blue)\
$c\
$cpp\
$rust\
$golang\
$nodejs\
$php\
$java\
$kotlin\
$haskell\
$python\
[](fg:color_blue bg:color_bg3)\
$docker_context\
$conda\
$pixi\
[](fg:color_bg3 bg:color_bg1)\
$time\
[](fg:color_bg1)\
$line_break$character"""
palette = 'colors'

[palettes.colors]
color_orange = '#bb9af7'
color_fg0 = '#1a1b26'
color_fg1 = '#c0caf5'
color_purple = '#9d7cd8'
color_bg3 = '#414868'
color_green = '#9ece6a'
color_bg1 = '#24283b'
color_blue = '#7aa2f7'
color_red = '#f7768e'
color_aqua = '#7dcfff'
color_yellow = '#e0af68'

[os]
disabled = false
style = "bg:color_orange fg:color_fg0"

[os.symbols]
Arch = "󰣇"
Windows = "󰍲"
Macos = "󰀵"

[username]
show_always = true
style_user = "bg:color_orange fg:color_fg0"
style_root = "bg:color_orange fg:color_fg0"
format = '[ $user ]($style)'

[directory]
style = "fg:color_fg0 bg:color_yellow"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"

[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = "󰏔 "
"Music" = "󰝚 "
"Pictures" = "󰉏 "
"Developer" = "󰲋 "

[git_branch]
symbol = ""
style = "bg:color_aqua"
format = '[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)'

[git_status]
style = "bg:color_aqua"
format = '[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)'

[nodejs]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'

[python]
symbol = ""
style = "bg:color_blue"
format = '[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)'

[docker_context]
symbol = ""
style = "bg:color_bg3"
format = '[[ $symbol( $context) ](fg:#83a598 bg:color_bg3)]($style)'

[time]
disabled = false
time_format = "%R"
style = "bg:color_bg1"
format = '[[ $time ](fg:color_fg1 bg:color_bg1)]($style)'

[line_break]
disabled = false

[character]
disabled = false
success_symbol = '[](bold fg:color_green)'
error_symbol = '[](bold fg:color_red)'
vimcmd_symbol = '[](bold fg:color_green)'

Fastfetch 系统信息配置

配置文件位置

~/.config/fastfetch/config.jsonc

配置结构

Fastfetch 配置主要包含:

  1. logo - Logo 显示设置
  2. display - 显示样式设置
  3. modules - 系统信息模块列表

Tokyo Night 配色配置

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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/master/doc/json_schema.json",
"logo": {
"width": 25,
"color": {
"1": "#7aa2f7", // Logo 主色(蓝色)
"2": "#bb9af7" // Logo 副色(紫色)
},
"padding": {
"top": 1,
"left": 2,
"right": 2
}
},
"display": {
"separator": " ",
"color": {
"title": "#c0caf5", // 标题颜色
"output": "#c0caf5" // 输出文字颜色
}
},
"modules": [
"break",
// 系统信息 - 紫色
{
"type": "os",
"key": "OS",
"keyColor": "#bb9af7"
},
{
"type": "kernel",
"key": " ├ KER ",
"keyColor": "#bb9af7"
},
{
"type": "packages",
"key": " ├ PAK ",
"format": "{all}",
"keyColor": "#bb9af7"
},
{
"type": "title",
"key": " └ USR ",
"keyColor": "#bb9af7"
},
"break",
"break",
// 桌面环境 - 青色
{
"type": "wm",
"key": "WM",
"keyColor": "#7dcfff"
},
{
"type": "de",
"key": " ├ 󱈹 DES ",
"keyColor": "#7dcfff"
},
{
"type": "shell",
"key": " ├ SHE ",
"keyColor": "#7dcfff"
},
{
"type": "terminal",
"key": " ├ TER ",
"keyColor": "#7dcfff"
},
{
"type": "terminalfont",
"key": " └ TFO ",
"keyColor": "#7dcfff"
},
"break",
"break",
// 硬件信息 - 蓝色
{
"type": "host",
"key": "PC ",
"keyColor": "#7aa2f7"
},
{
"type": "cpu",
"key": " ├ CPU ",
"keyColor": "#7aa2f7"
},
{
"type": "memory",
"key": " ├ MEM ",
"keyColor": "#7aa2f7"
},
{
"type": "gpu",
"key": " ├ 󰢮 GPU ",
"format": "{1} {2}",
"keyColor": "#7aa2f7"
},
{
"type": "display",
"key": " ├ MON ",
"format": "{name} {width}x{height}@{refresh-rate} ",
"keyColor": "#7aa2f7"
},
{
"type": "disk",
"key": " └ 󰋊 DIS ",
"keyColor": "#7aa2f7"
},
"break",
"break",
"colors"
]
}

颜色分组说明

分组 颜色 Hex 模块
系统信息 紫色 #bb9af7 OS, 内核, 包, 用户
桌面环境 青色 #7dcfff WM, DE, Shell, 终端
硬件信息 蓝色 #7aa2f7 主机, CPU, 内存, GPU, 显示器, 磁盘

其他配色方案

Catppuccin Mocha

1
2
3
4
5
6
7
8
9
10
"color": {
"1": "#89b4fa", // 蓝色
"2": "#cba6f7" // 紫色
},
// 系统信息
"keyColor": "#cba6f7"
// 桌面环境
"keyColor": "#94e2d5"
// 硬件信息
"keyColor": "#89b4fa"

Nord

1
2
3
4
5
6
7
8
9
10
"color": {
"1": "#88c0d0", // 青色
"2": "#b48ead" // 紫色
},
// 系统信息
"keyColor": "#b48ead"
// 桌面环境
"keyColor": "#88c0d0"
// 硬件信息
"keyColor": "#81a1c1"

Dracula

1
2
3
4
5
6
7
8
9
10
"color": {
"1": "#bd93f9", // 紫色
"2": "#8be9fd" // 青色
},
// 系统信息
"keyColor": "#bd93f9"
// 桌面环境
"keyColor": "#8be9fd"
// 硬件信息
"keyColor": "#6272a4"

常用模块

模块类型 说明 格式变量
os 操作系统 {name}, {version}
kernel 内核版本 {release}
packages 包数量 {all}, {manager}
title 用户名@主机 {user-name}, {host-name}
wm 窗口管理器 {name}
de 桌面环境 {name}
shell Shell {name}, {version}
terminal 终端 {name}
cpu CPU {name}, {cores-logical}
memory 内存 {used}, {total}
gpu GPU {1} 型号, {2} 驱动
display 显示器 {name}, {width}x{height}
disk 磁盘 {size-used}, {size-total}

Fastfetch 命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 运行 fastfetch
fastfetch

# 使用别名(如果配置了)
fa

# 指定配置文件
fastfetch --config /path/to/config.jsonc

# 查看所有可用模块
fastfetch --list-modules

# 查看模块格式
fastfetch --format-help

Eza (ls 替代) 配色配置

配置方式

Eza 的颜色通过 EZA_COLORS 环境变量配置,添加到 ~/.config/fish/config.fish

Tokyo Night 配色

1
2
# Tokyo Night 配色 for eza
set -gx EZA_COLORS "di=38;2;122;162;247:ex=38;2;158;206;106:fi=38;2;192;202;245:ln=38;2;125;207;255:pi=38;2;224;175;104:so=38;2;187;154;247:bd=38;2;224;175;104:cd=38;2;224;175;104:or=38;2;247;118;142"

颜色说明

代码 类型 颜色 Hex
di 目录 蓝色 #7aa2f7
ex 可执行文件 绿色 #9ece6a
fi 普通文件 浅灰 #c0caf5
ln 符号链接 青色 #7dcfff
pi 命名管道 黄色 #e0af68
so 套接字 紫色 #bb9af7
bd 块设备 黄色 #e0af68
cd 字符设备 黄色 #e0af68
or 孤立链接 红色 #f7768e

颜色格式

EZA_COLORS 使用 ANSI 256 色或真彩色格式:

1
2
3
4
5
6
7
8
9
10
11
# 256 色
"di=38;5;123"

# 真彩色 (RGB)
"di=38;2;R;G;B"

# 背景色
"di=48;2;R;G;B"

# 组合
"di=38;2;R;G;B;48;2;R;G;B"

其他配色方案

Catppuccin Mocha

1
set -gx EZA_COLORS "di=38;2;137;180;250:ex=38;2;166;227;161:fi=38;2;205;214;244:ln=38;2;148;226;213:pi=38;2;249;226;175:so=38;2;203;166;247:bd=38;2;249;226;175:cd=38;2;249;226;175:or=38;2;243;139;168"

Nord

1
set -gx EZA_COLORS "di=38;2;136;192;208:ex=38;2;163;190;140:fi=38;2;216;222;233:ln=38;2;180;142;173:pi=38;2;235;203;139:so=38;2;180;142;173:bd=38;2;235;203;139:cd=38;2;235;203;139:or=38;2;191;97;106"

Dracula

1
set -gx EZA_COLORS "di=38;2;139;233;253:ex=38;2;80;250;123:fi=38;2;248;248;242:ln=38;2;189;147;249:pi=38;2;241;250;140:so=38;2;189;147;249:bd=38;2;241;250;140:cd=38;2;241;250;140:or=38;2;255;85;85"

自定义颜色

修改 EZA_COLORS 中的 RGB 值:

1
2
3
# 格式:38;2;R;G;B
# 例如:改为红色目录
set -gx EZA_COLORS "di=38;2;255;0;0:..."

配置位置

1
2
3
# ~/.config/fish/config.fish
# 在文件末尾添加
set -gx EZA_COLORS "di=38;2;122;162;247:..."

重新加载配置

1
2
3
4
# 重新加载 fish 配置
source ~/.config/fish/config.fish

# 或重新打开终端

注意事项

  • EZA_COLORS 是环境变量,不依赖 matugen
  • 颜色值是固定的,不会跟随系统主题变化
  • 使用真彩色(24-bit)格式,确保终端支持

Matugen 主题同步问题

问题描述

系统切换主题色后,Starship、Fastfetch 等工具的配色会自动恢复为系统主题色,手动修改的配置被覆盖。

原因

matugen 是一个主题生成工具,会根据系统主题色自动更新多个应用的配置文件。

检查是否使用 matugen

1
2
3
4
5
6
7
8
# 检查 matugen 是否安装
which matugen

# 检查 matugen 配置
cat ~/.config/matugen/config.toml

# 查看 matugen 管理的模板
ls ~/.config/matugen/templates/

matugen 配置文件位置

~/.config/matugen/config.toml              # 主配置
~/.config/matugen/templates/               # 模板目录

matugen 管理的配置文件

~/.config/matugen/config.toml 中定义了模板映射:

1
2
3
4
5
6
7
8
9
10
11
[templates.starship]
input_path = '~/.config/matugen/templates/starship-colors.toml'
output_path = '~/.config/starship.toml'

[templates.kitty]
input_path = '~/.config/matugen/templates/kitty-colors.conf'
output_path = '~/.config/kitty/dank-theme.conf'

[templates.fastfetch]
input_path = '~/.config/matugen/templates/fastfetch-colors.jsonc'
output_path = '~/.config/fastfetch/config.jsonc'

解决方案

方案 1: 修改 matugen 模板(推荐)

直接修改 matugen 的模板文件,将动态变量替换为固定颜色值。

Starship 模板 (~/.config/matugen/templates/starship-colors.toml):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 将动态变量改为固定颜色
[palettes.colors]
# 原来的动态变量
# color_orange = '{{colors.primary_fixed_dim.default.hex}}'

# 改为 Tokyo Night 固定值
color_orange = '#bb9af7'
color_fg0 = '#1a1b26'
color_fg1 = '#c0caf5'
color_purple = '#9d7cd8'
color_bg3 = '#414868'
color_green = '#9ece6a'
color_bg1 = '#24283b'
color_blue = '#7aa2f7'
color_red = '#f7768e'
color_aqua = '#7dcfff'
color_yellow = '#e0af68'

其他模板同理,将 {{colors.xxx.default.hex}} 替换为固定色值。

方案 2: 禁用特定模板

编辑 ~/.config/matugen/config.toml,注释掉不需要同步的模板:

1
2
3
# [templates.starship]
# input_path = '~/.config/matugen/templates/starship-colors.toml'
# output_path = '~/.config/starship.toml'

方案 3: 删除模板文件

1
2
3
4
# 备份
mv ~/.config/matugen/templates/starship-colors.toml ~/.config/matugen/templates/starship-colors.toml.bak

# 创建空模板或固定模板

matugen 模板语法

matugen 使用 Jinja2 风格的模板语法:

1
2
3
4
5
6
7
8
9
10
11
12
13
# 动态颜色(跟随系统主题)
color = '{{colors.primary.default.hex}}'

# 可用的颜色变量
{{colors.primary.default.hex}} # 主色
{{colors.secondary.default.hex}} # 次色
{{colors.tertiary.default.hex}} # 第三色
{{colors.surface.default.hex}} # 表面色
{{colors.on_primary.default.hex}} # 主色上的文字
{{colors.on_secondary.default.hex}} # 次色上的文字
{{colors.on_surface.default.hex}} # 表面上的文字
{{colors.primary_fixed_dim.default.hex}} # 固定主色(暗)
{{colors.inverse_primary.default.hex}} # 反色主色

常见 matugen 命令

1
2
3
4
5
6
7
8
# 生成主题
matugen image /path/to/wallpaper.jpg

# 使用颜色生成
matugen color '#bb9af7'

# 测试生成(不写入文件)
matugen --dry-run image /path/to/wallpaper.jpg

验证修复

1
2
3
4
5
6
7
8
# 1. 修改模板后,手动运行 matugen 测试
matugen color '#bb9af7'

# 2. 检查配置文件是否被正确生成
head -40 ~/.config/starship.toml

# 3. 切换系统主题,再次检查配置
# 配置应该保持 Tokyo Night 颜色

恢复默认配色教程

恢复 Fish Shell 默认配色

方法 1: 删除颜色变量(推荐)

1
2
3
4
5
6
7
8
9
10
11
# 删除所有 fish 颜色变量
fish -c "set -e fish_color_autosuggestion fish_color_cancel fish_color_command \
fish_color_comment fish_color_cwd fish_color_cwd_root fish_color_end \
fish_color_error fish_color_escape fish_color_history_current \
fish_color_host fish_color_host_remote fish_color_keyword \
fish_color_normal fish_color_operator fish_color_option \
fish_color_param fish_color_quote fish_color_redirection \
fish_color_search_match fish_color_selection fish_color_status \
fish_color_user fish_color_valid_path fish_pager_color_completion \
fish_pager_color_description fish_pager_color_prefix \
fish_pager_color_progress fish_pager_color_selected_background"

方法 2: 手动编辑 fish_variables

1
2
3
4
5
6
7
8
# 编辑文件
nano ~/.config/fish/fish_variables

# 删除所有 SETUVAR fish_color_* 和 SETUVAR fish_pager_color_* 行
# 只保留:
# # This file contains fish universal variable definitions.
# # VERSION: 3.0
# SETUVAR __fish_initialized:4300

方法 3: 使用默认主题

1
2
fish_config theme choose default
fish_config theme save

恢复 Kitty 默认配色

方法 1: 使用内置主题

1
2
3
4
# 交互式选择主题
kitty +kitten themes

# 选择 "default" 或其他内置主题

方法 2: 重置主题文件

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
# 备份当前配置
cp ~/.config/kitty/dank-theme.conf ~/.config/kitty/dank-theme.conf.bak

# 创建默认主题
cat > ~/.config/kitty/dank-theme.conf << 'EOF'
# Default Kitty Colors
foreground #ffffff
background #000000
selection_foreground #ffffff
selection_background #008080

cursor #ffffff
cursor_text_color #000000

color0 #000000
color1 #cc0000
color2 #4e9a06
color3 #c4a000
color4 #3465a4
color5 #75507b
color6 #06989a
color7 #d3d7cf
color8 #555753
color9 #ef2929
color10 #8ae234
color11 #fce94f
color12 #729fcf
color13 #ad7fa8
color14 #34e2e2
color15 #eeeeec
EOF

# 重新加载配置
kill -SIGUSR1 $(pgrep kitty)

恢复 Starship 默认配置

方法 1: 删除配置文件

1
2
3
4
5
# 备份
cp ~/.config/starship.toml ~/.config/starship.toml.bak

# 删除配置文件(使用默认配置)
rm ~/.config/starship.toml

方法 2: 重置为默认配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 创建最小配置
cat > ~/.config/starship.toml << 'EOF'
# Starship 默认配置
format = """
$username\
$hostname\
$directory\
$git_branch\
$git_status\
$nodejs\
$python\
$line_break\
$character"""

[character]
success_symbol = "[❯](bold green)"
error_symbol = "[❯](bold red)"
EOF

恢复 Fastfetch 默认配置

方法 1: 删除配置文件

1
2
3
4
5
# 备份
cp ~/.config/fastfetch/config.jsonc ~/.config/fastfetch/config.jsonc.bak

# 删除配置文件(使用默认配置)
rm ~/.config/fastfetch/config.jsonc

方法 2: 重置为默认配置

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
# 创建默认配置
cat > ~/.config/fastfetch/config.jsonc << 'EOF'
{
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/master/doc/json_schema.json",
"logo": {
"width": 25
},
"display": {
"separator": " "
},
"modules": [
"break",
"title",
"separator",
"os",
"kernel",
"packages",
"shell",
"terminal",
"de",
"wm",
"wmtheme",
"icons",
"cursor",
"terminalfont",
"break",
"host",
"cpu",
"gpu",
"memory",
"swap",
"disk",
"localip",
"battery",
"locale",
"break",
"uptime",
"break",
"colors"
]
}
EOF

一键恢复所有默认配置

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
#!/bin/bash
# restore-defaults.sh

echo "恢复 Fish Shell 默认配色..."
fish -c "set -e fish_color_autosuggestion fish_color_cancel fish_color_command \
fish_color_comment fish_color_cwd fish_color_cwd_root fish_color_end \
fish_color_error fish_color_escape fish_color_history_current \
fish_color_host fish_color_host_remote fish_color_keyword \
fish_color_normal fish_color_operator fish_color_option \
fish_color_param fish_color_quote fish_color_redirection \
fish_color_search_match fish_color_selection fish_color_status \
fish_color_user fish_color_valid_path fish_pager_color_completion \
fish_pager_color_description fish_pager_color_prefix \
fish_pager_color_progress fish_pager_color_selected_background"

echo "备份并恢复 Kitty 默认主题..."
cp ~/.config/kitty/dank-theme.conf ~/.config/kitty/dank-theme.conf.bak 2>/dev/null
# 这里可以添加默认主题内容

echo "备份并删除 Starship 配置..."
mv ~/.config/starship.toml ~/.config/starship.toml.bak 2>/dev/null

echo "备份并删除 Fastfetch 配置..."
mv ~/.config/fastfetch/config.jsonc ~/.config/fastfetch/config.jsonc.bak 2>/dev/null

echo "完成!请重新打开终端。"

常用命令参考

Fish Shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 查看当前主题
fish_config theme show

# 选择并保存主题
fish_config theme choose <theme>
fish_config theme save

# 编辑配置
nano ~/.config/fish/config.fish

# 重新加载配置
source ~/.config/fish/config.fish

# 查看所有函数
functions

# 查看特定函数定义
functions <function_name>

Kitty 终端

1
2
3
4
5
6
7
8
9
10
11
# 编辑配置
nano ~/.config/kitty/kitty.conf

# 重新加载配置
kill -SIGUSR1 $(pgrep kitty)

# 选择主题
kitty +kitten themes

# 查看当前配置
kitty --debug-config

Starship

1
2
3
4
5
6
7
8
9
10
11
# 编辑配置
nano ~/.config/starship.toml

# 预览提示符
starship prompt

# 打印配置
starship config

# 测试配置
starship explain

故障排查

Fish 主题不生效

  1. 检查 ~/.config/fish/fish_variables 是否有颜色变量
  2. 确认终端模拟器的主题设置
  3. 重新打开终端窗口

Kitty 配置不生效

  1. 运行 kill -SIGUSR1 $(pgrep kitty) 重新加载
  2. 检查配置文件语法
  3. 查看 Kitty 日志:kitty --debug-config

Starship 提示符异常

  1. 检查 ~/.config/starship.toml 语法
  2. 运行 starship prompt 测试输出
  3. 确认 Fish 中已初始化:starship init fish | source

颜色显示不正确

  1. 确认终端支持真彩色(24-bit color)
  2. 检查 $TERM 变量:echo $TERM
  3. Kitty 应设置为 xterm-kitty

参考资源


最后更新: 2026-05-17 配置环境: Arch Linux + Fish Shell + Kitty + Starship + Fastfetch + Matugen


Fish、Kitty 与 Starship 终端美化指南
https://tingfeng347.github.io/2026/02/14/Fish、Kitty 与 Starship 终端美化指南/
作者
Tingfeng
发布于
2026年2月14日
许可协议