1

Problem

When I'm in bash in tmux, I can't use the left arrow key (on my keyboard) to move the cursor left over text I've typed. No other characters show up, the cursor does not move, nothing happens.

Details

If I enter vim, the left arrow works for navigation. So it does not appear to be a general problem within tmux, but only something that shows up on the bash command line. The up and down arrows work in bash in tmux. The left arrow also works normally in bash outside of tmux. When I'm in bash in tmux, hitting Shift Left moves the cursor left instead.

Basic Setup

From PuTTY in Windows I'm ssh'ing to a Fedora 24 box. Then I launch tmux.


Environment

Putty configuration

Terminal -> Keyboard -> keypad: ESC[n~
Terminal -> Features -> nothing checked
Connection -> Data -> term type string: putty-256color

Shell

Outside tmux:

$ echo $0
-bash
$ help
GNU bash, version 4.3.42(1)-release (x86_64-redhat-linux-gnu)

Inside tmux:

$ echo $0
-bash
$ help
GNU bash, version 4.3.42(1)-release (x86_64-redhat-linux-gnu)

Bash Variables

Outside of tmux:

$ echo $TERM
putty-256color

Inside tmux:

$ echo $TERM
screen-256color

I've also tried setting other values for $TERM inside tmux, such as screen.putty-256color which I found with ls -1 /usr/share/terminfo/s/screen* -- didn't seem to make a difference.

Dump of bash option settings, which are the same inside or outside of tmux:

$ shopt -o
allexport       off
braceexpand     on
emacs           on
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       on
interactive-comments    on
keyword         off
monitor         on
noclobber       off
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              off
xtrace          off

I don't have a personal .inputrc, but I see that emacs is on above, and /etc/inputrc has this section:

$if mode=emacs

# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# commented out keymappings for pgup/pgdown to reach begin/end of history
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word

# for rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word

# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line

# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif

Notes

I think this was working a week ago. Differences since then I've thought of:

  • I had a different PuTTY config (I can try to recover that, it's not easily accessible right now)
  • I installed Solarized colors for vim and tried their PuTTY colors too. I took another look at $TERM choices when I did that, but I don't think I made any significant changes that I haven't already undone.
  • kernel-headers were updated, glibc was updated.

Troubleshooting

Installing zsh and setting set-option -g default-shell /bin/zsh in ~/.tmux.conf did not resolve the issue.

su'ing to root and starting tmux from root did not resolve the issue.

3

I resolved the problem this morning, so I'm posting this answer with my fix:

Fix

Change PuTTY configuration Connection -> Data -> Terminal-type string to xterm-256color.


Explanation

Well, here's the difference between the terminfo values for kLFT, which man terminfo says is the shifted left-arrow key:

$ infocmp xterm-256color putty-256color | grep '\\E\[D'
kLFT: '\E[1;2D', '\E[D'

I think Bash understands \E[D as the command to move the cursor left one, so it makes sense that shift-left-arrow worked for moving the cursor left. But there's no other entry for \E[D, and

$ infocmp xterm-256color | grep '\\E\[D'

finds nothing, so it doesn't appear that xterm-256color has bound anything else to that, and kLFT is the only match in putty-256color. man terminfo says

The codes sent by the left arrow, right arrow, up arrow, down arrow, and home keys can be given as kcub1, kcuf1, kcuu1, kcud1, and khome respectively.

And elsewhere lists kcub1 as the left-arrow key, so I should look for kcub1:

$ infocmp xterm-256color | grep kcub1
kbs=\177, kcbt=\E[Z, kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC,

$ infocmp putty-256color | grep kcub1
kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA,

But it's set to the same value, \EOD, in both.

In screen-256color, the value for kcub1 is the same, and kLFT is not set.

Beyond that, I don't have a lot of explanation -- if this all adds up and makes sense to you please post an answer.

Note: I thought this was working a week ago with putty-256color, but I recall changing some $TERM choices when I installed Solarized, so I'm guessing I changed it to putty-256color at that time and forgot about it.

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.