A good[ish] website
Web development blog, loads of UI and JavaScript topics
Alacritty is a suckless terminal emulator written in Rust, it’s extremely fast and very simple. Here’s how to install and configure it.
What is a suckless program?
Software with a focus on simplicity, clarity, and frugality.
Meaning, for example, that Alacritty will never "call home" to gather telemetry, aka track you. It will never haze you with automated update notices. There’s no package manager, there’s no GUI for settings, nor for menus, it doesn’t have tabs, there’s nothing... just a void of pure, unadulterated nihilism.
This either sucks less, or sucks more, depending on your personality.
I’m on Mac, so this install guide is Mac-centric, but see the Alacritty repo for more installation instructions.
Since Alacritty is a GUI app (icon in the Applications directory), in Homebrew-land this means it’s a "cask", and has to be installed with the --cask
flag:
$ brew install --cask --no-quarantine alacritty
The --no-quarantine
option is needed because Alacritty isn’t part of the Apple developer program. Otherwise you might get this error:
Check your version with the capital V:
$ alacritty -V
And upgrade Alacritty if needed:
$ brew upgrade --cask --no-quarantine alacritty
From the docs:
To make sure Alacritty works correctly, either the
alacritty
oralacritty-direct
terminfo must be used. Thealacritty
terminfo will be picked up automatically if it is installed.
Test if you got terminfo installed:
$ infocmp alacritty
Clone Alacritty because we need bits from it, and hop into the dir:
$ git clone https://github.com/alacritty/alacritty.git
$ cd alacritty
Then setup terminfo:
$ sudo tic -xe alacritty,alacritty-direct extra/alacritty.info
Config is done with a YAML file that lives in ~/.config/alacritty/alacritty.yml
. This is great, because now you can keep the config in your dotfiles and share it between machines, which you can’t do with iTerm for example.
My config is pretty default, but I’ve cherry picked few things to highlight here. See the full config below.
Copy the selected text to system clipboard without having to press Cmd/Ctrl+c:
selection:
# This string contains all characters that are used as separators for
# "semantic words" in Alacritty.
semantic_escape_chars: ",│`|:\"' ()[]{}<>\t"
# When set to `true`, selected text will be copied to the primary clipboard.
save_to_clipboard: true
This mapping is for British keyboard layout. This is needed so that you can type hashes in Vim for example, which is Alt+3.
key_bindings:
- { key: Key0, mods: Alt, chars: 'º' }
- { key: Key1, mods: Alt, chars: '¡' }
- { key: Key2, mods: Alt, chars: '€' }
- { key: Key3, mods: Alt, chars: '#' }
- { key: Key4, mods: Alt, chars: '¢' }
- { key: Key5, mods: Alt, chars: '∞' }
- { key: Key6, mods: Alt, chars: '§' }
- { key: Key7, mods: Alt, chars: '¶' }
- { key: Key8, mods: Alt, chars: '•' }
- { key: Key9, mods: Alt, chars: 'ª' }
See this thread in GitHub for more examples. And a this Wiki entry for more keyboard configs for layouts like German, Swiss, Italian, Spanish, Portuguese...
If you’re on fish, tell Alacritty about it:
shell:
program: /usr/local/bin/fish
args:
- --login
Get the path to your fish with $ which fish
.
Then set the fish completion by grabbing the alacritty.fish
completion mapping from the Alacritty repo we cloned earlier:
$ mkdir -p $fish_complete_path[1]
$ cp extra/completions/alacritty.fish $fish_complete_path[1]/alacritty.fish
Make URLs clickable when Cmd is held down:
mouse:
url:
launcher:
# This depends on your OS, on Mac it’s `open`
program: open
modifiers: Command
But why can’t I click URLs even if I have configured it the right way? You might be in a tmux session and have the mouse mode enabled, which captures clicks before Alactitty can see them. The mouse mode can disabled by pressing Shift, so Cmd+Shift click, should work.
See a selection of color themes in the Alacritty repo.
This is my full config at the time of writing this:
window:
# Blank space added around the window in pixels. This padding is scaled
# by DPI and the specified value is always added at both opposing sides.
padding:
x: 10
y: 10
scrolling:
# Specifying '0' will disable scrolling.
history: 100000
# Number of lines the viewport will move for every line scrolled when
# scrollback is enabled (history > 0).
multiplier: 3
font:
normal:
family: Menlo
style: Regular
bold:
family: Menlo
style: Bold
italic:
family: Menlo
style: Italic
bold_italic:
family: Menlo
style: Bold Italic
size: 16.0
use_thin_strokes: true
# If `true`, bold text is drawn using the bright color variants.
draw_bold_text_with_bright_colors: true
# Base16 Default Dark 256 - alacritty color config
# Chris Kempson (http://chriskempson.com)
colors:
# Default colors
primary:
background: '0x181818'
foreground: '0xd8d8d8'
# Colors the cursor will use if `custom_cursor_colors` is true
cursor:
text: '0x181818'
cursor: '0xd8d8d8'
# Normal colors
normal:
black: '0x181818'
red: '0xab4642'
green: '0xa1b56c'
yellow: '0xf7ca88'
blue: '0x7cafc2'
magenta: '0xba8baf'
cyan: '0x86c1b9'
white: '0xd8d8d8'
# Bright colors
bright:
black: '0x585858'
red: '0xab4642'
green: '0xa1b56c'
yellow: '0xf7ca88'
blue: '0x7cafc2'
magenta: '0xba8baf'
cyan: '0x86c1b9'
white: '0xf8f8f8'
indexed_colors:
- { index: 16, color: '0xdc9656' }
- { index: 17, color: '0xa16946' }
- { index: 18, color: '0x282828' }
- { index: 19, color: '0x383838' }
- { index: 20, color: '0xb8b8b8' }
- { index: 21, color: '0xe8e8e8' }
# Specifying a `duration` of `0` will disable the visual bell.
bell:
animation: EaseOutExpo
duration: 300
color: '0xffffff'
background_opacity: 0.99
selection:
# This string contains all characters that are used as separators for
# "semantic words" in Alacritty.
semantic_escape_chars: ",│`|:\"' ()[]{}<>\t"
# When set to `true`, selected text will be copied to the primary clipboard.
save_to_clipboard: true
# Allow terminal applications to change Alacritty’s window title.
window.dynamic_title: true
cursor:
style: Block
unfocused_hollow: true
# Live config reload (changes require restart)
live_config_reload: true
# Tell Alacritty that we’re using fish here
shell:
program: /usr/local/bin/fish
args:
- --login
# Enable clickable URLs
mouse:
url:
launcher:
program: open
modifiers: Command
# Map the keys (British keyboard layout)
key_bindings:
- { key: Key0, mods: Alt, chars: 'º' }
- { key: Key1, mods: Alt, chars: '¡' }
- { key: Key2, mods: Alt, chars: '€' }
- { key: Key3, mods: Alt, chars: '#' }
- { key: Key4, mods: Alt, chars: '¢' }
- { key: Key5, mods: Alt, chars: '∞' }
- { key: Key6, mods: Alt, chars: '§' }
- { key: Key7, mods: Alt, chars: '¶' }
- { key: Key8, mods: Alt, chars: '•' }
- { key: Key9, mods: Alt, chars: 'ª' }
See all the options in the freshest config file on the releases page in Alacritty GitHub.
Here’s the default ones on Mac:
Key | Command |
---|---|
Cmd+0 | ResetFontSize |
Cmd+Equals | IncreaseFontSize |
Cmd+Plus | IncreaseFontSize |
Cmd+Minus | DecreaseFontSize |
Cmd+K | ClearHistory |
Cmd+V | Paste |
Cmd+C | Copy |
Cmd+C | ClearSelection |
Cmd+H | Hide |
Cmd+M | Minimize |
Cmd+Q | Quit |
Cmd+W | Quit |
Cmd+N | SpawnNewInstance |
Cmd/Ctrl+F | ToggleFullscreen |
Cmd+F | SearchForward |
Cmd+B | SearchBackward |
You can’t pull down "File" and choose "New Window", but there’s a default keybinding to spawn a new instance Cmd+N. That can be remapped to Cmd+Shift+N for example, to be more familiar. Using the pipe |
you can add modifiers:
key_bindings:
- { key: N, mods: Command|Shift, action: SpawnNewInstance }
Alactitty has Vi mode. Meaning: you can navigate the prompt with hjkl like in Vim. You can turn the Vi mode with Ctrl+Shift+Space, and exit the Vi mode with the same shortcut.
To copy text in Vi mode, press v and highlight the text you want, then press y (yank) to copy it to your systems clipboard. You can also use mouse to copy text like a normal person.
It’s a terminal emulator, so you don’t really use it, you use other programs with it. But you can issue the alacritty
command, which will pop out a new window:
$ alacritty
You can also start a new Alacritty session using a different config file:
$ alacritty --config-file ~/.config/alacritty/alacritty-party-mode.yml
Check the help to see all the flags and options:
$ alacritty --help
Since Alacritty is so frugal with features, you really need Tmux (or screen) to go with it.
I have a full post about tmux which has a lot of the good stuff.
But here are the basics to summarized.
Install tmux:
$ brew install tmux
Pop open a tmux session:
$ tmux
Tmux is all about the keyboard shortcuts, everything starts with a Ctrl+b then followed by a key. For example Ctrl+b % splits your pne into two. Ctrl+b c opens a new window (analogous to a tab). Ctrl+b n goes to the next window, Ctrl+b p to the previous. Check out my tmux cheat sheet for a nice index of keybinding.
Alacritty is pretty easy in the sense that you set it and forget it, it doesn’t need much attention. It took me a while to figure out tmux, though. But tmux is a good program to know, you can carry that knowledge over to other environments.
And by the way; even tho I say it’s "nihilist", I really love Alacritty ❤️
Comments would go here, but the commenting system isn’t ready yet, sorry.