macOS 的预设终端机为 Terminal.app ,对於使用终端频率较少的一般使用者是十分足够的,但对於开发者而言,它依然有许多可以改进的地方,像是执行效率、配置方式等。
为了提升开发时使用终端机时的效率,因此我们需要一个适合开发的终端。
Alacritty 是个执行速度极快的跨平台终端机,它专注在终端机本身的功能上,因此像是许多终端机都内置的分页功能, Alacritty 是没有的,取而代之的是建议使用者整合其他专注特定功能的工具来使用(例如分页与视窗功能可以藉由整合 Tmux 达成)。
因为其实作的功能单纯,因此使得它拥有高效率与高扩展的特性,成为合适开发者使用的终端机之一。
使用 Homebrew 安装 Alacritty :
brew install alacritty
接着在「启动台」内按下 Alacritty 启动应用程序。
Alacritty 的配置依赖一个 Yaml 档,预设并不会产生这个配置档,需要自行去下载。
在 GitHub 的发布页中可以找到名为 alacritty.yml
的档案,这就是 Alacritty 配置档的内容。请依照安装的版本,下载对应的档案。
这个配置档可以放於:
$XDG_CONFIG_HOME/alacritty/alacritty.yml
$XDG_CONFIG_HOME/alacritty.yml
$HOME/.config/alacritty/alacritty.yml
$HOME/.alacritty.yml
Alacritty 会依序由第一个往下找各个路径,如果都没有设置,则会使用预设的配置。
在放置好後,打开配置档,会看到有各个设定属性及说明,全部的属性都会是注解的状态,如果要做设定,请将属性反注解,部分属性需重启 Alacritty 才会显现效果,说明上会有提示,可以依照说明来决定是否重启。
举个例子,如果我现在想要把上方列给除去的话,我可以将 window.decorations
值改为 buttonless
:
window:
# Window dimensions (changes require restart)
#
# Window decorations
#
# Values for `decorations`:
# - full: Borders and title bar
# - none: Neither borders nor title bar
#
# Values for `decorations` (macOS only):
# - transparent: Title bar, transparent background and title bar buttons
# - buttonless: Title bar, transparent background and no title bar buttons
decorations: buttonless
依照指示 window
相关的属性变更都需要重启 Alacritty ,重启後就可以看到配置生效後的效果了。
接着介绍几个常用的配置。
window:
# 动态调整边缘与内容的间距,避免切到内容
dynamic_padding: true
# 隐藏视窗上方的 Bar
decorations: buttonless
# 开启时的初始模式
startup_mode: Maximized
font:
normal:
family: Hack Nerd Font Mono
style: Regular
bold:
family: Hack Nerd Font Mono
style: Bold
italic:
family: Hack Nerd Font Mono
style: Italic
bold_italic:
family: Hack Nerd Font Mono
style: Bold Italic
# 字元大小
size: 16.0
offset:
x: 0
# 行间距
y: 8
glyph_offset:
x: 0
# 保持 offset 的一半,确保字元会在行的正中间
y: 4
use_thin_strokes: true
字型来源是 NERD FONTS ,可以使用 Homebrew 安装
# Colors (One Dark)
colors:
# Default colors
primary:
background: '0x1e2127'
foreground: '0xabb2bf'
# Normal colors
normal:
black: '0x1e2127'
red: '0xe06c75'
green: '0x98c379'
yellow: '0xd19a66'
blue: '0x61afef'
magenta: '0xc678dd'
cyan: '0x56b6c2'
white: '0xabb2bf'
# Bright colors
bright:
black: '0x5c6370'
red: '0xe06c75'
green: '0x98c379'
yellow: '0xd19a66'
blue: '0x61afef'
magenta: '0xc678dd'
cyan: '0x56b6c2'
white: '0xffffff'
颜色主题参考 eendroroy/alacritty-theme 的 One Dark 。
在启动终端机时,如果有想要自动执行的指令,可以使用 shell
属性来设置。
# 启动时执行的指令
shell:
program: /bin/zsh
args:
- -l
- -c
- 'tmux attach || tmux'
上面的设定会在启动 Alacritty 时自动执行 Tmux 。
完整的配置可以参考 peterhpchen/dotfiles 。
alacritty.yml
。
<<: [Day 5] Reactive Programming - Java 9(Publisher、Subscribers)
>>: [Lesson4] SharedPreferences
今日题目:409. Longest Palindrome Given a string s whic...
回到储存空间部分, 因为有个 EFS也挺重要的 EFS (Elastic File System)...
如何实现一套基础开发流程? 在前面的章节里谈到了 GCP、Docker、Cloud Run 等技术,...
[Day18] Unreal Webcam Fun 需要用到的技巧与练习目标 MediaDevice...
在这个范例里,是用单一方式去验证active是否为true <div v-bind:class...