Alacritty 是一个现代终端模拟器,具有合理的默认设置,但允许进行广泛的配置。通过与其他应用程序集成,而不是重新实现它们的功能,它能够提供一套灵活的高性能特性。目前支持的平台包括 BSD、Linux、macOS 和 Windows。
如果不需要修改图标推荐直接下载
直接下载官网编译的安装包 https://alacritty.org/index.html
手动编译 这里因为源代码的图标是方形直角, 并且和 macOS 的图标风格不太搭配, 所以我自己 fork 了一份修改了图标, 所以需要手动编译
安装 rust 和 make 环境
bash# 安装 rust 环境, 如果已存在则可以跳过
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
brew install make
bash # 浅克隆仓库代码
git clone --depth 1 https://github.com/KevinYouu/alacritty.git
cd alacritty
# 编译当前架构
make dmg
# 编译 macOS 的通用架构
# dmg-universal
然后可以在 alacritty/target/release/osx
这个目录找到编译好的 app 和 dmg 文件, 直接放入 /Applications
即可使用
这是我的自定义配置文件
toml[window]
dimensions = { columns = 80, lines = 24 }
padding = { x = 4, y = 0 }
opacity = 0.2
blur = true
[font]
normal = { family = "Roboto Mono", style = "Regular" }
bold = { family = "Roboto Mono", style = "bold" }
italic = { family = "Roboto Mono", style = "italic" }
bold_italic = { family = "Roboto Mono", style = "bold italic" }
size = 18
[selection]
save_to_clipboard = true
semantic_escape_chars = ",│`|:\"' ()[]{}<>\t"
[cursor]
style = { shape = "Beam", blinking = "On" }
[terminal]
shell = { program = "/opt/homebrew/bin/fish", args = ["-l"] }
[colors.primary]
foreground = "#ffffff" # 白色
background = "#000000" # 黑色
[colors.normal]
black = "#000000"
red = "#ff3b30"
green = "#4cd964"
yellow = "#ffcc00"
blue = "#007aff"
magenta = "#ff2d55"
cyan = "#5ac8fa"
white = "#ffffff"
[colors.bright]
black = "#686868"
red = "#ff3b30"
green = "#4cd964"
yellow = "#ffcc00"
blue = "#007aff"
magenta = "#ff2d55"
cyan = "#5ac8fa"
white = "#ffffff"
[keyboard]
bindings = [
# 复制 (Cmd + C)
{ key = "C", mods = "Command", action = "Copy" },
# 粘贴 (Cmd + V)
{ key = "V", mods = "Command", action = "Paste" },
# 查找 (Cmd + F)
{ key = "F", mods = "Command", action = "SearchForward" },
# 新建窗口 (Cmd + N)
{ key = "N", mods = "Command", action = "CreateNewWindow" },
# 缩小字体 (Cmd + -)
{ key = "Minus", mods = "Command", action = "DecreaseFontSize" },
# 放大字体 (Cmd + =)
{ key = "Equals", mods = "Command", action = "IncreaseFontSize" },
# 恢复默认字体大小 (Cmd + 0)
{ key = "Key0", mods = "Command", action = "ResetFontSize" },
# 切换全屏 (Cmd + Enter)
{ key = "Return", mods = "Command", action = "ToggleSimpleFullscreen" },
# 切换到具体标签页 (Cmd + 1 ~ Cmd + 9)
{ key = "Key1", mods = "Command", action = "SelectTab1" },
{ key = "Key2", mods = "Command", action = "SelectTab2" },
{ key = "Key3", mods = "Command", action = "SelectTab3" },
{ key = "Key4", mods = "Command", action = "SelectTab4" },
{ key = "Key5", mods = "Command", action = "SelectTab5" },
{ key = "Key6", mods = "Command", action = "SelectTab6" },
{ key = "Key7", mods = "Command", action = "SelectTab7" },
{ key = "Key8", mods = "Command", action = "SelectTab8" },
{ key = "Key9", mods = "Command", action = "SelectTab9" },
# 隐藏 Alacritty (Cmd + H)
{ key = "H", mods = "Command", action = "Hide" },
# 隐藏其他应用 (Cmd + Option + H)
{ key = "H", mods = "Command|Option", action = "HideOtherApplications" },
]
Alacritty 的配置文件使用 TOML 格式。其规范可以在 https://toml.io/en/v1.0.0
找到。
Alacritty 不会自动创建配置文件,但它会在特定位置查找该文件。
UNIX 系统:
$XDG_CONFIG_HOME/alacritty/alacritty.toml
$XDG_CONFIG_HOME/alacritty.toml
$HOME/.config/alacritty/alacritty.toml
$HOME/.alacritty.toml
Windows 系统:
%APPDATA%\alacritty\alacritty.toml
[general]
- 通用配置import
["<string>", ...]
~/
) 的路径,或相对于当前配置文件的路径。tomlimport = [
"~/.config/alacritty/base16-dark.toml",
"~/.config/alacritty/keybindings.toml",
]
working_directory
"<string>"
或 "None"
"None"
或未设置,将使用父进程的工作目录。"None"
live_config_reload
true
| false
true
ipc_socket
true
| false
alacritty msg
进行 IPC (进程间通信)。true
[env]
- 环境变量在此部分中定义的所有键值对,都将作为环境变量添加到由 Alacritty 启动的任何进程中(包括其 Shell)。
toml[env]
WINIT_X11_SCALE_FACTOR = "1.0"
[window]
- 窗口配置dimensions
{ columns = <integer>, lines = <integer> }
columns
必须至少为 2
。{ columns = 0, lines = 0 }
position
{ x = <integer>, y = <integer> }
或 "None"
"None"
,则由窗口管理器决定位置。"None"
padding
{ x = <integer>, y = <integer> }
{ x = 0, y = 0 }
dynamic_padding
true
| false
false
decorations
"Full"
| "None"
| "Transparent"
| "Buttonless"
Full
: 完整边框和标题栏。None
: 无边框和标题栏。Transparent
(仅限 macOS): 透明背景的标题栏和按钮。Buttonless
(仅限 macOS): 透明背景的标题栏但无按钮。"Full"
opacity
<float>
0.0
(完全透明) 到 1.0
(完全不透明)。1.0
blur
true
| false
false
startup_mode
"Windowed"
| "Maximized"
| "Fullscreen"
| "SimpleFullscreen"
Windowed
: 普通窗口。Maximized
: 启动时最大化。Fullscreen
: 启动时全屏。SimpleFullscreen
(仅限 macOS): 与 Fullscreen
类似,但允许其他窗口堆叠在其上。"Windowed"
title
"<string>"
"Alacritty"
dynamic_title
true
| false
true
class
{ instance = "<string>", general = "<string>" }
general
用作 app_id
。{ instance = "Alacritty", general = "Alacritty" }
decorations_theme_variant
"Dark"
| "Light"
| "None"
"None"
使用系统默认值。"None"
resize_increments
true
| false
false
option_as_alt
"OnlyLeft"
| "OnlyRight"
| "Both"
| "None"
Option
键映射为 Alt
键。"None"
level
"Normal"
| "AlwaysOnTop"
Normal
: 窗口遵守系统默认的 Z 轴顺序。AlwaysOnTop
: 窗口始终位于顶层。"Normal"
[scrolling]
- 滚动配置history
<integer>
0
将禁用滚动。最大限制为 100000
。10000
multiplier
<integer>
3
[font]
- 字体配置normal
{ family = "<string>", style = "<string>" }
{ family = "monospace", style = "Regular" }
{ family = "Consolas", style = "Regular" }
{ family = "Menlo", style = "Regular" }
bold
{ family = "<string>", style = "<string>" }
family
,将使用 normal
的字体族。{ style = "Bold" }
italic
{ family = "<string>", style = "<string>" }
family
,将使用 normal
的字体族。{ style = "Italic" }
bold_italic
{ family = "<string>", style = "<string>" }
family
,将使用 normal
的字体族。{ style = "Bold Italic" }
size
<float>
11.25
offset
{ x = <integer>, y = <integer> }
y
用于调整行间距,x
用于调整字间距。{ x = 0, y = 0 }
glyph_offset
{ x = <integer>, y = <integer> }
x
增加向右移动,y
增加向上移动。builtin_box_drawing
true
| false
true
时,Alacritty 将使用内置字体来绘制制表符 (U+2500 - U+259F)、旧式计算符号 (U+1FB00 - U+1FB3B) 和 Powerline 符号 (U+E0B0 - U+E0B3)。true
[colors]
- 颜色配置颜色使用 #RRGGBB
格式的十六进制值指定。
primary
foreground
: 默认 "#d8d8d8"
。background
: 默认 "#181818"
。dim_foreground
: 默认 "#828482"
。如果未设置,将基于前景色自动计算。bright_foreground
: 默认 "None"
。仅在 draw_bold_text_with_bright_colors
为 true
时使用。cursor
{ text = "<string>", cursor = "<string>" }
CellForeground
/CellBackground
。{ text = "CellBackground", cursor = "CellForeground" }
selection
{ text = "<string>", background = "<string>" }
{ text = "CellBackground", background = "CellForeground" }
normal
black
: "#181818"
red
: "#ac4242"
green
: "#90a959"
yellow
: "#f4bf75"
blue
: "#6a9fb5"
magenta
: "#aa759f"
cyan
: "#75b5aa"
white
: "#d8d8d8"
bright
black
: "#6b6b6b"
red
: "#c55555"
green
: "#aac474"
yellow
: "#feca88"
blue
: "#82b8c8"
magenta
: "#c28cb8"
cyan
: "#93d3c3"
white
: "#f8f8f8"
draw_bold_text_with_bright_colors
true
| false
true
时,粗体文本将使用 bright
部分定义的亮色进行渲染。false
[cursor]
- 光标配置style
shape
: 可选值为 "Block"
, "Underline"
, "Beam"
。默认 "Block"
。blinking
: 可选值为 "Never"
, "Off"
, "On"
, "Always"
。默认 "Off"
。unfocused_hollow
true
| false
true
thickness
<float>
0.0
到 1.0
。0.15
[keyboard]
- 键盘绑定bindings
[{ key = "<key>", mods = "<mods>", action = "<action>" | ... }, ...]
action
设置为 "ReceiveChar"
或 "None"
。key
: 按键名称 (例如 "A"
, "F1"
) 或按键的 scancode。mods
: 修饰键 ("Control"
, "Shift"
, "Alt"
, "Super"
, "Command"
),多个修饰键用 |
分隔。mode
: 绑定生效的终端模式 (如 "Vi"
, "Search"
)。action
: 预定义的动作,如 Paste
, Copy
, ToggleFullscreen
等。chars
: 向终端写入指定的字符串。command
: 执行一个外部命令。toml[[keyboard.bindings]]
key = "N"
mods = "Control|Shift"
action = "CreateNewWindow"
[debug]
- 调试配置这些选项用于帮助排查问题,其功能和可用性可能会在没有警告的情况下更改。
persistent_logging
true
| false
false
log_level
"Off"
| "Error"
| "Warn"
| "Info"
| "Debug"
| "Trace"
"Warn"
renderer
"glsl3"
| "gles2"
| "gles2pure"
| "None"
"None"
将使用可用的最高级渲染器。"None"