0

I'm sshing from my Mac to an Ubuntu machine, but for some reason the key bindings do not work properly. For example when I try to run the tmux shortcut CTRL+b it returns ^B.

The closest questions I could find around is this where different combinations of the stty command has been proposed. I tried them all but none solved the issue. I have checked my .bashrc file but I can't find anything aliasing the CTRL key!

I would appreciate if you could help me know what is the problem and how I can solve it.

P.S.1. I was asked to run the locale and locale -a commands and add the results here:

$ locale
LANG=en_US.UTF-8
LANGUAGE= LC_CTYPE="en_US.utf8" 
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8" 
LC_COLLATE="en_US.utf8" 
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8" 
LC_PAPER="en_US.utf8" 
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8" 
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8" 
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=en_US.utf8

$ locale -a 
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX

P.S.2 I have posted my .bashrc and stty -a here.

wjandrea
  • 14,504
Foad
  • 893

1 Answers1

0

You need to ensure that both the Ubuntu machine and the Mac have the proper locale settings.

For Ubuntu, you can do this by running these commands:

sudo locale-gen en_US.UTF-8
sudo update-locale

After double-checking Ubuntu, let's focus on the Mac. It is most likely that your Mac is causing the issue, though. This will be dependent on the terminal emulator that you're using. If you go into Terminal app settings, be sure you have Set locale environment variables on startup enabled, and set to Unicode (UTF-8).

Once your locales match, both systems should respond similarly to the same key presses.

You can check your current settings by issuing the locale command on each of the machines.

Alternatively, locale can also be adjusted by setting/changing these environmental variables. For example, these can be exported in .bashrc, or some other file, optionally sourced, though some may argue they belong in .profile:

export LANG="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
export LC_NUMERIC="en_US.UTF-8"
export LC_TIME="en_US.UTF-8"
export LC_COLLATE="en_US.UTF-8"
export LC_MONETARY="en_US.UTF-8"
export LC_MESSAGES="en_US.UTF-8"
export LC_PAPER="en_US.UTF-8"
export LC_NAME="en_US.UTF-8"
export LC_ADDRESS="en_US.UTF-8"
export LC_TELEPHONE="en_US.UTF-8"
export LC_MEASUREMENT="en_US.UTF-8"
export LC_IDENTIFICATION="en_US.UTF-8"
export LC_ALL=

While this example is 'typical', it has been suggested to set the LC_ALL variable to en_US.UTF-8, as well, and is reported to work for both Terminal and iTerm2:

export LC_ALL="en_US.UTF-8"
wjandrea
  • 14,504
earthmeLon
  • 11,658