I've tried using my Linux .bashrc setup with the FreeBSD terminal. In Linux I use bash with set -o vi and a keybinding for Ctr+H (which invokes an editor on my history file). On FreeBSD in virtual box (not when connected to via ssh), this keybinding gets invoked whenever I press backspace.

It appears on Linux terminals, the backspace key produces ^? (which is different from ^H). On FreeBSD, the key produced by backspace is ^H, which triggers my keybinding. I'm curious if there's a way to make my ^H keybinding work on both terminals (i.e., have the FreeBSD terminal also use ^? for backspace, not ^H) or if I should just use a different shortcut.

I've tried stty -a. It said ... erase = ^?; erase2 = ^H ... so I tried stty erase2 ^?, and while it did change the stty -a output as expected, the behavior of the backspace key didn't change and is still producing ^H.

  • 1
    The terminal emulator can probably configure which key to send for Backspace (e.g., GNOME Terminal: i.sstatic.net/5cxxM.png), so take a look there
    – muru
    Commented Nov 22, 2022 at 10:04
  • There's no way to answer this without clarification of what the question means by "the FreeBSD terminal". A kernel virtual terminal is a different answer to a GUI terminal emulator running on X.
    – JdeBP
    Commented May 27, 2023 at 17:24
  • @JdeBP A kernel virtual terminal. Commented May 27, 2023 at 17:26

1 Answer 1


stty has nothing to do with it. That controls the line discipline. The line discipline reacts to characters as they come down the virtual wire to the kernel virtual terminal. At that point, the input has become characters, as a real terminal would send over a real wire.

What maps keystrokes to characters in a kernel virtual terminal is a keyboard map.

% sed -ne '2,4p;/014/p' /usr/share/vt/keymaps/uk.capsctrl.kbd
#                                                         alt
# scan                       cntrl          alt    alt   cntrl lock
# code  base   shift  cntrl  shift  alt    shift  cntrl  shift state
  014   bs     bs     del    del    bs     bs     del    del     O

14 is the PC/AT key code for the backspace key that is at ISO 9995-1 positions A13 and A14 on PC Model M and Windows keyboards. You can see how it is mapped in this keymap. It should be obvious what to change here. ☺

You load keyboard maps with kbdcontrol using the target kernel virtual terminal device as its standard input. The file format is of course documented as kbdmap(5). It actually comes all of the way from SCO Unix, which you will find documents it better than FreeBSD does.

Further reading

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .