8

So, I decided to give Alacritty a try, and in their default configuration there is the following comment:

#env:
  # TERM variable
  #
  # This value is used to set the `$TERM` environment variable for
  # each instance of Alacritty. If it is not present, alacritty will
  # check the local terminfo database and use `alacritty` if it is
  # available, otherwise `xterm-256color` is used.
  #TERM: alacritty

What I don't get it is: why would I want to set TERM to xterm-256color when using alacritty? Isn't xterm the default terminal emulator for Linux? In the old OSX days I remember using iTerm2 but the variable TERM was set to xterm-256color if I'm not mistake - back then I never thought the reason why that was the case.

2
  • 1
    Actually you shouldn't want to use TERM=xterm-256color with alacritty, because alacritty doesn't support the full terminal description, just parts. Jul 9 '20 at 1:17
  • Bringing my comment below up to the top level. Simply put you want TERM=xterm-256color if you are accessing other systems that don't have alacritty terminfo installed (ie. most systems at this point). Setting TERM=alacritty gets you nothing except status-line support which is a legacy setting from terminals that had a separate status line (and tmux and other TUIs with status lines don't use this). Jul 9 at 18:30
3

You wouldn't.

The correct terminal type for Alacritty is, as the comment even says, alacritty.

What the comment is telling you is that, if you don't explicitly specify the terminal type, Alacritty goes and looks to see whether your terminfo database has an alacritty entry, sets the terminal type to alacritty if so, and uses a bad fallback if it doesn't have such an entry.

xterm-anything is the wrong terminal type to set unless your terminal emulator is actually the XTerm program.

The right thing to do is to put an alacritty entry in your terminfo database if it is missing. terminfo both allows entries to be exported from and imported to machines, and allows people to locally add terminal capabilities records in their home directories.

It shouldn't be missing. Dickey terminfo has had an alacritty entry since 2018, and the Alacritty developers themselves have supplied a terminfo entry that one can add to one's database since 2017.

Further reading

6
  • 1
    In practice, many servers may not have the alacritty term info installed. Using export TERM=xterm-256color is likely to fix problems like htop not running due the missing alacritty term info and you are unlikely to notice any problems. I'm unaware of any reference that explains that works with TERM=alacritty vs TERM=xterm-256color. In my experience xterm-256color is sufficiently good. Nov 9 '20 at 14:57
  • As Mark said above, the terminfo check doesn't take into account that you may SSH to a server with different terminfo (eg. Debian minimal install for a server) that doesn't have an alacritty entry. Apr 10 at 8:36
  • as i commented above, note LESS='-j3 -p~/.ssh/environment' man ssh to set an environment specific to machine when using ssh
    – Jack Wasey
    Jun 12 at 9:06
  • This answer doesn't actually answer the question "why?". Comments and other answers express some good reasons why you might set it to xterm-256color, but the answer telling you not to doesn't give any reason why other than it tells you not to. Jul 5 at 1:27
  • I reviewed the differences between alacritty terminfo and xterm-256color and the only real difference is that alacritty's supports a status line. Terminfo docs say ncurses doesn't use these terminfo entries yet and all other mentions are legacy uses. So I'm thinking this answer is just wrong and it is generally better to use xterm-256color until alacritty (and it's terminfo) is more wide spread. Jul 9 at 18:27
2

One reason is to make sure that the output of ls is colorized: dircolors is used to set the LS_COLORS environment variable. dircolors reads TERM to determine whether the terminal supports colors. If you run

dircolors --print-database | grep '^TERM'

you get a list of all color terminals that dircolors knows. alacritty is not on the list. I assume that more programs with such behavior exist or else Alacritty’s default value for TERM could be alacritty-color (since *color* is on dircolors’ list).

Because of a bug in Mono, some games do not launch. The official workaround is to use TERM=xterm.

2
  • Hmm, wouldn't toe -a be a better choice to see what the curses library knows about? 🧐 ... what dircolors -p gives you seems to be more a list of patterns it matches against ... Jul 8 '20 at 21:02
  • dircolors (and GNU ls) ignore the terminal database. According to those programs, vt100's did ANSI color. The mono bug report doesn't actually say what this answer implies. What it actually says is that mono was unable to read the newer terminfo binary format, and as a workaround, suggested using one of the terminal descriptions that didn't use the newer format. It's only been 3 years, without a fix in mono (be patient). Oct 9 at 23:25
1

Voice to the contrary (and why I am contemplating switch myself):

When connecting to a remote system from an Alacritty terminal, for instance over SSH, it can occur that the system does not have an entry for Alacritty in its terminfo database (/usr/share/terminfo/a/alacritty*). Therefore, all interactive terminal functionality does not work. This can be fixed by explicitly exporting the value of the TERM variable set to xterm-256color instead of the default alacritty.

1
  • a solution to this is to set the TERM to xterm-256color in the SSH environment. LESS='-j3 -p~/.ssh/environment' man ssh
    – Jack Wasey
    Jun 12 at 9:04
-1

The current top rated answer states:

The right thing to do is to put an alacritty entry in your terminfo database if it is missing. terminfo both allows entries to be exported from and imported to machines, and allows people to locally add terminal capabilities records in their home directories.

Here is a oneliner that does the export locally and the import remotely via ssh:

infocmp | ssh $user@$host 'tic -x -'

See man infocmp and man tic for more info on the export and import commands respectively.

Bonus Unix/Linux tip (Don't downvote the messenger ;-)

The use of - as a filename is a common (though not universal) convention for telling a command that expects a file argument to instead read from /dev/stdin. Many commands (including tic) support it without stating so in the man page. You can use the explicit device path in most cases.

infocmp | ssh $user@$host 'tic -x /dev/stdin'
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.