Using the alacritty terminal

The alacritty terminal's main page says that it allows for extensive configuration. This is true, but how to do said configuration is sometimes difficult to find.

There was a discussion when someone suggested a sample config file would be a good thing while others seemed to disagree with the idea. One developer mentioned that it's all in the man page. (This would be man 5, which describes the alacritty.toml file. Man 1 consists of various options to the alacritty command. If you just type man alacritty, it will default to man 1, so if trying to figure a toml file, be sure to type man 5 alacritty.) There is a detailed configuration file on github.

If one looks at it, they will see that it is taken from man(5) alacritty. Whether one looks at it, or man(5) alacritty, these are existing defaults. If you don't create your own custom toml file, it will have the man page's settings.

The alacritty terminal can be used with its defaults and it may be quite sufficient for your needs. However, to customize it, one can create a $HOME/.config/alacritty/alacritty.toml file. Note that it's toml, not yaml. So, when doing a web search on customizing, make sure you don't use an an older example with a yaml file. (yaml was used before it was switched to toml)

[window]
decorations = "Full"

[font]
size = 12.0
[font.normal]
family = "Liberation Mono"
style = "Regular"

[colors.primary]
background = "#171421"
foreground = "#FFBF00"

The file above is a simple configuation, setting terminal windows to a title bar and using Liberation Mono size 12 fonts. I use this with dwm or dwl, tiling window managers that automatically adjust the size of new windows. If using it with labwc or openbox, I would have
[window]
decorations = "Full"

[window.dimensions]
columns = 80
lines = 24

[font]
size = 12.0
[font.normal]
family = "Liberation Mono"
style = "Regular"

[colors.primary]
background = "#171421"
foreground = "#FFBF00"

which creates an 80x24 terminal.

In dwm and dwl the title bars don't show. In openbox and labwc, they do but can be removed with a keyboard shortcut to ToggleDecorations. The default columns and rows are 0 and 0, which, in a stacking window manager like openbox, created, for me, something about 80 columns wide and maybe 50 rows high.

If using alacritty with dwm or dwl (the Wayland version of dwm) for me, at least on Fedora and FreeBSD, ignores the columns and lines and just tiles the window, using available space. I mark decorations as Full, it is the default, and still opens without decorations, in dwm and dwl, but the openbox rc.xml's ToggleDecoration keyboard shortcut works. In labwc, if decorations are marked as None, the ToggleDecorations key shortcut will give it a title bar, but it will open with no decorations. In openbox, if decorations are set to none, it opens without decorations, and the ToggleDecorations shortcut won't work. . As I often enlarge the window to full screen, I haven't looked into this too deeply. But if decorations are set to None the ToggleDecor won't put a title bar on the window, in openbox. Most people may not even need a line for it, as the default will be Full, but as just mentioned, it will still open without decorations in some window managers. If you're only using labwc, and basically don't want decorations, you can set it to none, and if you do, for some reason want a title bar, the ToggleDecorations keyboard shortcut will work.

The alacritty(5) man page gives the existing defaults. So, in the preceding example, if I left out the decorations line, it would still work as if I'd put in the section for decorations. The nice thing about alacritty is that it works equally well in X and Wayland. Usually, urxvt will work in Wayland as well as it does in X, but from time to time, I find that a system with Wayland will have trouble with urxvt though this is rare. But since urxvt-9.31, it's had some issues. See a mention on urxvt's mailing list. Though reported in January, 2023, nothing's been done.

(The issues are mentioned on the ArchWiki's urvxt page, along with solutions. Look for the section marked "Wrong shell prompt placement after upgrading to 9.31". Basically, one can add entries to .Xdefaults or .Xresources, or apply the lines-rewrap.patch, which also works in FreeBSD.)

Everyone has their favorite terminal and for varying reasons. For me, what I like about urxvt is that one can change background and foreground colors on the fly with urxvt -bg something -fg something, and that if one uses the perl extension scripts, (urxvt-perls in FreeBSD) one can easily open a URL from a urxvt terminal.

Though not quite as simple in alacritty, one can do both these things.

There are a variety of themes one can use for colors. See the page for alacritty themes to get a variety of schemes for one idea. As for me, I only need a couple of different themes. So, I have my default with a blackish background and amber foreground, then I also have one with a gray background and black foreground which I use when ssh-ing into some systems where my usual black background makes it somewhat hard to see directories which RedHat gives a default dark blue color. I change the background and foreground colors and keep a second file in my $HOME/.config/alacritty, called, for example, alacgray.toml. Now I can start alacritty with
alacritty --config-file ~/.config/alacritty/alacgray.toml

This can become annoying to type a lot, so I usually just make a small script.
#!/bin/sh
alacritty --config-file ~/.config/alacritty/alacgray.toml

and then I can call it with alacgray.sh. (Or, if you prefer, just make an alias, something like
alias alacgray='alacritty --config-file ~/.config/alacritty/alacgray.toml'

Either method works, and is fine if you only have one or two color schemes that you use. Incidentally, the colors must be in hex or rgb format. If you try foreground = white, background = black, alacritty will complain about unknown values. I prefer making a script because then, if in dwm, I use dmenu to run the command, the script will open an alacritty terminal in my desired colors. Using the alias from dmenu doesn't seem to work.

A really basic alacritty.toml as described above will allow you to open urls with either mouse or keyboard. With the mouse, if you just hover over a url it will show as underlined, and open with a click. To open it by keyboard, first hit ctl+shift+space which puts alacritty into vi mode. Then, when your cursor gets to the url, said url will show as underlined and hitting enter will open the web page in your default browser. If you look at the detailed default toml file linked above, you'll see more sophisticated configuration examples, using regexes, etc., but it's not necessary. It may be handier, however, The defautl also underlines and will open urls with ctl+shift+U. Again, this is a default, you don't need to add anything to your toml file.

That is, even if you don't create an alacritty.toml file, it will, by default, underline or open a url with ctl+shift U.

For me, with urxvt, I got used to using alt+u to open a url from the terminal. I don't remember how I decided or got used to that key combination, I probably followed an article somewhere. One has to have perl extensions for urxvt installed to do that with urvt.

Although I could open links as mentioned above by going into vi mode, I took a sample from the man page, also found in that sample config mentioned above. I've modified it slightly. Mine reads
[[hints.enabled]]
command = "xdg-open" # On Linux/BSD
hyperlinks = true
post_processing = true
persist = false
mouse.enabled = false 
binding = { key = "u", mods = "Alt" }
regex = "(ipfs:|ipns:|magnet:|mailto:|gemini://|gopher://|https://|http://|news:|file:|git://|ssh:|ftp://)[^\u0000-\u001F\u007F-\u009F<>\"\\s{-}\\^⟨⟩`]+"

The man page's version has mouse.enabled = true and the binding key a capital U, rather than my lower case one. It has the mods = Control|Shift. Either version will work. It has a nice way of choosing which url link. If say, there are 3 links in the file, one will show as fttps://, one as jttps and one perhaps as kttps. The first letter, the f, j, or k chooses which link to open. For example, if the one you want is fttps:// then hit f.

As mentioned there is more than one man page. Aside from man(1) alacritty, there is also man(5) alacritty, and man(5) alacritty-bindings. The man(5) alacritty covers the setup of a toml file and the the alacritty-bindings one covers some key and mouse bindings.

Lastly, we had a little thread about configuring alacritty on FreeBSD forums. There is some useful information from users NapoleanWils0n and T-Daemon (who explained default opening URLs with it.