In this article, we will take a look at one of the popular terminal emulators named Alacritty and how to install Alacritty in various Linux distributions, and finally how to configure Alacritty terminal emulator to get the most of it.
Table of Contents
What is Alacritty?
Alacritty is a cross-platform, GPU-accelerated terminal emulator. It is an OpenGL terminal emulator written in Rust Programming language. Thanks to the OpenGL renderer and the high throughput parser, Alacritty is incredibly fast and extremely lightweight Terminal emulator in existence.
Since it has been developed to focus only on simplicity and performance in mind, Alacritty Terminal emulator doesn't include many fancy features like tabs and spilts that you use in other Terminal emulators, for example Terminology.
Alacritty supports major operating systems, including Linux, BSD, Mac OS, and Windows.
Alacritty Features
Some of the core features of alacritty are as follows.
- Yaml-based configuration.
- Multi Window.
- Opening the URL into the browser directly from the terminal.
- Vi mode.
- Search Mode - Normal and VI search.
- Customizable color schemes.
- Customizable keybindings.
- Hints & Selection Expansion.
Install Alacritty in Linux
As stated already, Alacritty can also be installed on macOS and Windows but our focus is only on linux for this article.
Before installing Alacritty in Linux, you need to set up Rust programming language to build and install alacritty. Refer the following guide to know how to install Rust in Linux.
Next install the necessary development tools in your Linux box.
Alpine Linux:
$ sudo apk add cmake pkgconf freetype-dev fontconfig-dev python3 libxcb-dev
Arch Linux, EndeavourOS, and Manjaro Linux:
$ sudo pacman -S cmake freetype2 fontconfig pkg-config make libxcb libxkbcommon python
Debian, Ubuntu and derivatives:
$ sudo apt install cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev python3
Fedora:
$ sudo dnf install cmake freetype-devel fontconfig-devel libxcb-devel libxkbcommon-devel g++
RHEL 8:
$ sudo dnf install cmake freetype-devel fontconfig-devel libxcb-devel libxkbcommon-devel
$ sudo dnf group install "Development Tools"
OpenSUSE:
$ sudo zypper install cmake freetype-devel fontconfig-devel libxcb-devel libxkbcommon-devel
FreeBSD:
$ pkg install cmake freetype2 fontconfig pkgconf python3
OpenBSD:
$ pkg_add rust python
Always keep an eye on the official installation instructions as it may change in future.
After installing Rust and other required dependencies, git clone the alacritty project repository.
$ git clone https://github.com/alacritty/alacritty.git
$ cd alacritty
Next, run the following command to start the build. This command should be submitted under the cloned alacritty directory.
$ cargo build --release
Once the build is completed the binary will be generated under alacritty/target/release/alacritty
.
A few additional steps are needed to set up the Term info, Desktop entry, and man page.
Heads Up: The following commands should be submitted from the cloned alacritty directory.
Run the following command to set up the term info.
$ sudo tic -xe alacritty,alacritty-direct extra/alacritty.info
Run the following command to set up the desktop entry.
$ sudo cp target/release/alacritty /usr/local/bin # or anywhere else in $PATH
$ sudo cp extra/logo/alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
$ sudo desktop-file-install extra/linux/Alacritty.desktop
$ sudo update-desktop-database
Run the following command to set up the man page.
$ sudo mkdir -p /usr/local/share/man/man1
$ gzip -c extra/alacritty.man | sudo tee /usr/local/share/man/man1/alacritty.1.gz > /dev/null
$ gzip -c extra/alacritty-msg.man | sudo tee /usr/local/share/man/man1/alacritty-msg.1.gz > /dev/null
If all the above instructions went successfully, you should see the alacritty icon in your system menu.
Alacritty Configuration File Path
Alacritty by default will not create a configuration file. You have to create a configuration file named "alacritty.yml
" in any of the following locations.
$XDG_CONFIG_HOME/alacritty/alacritty.yml
$XDG_CONFIG_HOME/alacritty.yml
$HOME/.config/alacritty/alacritty.yml
$HOME/.alacritty.yml
You can download the default configuration file from the project repository. This file has all the supported parameters and all are commented out by default. You can use this file as a reference to create your configuration file.
Create Configuration From Scratch
In the upcoming sections, I am going to show you the most important parameters which will help you set up the terminal very quickly. Furthermore, you can explore the advanced features and add them to the config file if required.
Heads Up: The configuration file is in yaml
format. Lookout for proper indentation.
Live Configuration Reload
By default, alacritty supports live configuration changes. If you wish to disable it add the following property to the configuration file.
live_config_reload: false
Window Configurations
1. Window Title
At the top of the terminal, you will see the title of the terminal which is set to "Alacritty" by default.
You can set your own title by adding the following property to the config file. Here I am setting the title as "Term-Alacritty".
window: title: Term-Alacritty
You can also enable or disable the dynamic title.
window: # title: Term-Alacritty dynamic_title: true
2. Startup Mode
You can decide on which mode the terminal window should start with.
- Fullscreen: Terminal will take the full screen without the title bar.
- Maximized: This is like pressing the maximize button in the title bar.
- Windowed: It uses the dimensions to position the terminal window.
startup_mode: Windowed # Supported => Windowed, Maximized, Fullscreen
3. Window Dimension & Window Position
You can set the window dimension and position using the following properties. The dimension represents the lines/columns in the terminal and the position represents the pixels.
dimensions: columns: 151 lines: 39 position: x: 300 y: 150
4. Opacity
The opacity property decides the background transparency of your terminal. The value can be set from 0.0
which is fully transparent to 1.0
which is opaque.
opacity: 0.5 # Supported => 0.0(fully transparent) -> 1.0(opaque)
Cursor Settings
You can set the shape and blink for the cursor by adding the following yaml
configuration. You can set the different shapes for default alacritty and vi modes. This helps in identifying the current mode easily.
cursor: style: shape: underline # Supported => ▇ Block, _ Underline, | Beam blinking: off # Supported => Never, off, on, Always vi_mode_style: Beam
Alacritty cursor - Normal mode:
Alacritty cursor - Vi mode:
Copy On Select
If you are familiar with Putty, you probably will know this. Selecting any line in the putty will get copied to the clipboard. Most linux terminals do not implement this natively. You can enable this feature in alacritty by adding the following yaml
configuration.
selection: save_to_clipboard: true
Scrollback Buffer
The Scrollback buffer allows you to scroll your terminal till the given lines. Let’s say you have given the scrollback buffer as 1000, then you can scroll back to the previous 1000 lines in your terminal.
scrolling: history: 2000
To disable scrolling, set the value to '0'.
Startup Directory
By default when you start the terminal it will use the user's home directory as the startup directory unless you open the terminal explicitly from within any directory. You can set the custom startup directory by setting the following parameter.
working_directory: "/home/ostechnix/Desktop/"
Default Shell
By default, the terminal uses the default shell setup in the user profile. You can override this by adding the following parameters. Here my default shell is /bin/bash
, but I am using /bin/fish
as my default shell and passed --private
to start the shell with private mode.
shell: program: /bin/fish args: - --private
To know about fish private mode, please refer the guide below.
Font Settings
You can set the font and font size by adding the following properties in the configuration file. You can add font and its style for normal, bold, italic, and bold_italic font types.
You can run the fc-list
command to check the list of installed fonts. I am using "Ubuntu Mono" font.
$ fc-list | grep -i "fira code" fc-list | grep -i "ubuntu mono" /usr/share/fonts/truetype/ubuntu/UbuntuMono-RI.ttf: Ubuntu Mono:style=Italic /usr/share/fonts/truetype/ubuntu/UbuntuMono-B.ttf: Ubuntu Mono:style=Bold /usr/share/fonts/truetype/ubuntu/UbuntuMono-BI.ttf: Ubuntu Mono:style=Bold Italic /usr/share/fonts/truetype/ubuntu/UbuntuMono-R.ttf: Ubuntu Mono:style=Regular
font: size: 13 offset: x: 0 y: 1 normal: family: Ubuntu Mono style: Regular bold: family: Ubuntu Mono style: Bold italic: family: Ubuntu Mono style: Regular Italic bold_italic: family: Ubuntu Mono style: Bold Italic
Color Schemes
You can set multiple color schemes under the "schemes" section and set anyone as the default color in the "colors" properties.
schemes: darcula: &darcula primary: background: '0x282a36' foreground: '0xf8f8f2' normal: black: '0x000000' red: '0xff5555' green: '0x50fa7b' yellow: '0xf1fa8c' blue: '0xcaa9fa' magenta: '0xff79c6' cyan: '0x8be9fd' white: '0xbfbfbf' bright: black: '0x282a35' red: '0xff6e67' green: '0x5af78e' yellow: '0xf4f99d' blue: '0xcaa9fa' magenta: '0xff92d0' cyan: '0x9aedfe' white: '0xe6e6e6' atom_one_light: &atom_one_light primary: background: '0xf8f8f8' foreground: '0x2a2b33' normal: black: '0x000000' red: '0xde3d35' green: '0x3e953a' yellow: '0xd2b67b' blue: '0x2f5af3' magenta: '0xa00095' cyan: '0x3e953a' white: '0xbbbbbb' bright: black: '0x000000' red: '0xde3d35' green: '0x3e953a' yellow: '0xd2b67b' blue: '0x2f5af3' magenta: '0xa00095' cyan: '0x3e953a' white: '0xffffff' colors: *atom_one_light
Here, I am setting "atom_one_light" as the color scheme.
The above-mentioned step is a manual approach. Alternatively, you can clone all the themes from github and import the desired theme into the alacritty.yml
file using the import statement.
Run the following commands to clone the themes.
mkdir -p ~/.config/alacritty/themes
git clone https://github.com/alacritty/alacritty-theme ~/.config/alacritty/themes
Add the import statement into the alacritty.yml
file. All you have to do is replace the {theme}
in the syntax with the theme file name.
# syntax import: - ~/.config/alacritty/themes/themes/{theme}.yaml import: - ~/.config/alacritty/themes/themes/argonaut.yaml
Here I am using the argonaut theme.
Alacritty Keybindings
As foretold, Alacritty supports normal mode, vi mode, and search mode. Each mode comes with predefined key bindings. You can get the key bindings from the alacritty.yml
reference file downloaded from github.
For example, if you wish to go to vi mode then you can use "SHIFT + CTRL + SPACE
".
Setting custom keybindings is pretty simple. Grab any action from the reference file and add it to the alacritty.yml
by just changing the key and mods. Here, I have changed the ToggleViMode
keystroke to "CTRL + SPACE
" instead of "CTRL + SHIFT + SPACE
".
key_bindings: - { key: Space,mods: Control,mode: ~Search,action: ToggleViMode }
Conclusion
Alacritty is very popular in terminal space and easy to set up. Deep dive by spending a few hours in the terminal and you will love all the features it offers. Alacritty is actively maintained. If you think of any new features to be added, you can raise an enhancement request in the github.
Resources: