3

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.

  • 1
    Actually you shouldn't want to use TERM=xterm-256color with alacritty, because alacritty doesn't support the full terminal description, just parts. – Thomas Dickey Jul 9 '20 at 1:17
1

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

  • 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. – Mark Stosberg Nov 9 '20 at 14:57
1

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.

  • 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 ... – 0xC0000022L Jul 8 '20 at 21:02

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.