hishamhm / htop

htop is an interactive text-mode process viewer for Unix systems. It aims to be a better 'top'.
GNU General Public License v2.0
5.84k stars 581 forks source link

Alt-[hjkl] doesn't work when $TERM is not xterm #942

Open lacygoill opened 5 years ago

lacygoill commented 5 years ago

According to $ man htop, M-j and M-k can be pressed to scroll in the list of processes. On my machine, it works only when $TERM has the value xterm or xterm-256color.

In tmux, $TERM must have the value screen, screen-256color, tmux or tmux-256color. Because of this, M-j and M-k don't work in htop inside tmux.

I can reproduce on the latest commit of the htop github repository.


I don't think this is is a bug in tmux, because:

I don't think the issue is in my tmux-256color terminal description, because:

I don't think the issue is in my shell, because:


As a workaround, I use this shell alias:

alias top='TERM=xterm-256color htop'

Here's a gif to illustrate the issue:

gif


Environment:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.6 LTS
Release:        16.04
Codename:       xenial

$ zsh --version
zsh 5.7.1 (x86_64-pc-linux-gnu)

$ xterm -version
XTerm(322)
lacygoill commented 5 years ago

I'm not sure this is a bug, because maybe the keys are not meant to be used there, but I've also noticed that M-[hjkl] don't work in some menus. For example, in the menu opened when you press l to get the list of files opened by the process under the cursor.

OTOH, C-[np] seem to work in all menus, and with any TERM value. I don't think they are documented – at least I couldn't find them here – but they are very handy, so I use them instead of M-[jk].