6.7 KiB

Alacritty Configuration

Alacritty Configuration

This is my Alacritty terminal emulator configuration. It is set up to automatically tangle to a file named alacritty.toml whenever saved. This literate configuration approach allows embedding explanations directly alongside the settings, making it easier to understand and maintain.

Header

A decorative header block included at the top of the tangled alacritty.toml file.

#
# ██████╗  ██████╗  ██████╗ ███████╗
# ██╔══██╗██╔═══██╗██╔════╝ ██╔════╝     Roger Gonzalez
# ██████╔╝██║   ██║██║  ███╗███████╗     https://rogs.me
# ██╔══██╗██║   ██║██║   ██║╚════██║
# ██║  ██║╚██████╔╝╚██████╔╝███████║
# ╚═╝  ╚═╝ ╚═════╝  ╚═════╝ ╚══════╝

Colors

Defines the color scheme used within the terminal. This configuration uses a custom theme inspired by common dark palettes.

Bright Colors

These colors are used for brighter versions of the standard 8 ANSI colors, often invoked with specific escape codes or application settings.

[colors.bright]
black = "0x434758"
blue = "0x9cc4ff"
cyan = "0xa3f7ff"
green = "0xddffa7"
magenta = "0xe1acff"
red = "0xff8b92"
white = "0xffffff"
yellow = "0xffe585"

Normal Colors

These are the standard 8 ANSI colors used by most terminal applications.

[colors.normal]
black = "0x282a36"
blue = "0x82aaff"
cyan = "0x89ddff"
green = "0xc3e88d"
magenta = "0xc792ea"
red = "0xf07178"
white = "0xd0d0d0"
yellow = "0xffcb6b"

Primary Colors

Defines the default foreground (text) and background colors of the terminal window itself.

[colors.primary]
background = "0x000000"
foreground = "0xd0d0d0"

Selection Colors

Sets the background color for selected text. The foreground color of selected text remains the default foreground unless explicitly set.

[colors.selection]
background = "0x555555"

Environment

Sets environment variables within Alacritty. TERM = "xterm-256color" is widely compatible and signals support for 256 colors to terminal applications like vim, tmux, etc.

[env]
TERM = "xterm-256color"

Font Configuration

Configures the fonts used for rendering text in the terminal.

Font Size

[font]
size = 12.0

Normal Font

Specifies the default font family. 'MesloLGS Nerd Font Composite' is chosen for its clarity and built-in support for icons (via Nerd Fonts patching). The same family is used for bold/italic variants, relying on the font itself to provide these styles.

[font.normal]
family = "MesloLGS Nerd Font Composite"

Bold Font

[font.bold]
family = "MesloLGS Nerd Font Composite"

Italic Font

[font.italic]
family = "MesloLGS Nerd Font Composite"

Bold Italic Font

[font.bold_italic]
family = "MesloLGS Nerd Font Composite"

Scrolling

Configures scrollback behavior:

  • history: Defines the maximum number of lines kept in the scrollback buffer (10000 lines).
  • multiplier: Controls how many lines are scrolled per mouse wheel tick or keypress (3 lines).
[scrolling]
history = 10000
multiplier = 3

Window Settings

Adjusts various aspects of the Alacritty window appearance and behavior.

General Window Settings

Configures general window properties:

  • opacity: Sets the window background opacity (0.0 - 1.0). 0.80 means 80% opaque. Requires a running compositor (e.g., Picom, Mutter, KWin).
  • title: The default title displayed for the Alacritty window. Can be overridden by shell prompts or applications.
[window]
opacity = 0.80
title = "Alacritty"

Window Class

Sets the window class (general) and instance names. These are primarily used by Wayland compositors and some X11 window managers for identification, allowing specific window rules (like placement or decoration) to be applied.

[window.class]
general = "Alacritty"
instance = "Alacritty"

Window Padding

Adds padding (in pixels) around the terminal content within the window.

[window.padding]
x = 6
y = 6

Setting Up Auto-Tangle

To enable auto-tangling on save, you'll need to add a function to your Emacs configuration. This requires Emacs with Org Mode and the org-babel functionality enabled (usually default). Add the following to your ~/.emacs.d/init.el or equivalent (using use-package here for demonstration):

;; Auto-tangle configuration files
(use-package org
  :config
  (defun org-babel-auto-tangle ()
    "Automatically tangle org files when saved."
    (when (eq major-mode 'org-mode)
      (let ((auto-tangle (cdr (assoc "auto_tangle" (org-collect-keywords '("PROPERTY"))))))
        (when (and auto-tangle (string= auto-tangle "t"))
          (org-babel-tangle)))))
  (add-hook 'after-save-hook #'org-babel-auto-tangle))