1

I'm running CentOS 6.4 on vagrant and then doing a vagrant SSH into the box. I've been trying to get backspace to work correctly for a while now (as chronicled here: Centos Terminal Configuring Backspace and Ctrl-h Correctly)

As a part of this, I'm trying to use loadkeys to modify the actions in the keymap - but that doesn't seem to work very well. So, as root, I did the following (as specified here):

[root@localhost vagrant]# dumpkeys -f  | grep -iE string
...
string F9 = "\033[20~"
string F10 = "\033[21~"
...

[root@localhost vagrant]# echo 'string F10 = "foo" ' | loadkeys   # to make F10 print "foo"

[root@localhost vagrant]# dumpkeys -f  | grep -iE string   # verify that keymap is changed
...
string F9 = "\033[20~"
string F10 = "foo"
...

Now type F10. This keeps giving me the ~ character instead of printing foo. This is the original behavior before loadkeys were invoked - so it looks like loadkeys has no effect at all?

Rohith
  • 123

1 Answers1

3

loadkeys re-programs the terminal emulator that is built in to the kernel, via ioctl() requests through a kernel virtual terminal device. You aren't using that terminal emulator when you connect to the machine via ssh. Indeed, you aren't involving any terminal emulator, kernel or user space, on that machine at all.

The terminal emulator on your local machine is what is mapping function key presses into control sequences. Of course loadkeys isn't reprogramming the terminal emulator that is running on a completely different machine at the local end of your ssh connection.

If you hadn't run loadkeys as the superuser, you'd have received the useful error message that when run from the ssh login session loadkeys couldn't find a kernel virtual terminal to talk to, because one wasn't involved in that login session.

JdeBP
  • 68,745
  • If you are like me and were trying to do something like have F12 type "hello " and you're using tmux, you can use bind-key -Troot F12 send-keys 'hello '. But note this will only work from inside tmux. I'm sure other terminal emulators have similar functionality. – mondaugen Apr 22 '20 at 17:10