自从沉迷 nvim 依赖,更换过很多终端模拟器,这次给大家分享一个新的终端 Ghostty,可玩性很高。

按照惯例先来几张图,吸引一下:

基础外观 预览 tab 光标动画 下雪特效

配置详情

配置也很简单,基础配置放在 ~/.config/ghostty/config 文件里。

配置文件修改需要重新载入,部分配置仅支持新窗口、新标签页。

可使用 Ctrl + Shift + , 快速重载配置。

字体配置

# ghostty +show-config --default --docs
# ghostty +list-themes

font-family = FiraCode Nerd Font Mono
font-family = Symbols Nerd Font Mono
font-family = PingFang SC
# font-family-bold = PragmataPro Liga
# font-family-italic = PragmataPro Liga
# font-family-bold-italic = PragmataPro Liga

font-feature = FiraCode-Retina
font-feature = +zero
# font-feature = +onum
font-feature = calt
font-feature = liga
font-feature = ss13
font-codepoint-map = U+4E00-U+9FFF=Sarasa Mono SC Regular
font-codepoint-map = U+3400-U+4DBF=Sarasa Mono SC Regular
font-size = 13
font-thicken = true

window-inherit-font-size = true

窗口设置

# Window
window-height = 30
window-width = 100

美化

# Look and Feel
adjust-cursor-thickness = 3
adjust-underline-position = 3
bold-is-bright = true
cursor-invert-fg-bg = true
cursor-opacity = 0.8
cursor-style = bar
link-url = true
mouse-hide-while-typing = true
window-vsync = true
background-opacity = 0.9
background-blur = true

其他配置

# Other
clipboard-paste-protection = true
clipboard-trim-trailing-spaces = true
copy-on-select = true
macos-auto-secure-input = true
macos-secure-input-indication = true
macos-titlebar-style = tabs
macos-option-as-alt = true
quit-after-last-window-closed = true
scrollback-limit = 4200
shell-integration = zsh
shell-integration-features = cursor,sudo,title

按键绑定

# Key bindings
keybind = ctrl+h=goto_split:left
keybind = ctrl+j=goto_split:bottom
keybind = ctrl+k=goto_split:top
keybind = ctrl+l=goto_split:right
keybind = ctrl+shift+h=new_split:left
keybind = ctrl+shift+j=new_split:down
keybind = ctrl+shift+k=new_split:up
keybind = ctrl+shift+l=new_split:right
keybind = super+shift+enter=new_split:auto
keybind = super+shift+i=inspector:toggle
keybind = super+shift+r=reload_config
keybind = super+t=new_tab

配置的内容只简单的修改了一些字体和样式,快捷键也只配置了几个管理 tab 和窗口的。

特效

Ghostty 支持自定义着色器,可以给窗口增加很多特效,我也是被光标动画这个着色器吸引来的。

下载已有的 Shader

这里我推荐 https://github.com/hackr-sh/ghostty-shaders.git

git submodule add https://github.com/hackr-sh/ghostty-shaders.git ~/.config/ghostty/shaders

自定义 Shader

# Shader

# 启用一直更新动画,窗口失去焦点仍然运行
custom-shader-animation = always

# custom-shader = shaders/animated-gradient-shader.glsl
# custom-shader = shaders/bettercrt.glsl
# custom-shader = shaders/bloom.glsl
# custom-shader = shaders/cineShader-Lava.glsl
# custom-shader = shaders/crt.glsl
# custom-shader = shaders/cubes.glsl

# 光标动画
# custom-shader = shaders/cursor_blaze.glsl

# custom-shader = shaders/dither.glsl
# custom-shader = shaders/drunkard.glsl
# custom-shader = shaders/fireworks-rockets.glsl
# custom-shader = shaders/fireworks.glsl
# custom-shader = shaders/galaxy.glsl
# custom-shader = shaders/gears-and-belts.glsl
# custom-shader = shaders/glitchy.glsl
# custom-shader = shaders/glow-rgbsplit-twitchy.glsl
# custom-shader = shaders/gradient-background.glsl
# custom-shader = shaders/in-game-crt.glsl
# custom-shader = shaders/inside-the-matrix.glsl
# custom-shader = shaders/just-snow.glsl
# custom-shader = shaders/matrix-hallway.glsl
# custom-shader = shaders/mnoise.glsl
# custom-shader = shaders/negative.glsl
# custom-shader = shaders/retro-terminal.glsl
# custom-shader = shaders/sin-interference.glsl
# custom-shader = shaders/smoke-and-ghost.glsl
# custom-shader = shaders/sparks-from-fire.glsl
# custom-shader = shaders/spotlight.glsl
# custom-shader = shaders/starfield-colors.glsl
# custom-shader = shaders/starfield.glsl
# custom-shader = shaders/tft.glsl
# custom-shader = shaders/underwater.glsl
# custom-shader = shaders/water.glsl

主题配置

主题配置文件在 ~/.config/ghostty/themes 下,创建 tokyonight_daytokyonight_night 两个文件,也可以是别的名字,只要在配置中对应即可,在这里提供一套黑白主题。

tokyonight_day

