5.49 How can I alleviate the limitations of the Linux console?

If possible, we recommend running Emacs inside fbterm, when in a Linux console. This brings the Linux console on par with most terminal emulators under X. To do this, install fbterm, for example with the package manager of your GNU/Linux distribution, and execute the command

$ fbterm

This will create a sample configuration file ~/.fbtermrc in your home directory. Edit that file and change the options font-names and font-size if necessary. For the former, you can choose one or more of the lines in the output of the following command, separated by commas:

$ fc-list :spacing=mono family | sed 's/ /\\ /g'

Note that you can fine-tune the appearance of the fonts by adding attribute-value pairs, separated by colons, after each font name. For example,

font-names=DejaVu\ Sans\ Mono:style=bold:antialias=false

selects the bold style of the DejaVu Sans Mono font, and disables anti-aliasing.

You can now start Emacs inside fbterm with the command

$ fbterm -- env TERM=fbterm emacs

In some versions of fbterm, setting TERM to ‘fbterm’ can be omitted. To check whether it is needed, start Emacs inside fbterm with the command

$ fbterm -- emacs

and type M-x list-colors-display. If only 8 colors are displayed, it is necessary; if 256 colors are displayed, it isn’t.

You may want to add an alias for that command in your shell configuration file. For example, if you use Bash, you can add the following line to your ~/.bashrc file:

alias emacs="fbterm -- env TERM=fbterm emacs"

or, if you use Emacs both in the Linux console and under X:

[[ "$(tty)" =~ "/dev/tty" ]] && alias emacs="fbterm -- env TERM=fbterm emacs"

The fbterm terminal emulator may define a number of key bindings for its own use, some of which conflict with those that Emacs uses. Execute the following two commands as root to ensure that fbterm does not define these key bindings:

# chmod a-s `which fbterm`
# setcap cap_sys_tty_config=-ep `which fbterm`

If you use Emacs as root, the above is not enough however, because the root user has all privileges. You can use the following command to start Emacs inside fbterm as root while ensuring that fbterm does not define any key bindings for its own use:

# capsh --drop=cap_sys_tty_config -- -c "fbterm -- env TERM=fbterm emacs"

Again you may want to add a shortcut for that command in the shell configuration file of the root user. In this case however, it is not possible to use an alias, because the command line arguments passed to Emacs need to be inserted in the string at the end of the command. A wrapper script or a function can be used to do that. For example, if you use Bash, you can add the following function in the root user ~/.bashrc file:

function emacs ()
{
  CMD="fbterm -- env TERM=fbterm emacs "
  for ARG in "$@"
  do
    CMD="$CMD '$ARG' "
  done
  capsh --drop=cap_sys_tty_config -- -c "$CMD"
}