Alacritty

From Gentoo Wiki
Jump to: navigation, search
Resources
Article status
This article has some todo items:
  • Add more info
  • Tips and tricks
This article is a stub. You can help by expanding it.

Alacritty is a terminal emulator focused on simplicity and performance. The performance goal means it should be faster than any other terminal emulators available. The simplicity goal means it does not have features such as tabs or splits (which can be better provided by a window manager)[1].

Alacritty is written in Rust and GPU-accelerated using OpenGL.

USE flags

USE flags for x11-terms/alacritty GPU-accelerated terminal emulator

X Add support for X11
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
wayland Enable dev-libs/wayland backend

Installation

Emerge

Install x11-terms/alacritty package:

root #emerge --ask x11-terms/alacritty

Configuration

Files

Alacritty does not create the configuration file, but it looks for one in the following locations:

  • $XDG_CONFIG_HOME/alacritty/alacritty.yml
  • $XDG_CONFIG_HOME/alacritty.yml
  • $HOME/.config/alacritty/alacritty.yml
  • $HOME/.alacritty.yml
Warning
The configuration file is YAML -formatted. Preserving the indentation is critical.

Alacritty reloads the configuration automatically, which can be disabled via CLI:

user $alacritty --no-live-config-reload

This can also be disabled via the configuration file:

FILE ~/.config/alacritty/alacritty.ymldisable live reload
# Live config reload (changes require restart)
live_config_reload: false

The configuration file should be downloaded and edited from the repository's release page. Explanations are provided in the configuration file.

Important
Make sure, that the adapted configuration file is compatible with the current installation of Alacritty. It might be, that version differences cause compatibility issues.

Font configuration

One can run the following command and copy the desired font name:

user $fc-list -f '%{family}\n' | awk '!x[$0]++'

Changing the default font by editing the config file.

FILE ~/.config/alacritty/alacritty.ymlfont configure
# Font configuration (changes require restart)
font:
  # The normal (roman) font face to use.
  normal:
    family: Hack
    # Style can be specified to pick a specific face.
    style: Regular

  # The bold font face
  bold:
    family: Hack
    # Style can be specified to pick a specific face.
    # style: Bold

  # The italic font face
  italic:
    family: Hack
    # Style can be specified to pick a specific face.
    # style: Italic
  size: 11.0

This will change the font to Hack

Note
This method uses defaults for all other settings.

Colors configuration

FILE ~/.config/alacritty/alacritty.ymlcolor schemes
schemes:
  solarized_light: &light
    primary:
      #...
    normal:
      #...
    bright:
      #...
  solarized_dark: &dark
    primary:
      #...
    normal:
      #...
    bright:
      #...

colors: *light

With this config, Alacritty will use Solarized Light. To switch to the dark version, change colors: *light to colors: *dark.

More schemes can be found from this page: alacritty Wiki of Color schemes.

Transparent background

FILE ~/.config/alacritty/alacritty.ymltransparent background configure
background_opacity: 0.8  # value range is 0 ~ 1

Configuration with tabbed

Since Alacritty does not support tabs intentionally[2], one can use x11-misc/tabbed:

user $tabbed -r 2 alacritty --embed ""

See also:

user $man 1 tabbed
user $man 1 alacritty

Troubleshooting

Using fcitx

This needs app-i18n/fcitx and x11-wm/i3 installed. The initialization file should look like this:

FILE ~/.xprofile or ~/.xinitrc.xinitrc
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
eval "$(dbus-launch --sh-syntax --exit-with-session)"

exec i3

The most important thing is to start i3 last.

Colorless

Alacritty did not set $PS1 or $LS_COLORS, these can be set in the ~/.bashrc or /etc/profile or other rc file.

For example:

FILE ~/.bashrcbash color configure
# prompt
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "

There is a simple way to set colorful file:

FILE ~/.bashrcls color configure
# use alias
alias ls='ls --color=auto'

Window title

The default title is: Alacritty.

Bash

In Bash, one can set the window title by manipulating the environment variable PROMT_COMMAND.

The following will set the window title to: username@hostname:cwd.

FILE ~/.bashrcwindow title bar
# set PROMPT_COMMAND
PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"'

Zsh

In Zsh, one can set the window title by using the functions precmd() and preexec():

The following will set the window title to: username@hostname: zsh[shell_level] cwd_or_current command

For example:

larry@gentoo.local: zsh[4] /etc/conf.d

While executing tail -f /var/log/*:

larry@gentoo.local: zsh[4] tail -f /var/log/*

FILE ~/.zshrcwindow title bar
if [[ "${TERM}" != "" && "${TERM}" == "alacritty" ]]
then
    precmd()
    {
        # output on which level (%L) this shell is running on.
        # append the current directory (%~), substitute home directories with a tilde.
        # "\a" bell (man 1 echo)
        # "print" must be used here; echo cannot handle prompt expansions (%L)
        print -Pn "\e]0;$(id --user --name)@$(hostname): zsh[%L] %~\a"
    }

    preexec()
    {
        # output current executed command with parameters
        echo -en "\e]0;$(id --user --name)@$(hostname): ${1}\a"
    }
fi

See also

  • Terminal emulator — emulates a video terminal within another display architecture (usually X).

External resources

References