palette = 0=#b4b5b9
palette = 1=#f52a65
palette = 2=#587539
palette = 3=#8c6c3e
palette = 4=#2e7de9
palette = 5=#9854f1
palette = 6=#007197
palette = 7=#6172b0
palette = 8=#a1a6c5
palette = 9=#ff4774
palette = 10=#5c8524
palette = 11=#a27629
palette = 12=#358aff
palette = 13=#a463ff
palette = 14=#007ea8
palette = 15=#3760bf

background = #e1e2e7
foreground = #3760bf
cursor-color = #3760bf
selection-background = #b7c1e3
selection-foreground = #3760bf

tokyonight_night

palette = 0=#15161e
palette = 1=#f7768e
palette = 2=#9ece6a
palette = 3=#e0af68
palette = 4=#7aa2f7
palette = 5=#bb9af7
palette = 6=#7dcfff
palette = 7=#a9b1d6
palette = 8=#414868
palette = 9=#ff899d
palette = 10=#9fe044
palette = 11=#faba4a
palette = 12=#8db0ff
palette = 13=#c7a9ff
palette = 14=#a4daff
palette = 15=#c0caf5

background = #1a1b26
foreground = #c0caf5
cursor-color = #c0caf5
selection-background = #283457
selection-foreground = #c0caf5

配置内容

在配置文件的 Look and Feel 里增加一行配置。

theme                          = dark:tokyonight_night,light:tokyonight_day

当然如果你想一直使用同一个配色,把 dark 和 light 配置成一样就行了。

完整配置

# ghostty +show-config --default --docs
# ghostty +list-themes

font-family = FiraCode Nerd Font Mono
font-family = Symbols Nerd Font Mono
font-family = PingFang SC
# font-family-bold = PragmataPro Liga
# font-family-italic = PragmataPro Liga
# font-family-bold-italic = PragmataPro Liga

font-feature = FiraCode-Retina
font-feature = +zero
# font-feature = +onum
font-feature = calt
font-feature = liga
font-feature = ss13
font-codepoint-map = U+4E00-U+9FFF=Sarasa Mono SC Regular
font-codepoint-map = U+3400-U+4DBF=Sarasa Mono SC Regular
font-size = 13
font-thicken = true

window-inherit-font-size = true

# Window
window-height = 30
window-width = 100

# Look and Feel
adjust-cursor-thickness = 3
adjust-underline-position = 3
bold-is-bright = true
cursor-invert-fg-bg = true
cursor-opacity = 0.8
cursor-style = bar
link-url = true
mouse-hide-while-typing = true
theme = dark:tokyonight_night,light:tokyonight_night
window-vsync = true
background-opacity = 0.9
background-blur = true

# Shader
custom-shader-animation = always
# custom-shader = shaders/animated-gradient-shader.glsl
# custom-shader = shaders/bettercrt.glsl
# custom-shader = shaders/bloom.glsl
# custom-shader = shaders/cineShader-Lava.glsl
# custom-shader = shaders/crt.glsl
# custom-shader = shaders/cubes.glsl
custom-shader = shaders/cursor_blaze.glsl
# custom-shader = shaders/dither.glsl
# custom-shader = shaders/drunkard.glsl
# custom-shader = shaders/fireworks-rockets.glsl
# custom-shader = shaders/fireworks.glsl
# custom-shader = shaders/galaxy.glsl
# custom-shader = shaders/gears-and-belts.glsl
# custom-shader = shaders/glitchy.glsl
# custom-shader = shaders/glow-rgbsplit-twitchy.glsl
# custom-shader = shaders/gradient-background.glsl
# custom-shader = shaders/in-game-crt.glsl
# custom-shader = shaders/inside-the-matrix.glsl
custom-shader = shaders/just-snow.glsl
# custom-shader = shaders/matrix-hallway.glsl
# custom-shader = shaders/mnoise.glsl
# custom-shader = shaders/negative.glsl
# custom-shader = shaders/retro-terminal.glsl
# custom-shader = shaders/sin-interference.glsl
# custom-shader = shaders/smoke-and-ghost.glsl
# custom-shader = shaders/sparks-from-fire.glsl
# custom-shader = shaders/spotlight.glsl
# custom-shader = shaders/starfield-colors.glsl
# custom-shader = shaders/starfield.glsl
# custom-shader = shaders/tft.glsl
# custom-shader = shaders/underwater.glsl
# custom-shader = shaders/water.glsl

# Other
clipboard-paste-protection = true
clipboard-trim-trailing-spaces = true
copy-on-select = true
macos-auto-secure-input = true
macos-secure-input-indication = true
macos-titlebar-style = tabs
macos-option-as-alt = true
quit-after-last-window-closed = true
scrollback-limit = 4200
shell-integration = zsh
shell-integration-features = cursor,sudo,title

# Key bindings
keybind = ctrl+h=goto_split:left
keybind = ctrl+j=goto_split:bottom
keybind = ctrl+k=goto_split:top
keybind = ctrl+l=goto_split:right
keybind = ctrl+shift+h=new_split:left
keybind = ctrl+shift+j=new_split:down
keybind = ctrl+shift+k=new_split:up
keybind = ctrl+shift+l=new_split:right
keybind = super+shift+enter=new_split:auto
keybind = super+shift+i=inspector:toggle
keybind = super+shift+r=reload_config
keybind = super+t=new_tab