Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Vim-like movement #98

Closed
Vndtta opened this issue May 23, 2014 · 21 comments
Closed

Vim-like movement #98

Vndtta opened this issue May 23, 2014 · 21 comments

Comments

@Vndtta
Copy link

Vndtta commented May 23, 2014

Hi, I've searched in the archive of the mailing list and didn't find anything... Sorry if it's been asked before (I guess it must have)

Is there anyway of setting the movement commands like vim? hjkl?

Thank you

@hishamhm
Copy link
Owner

Hi! There's no way for enabling vim-like movement in the current release. The keybindings clash with existing commands, so I'm wary of adding that. But thanks for the suggestion, I'll keep it filed in the "wishlist" label.

@ghost
Copy link

ghost commented May 24, 2014

Here is a patch which offers very basic vi like keybindings https://pastee.org/bny2j
The key bindings which clash with existing ones seem to have also been rebound in the patch, and from a very quick test on htop 1.0.3 from git it seems to work fine.

@darvelo
Copy link

darvelo commented May 28, 2014

👍

@Vndtta
Copy link
Author

Vndtta commented May 28, 2014

You are awesome, thanks!

On May 24, 2014 3:38:48 AM CEST, Michael notifications@github.com wrote:

Here is a patch which offers very basic vi like keybindings
https://pastee.org/bny2j
The key bindings which clash with existing ones seem to have also been
rebound in the patch, and from a very quick test on htop 1.0.3 from git
it seems to work fine.


Reply to this email directly or view it on GitHub:
#98 (comment)

-- Calm Down and Keep Seeding --

@e9t
Copy link

e9t commented Sep 16, 2015

One vote up +1 for this wish!

@zkanda
Copy link

zkanda commented May 18, 2016

Hello, was this ever implemented?

Thanks

@hishamhm
Copy link
Owner

it was added as Alt+{h,j,k,l}.

@zkanda
Copy link

zkanda commented May 20, 2016

Hmm, weird, my version of htop is 2.0.1, but it doesn't seem to work.

@kaefer
Copy link
Contributor

kaefer commented May 20, 2016

It works (here on my machine with german keyboard layout) with pressing the left-alt button (alt and not alt-gr)

@hishamhm
Copy link
Owner

@zkanda it might be a limitation of your terminal. Open a shell, type read and press Enter. It will give you a prompt that will echo the ANSI codes for your keypresses. Type hjkl with and without Alt. It should produce different results. If the results are the same, htop has no way to detect that Alt was pressed. In my system it shows:

hisham@pointer ~]read
hjkl^[h^[j^[k^[l

@zkanda
Copy link

zkanda commented May 23, 2016

My terminal seems to be working as expected. Using gnome-terminal.

Can you please confirm this behavior?
https://asciinema.org/a/6kvkdo6szprhqcrpi7z1ctn2e

@hishamhm
Copy link
Owner

@zkanda That's odd! Keys from read are working as expected. Could you try it on another terminal you might have installed (xterm)? It might be an ncurses configuration issue? I'm at a loss here.

@darvelo
Copy link

darvelo commented May 26, 2016

Would it be possible to set this as a config variable at compile-time or preferably in an rc file or on the command line? I use Alt+{h,j,k,l} for moving through windows in my tiled window manager so the plain keys (non-Alt) in the patch above work best for me.

@zkanda
Copy link

zkanda commented May 27, 2016

Okay, I tried it on xterm without any configuration and it seems to worsen the situation. read is printing weird non ascii characters.
Here's the result: https://asciinema.org/a/2mmhmyenvhg97awgcxtn3hkjf

I'm on ArchLinux with Gnome as my DE if that matters.

@mudox
Copy link

mudox commented Jun 19, 2016

I use htop on OS X 10.11.5, I tested under following combinations:
- Terminal.app + [zsh / bash] + htop
- iTerm.app + [zsh / bash] + htop
- iTerm.app + tmux + [zsh / bash] + htop
All with no luck.
The read on iTerm.app behaves as expected: ^[j^[k
The read on Terminal.app spits out weird symbols: ∆˚

@sassanh
Copy link

sassanh commented Oct 29, 2017

Doesn't work in my mac with Iterm nor Terminal too. I was thinking about an alternative key binding user can switch to in settings. This way nothing will break for other users but users who prefer to use vim key bindings can use it by activating it in settings.

@ryenus
Copy link
Contributor

ryenus commented Oct 29, 2017

@sassanh, for Alt+{h,j,k,l} to work as expected in macOS, the Option key needs to be configured as +Esc (iTerm2) or Meta Terminal, in Preferences > Profile > Keyboard.

@sassanh
Copy link

sassanh commented Oct 29, 2017

Still doesn't work not in iTerm nor Terminal. I tried all 3 choices for Option key in iTerm and the 2 in Terminal. Also htop is not the only application I run in terminal. Changing option key will ruin my key bindings for vim, fish, etc.

@sassanh
Copy link

sassanh commented Oct 29, 2017

I ended up using https://github.com/KoffeinFlummi/htop-vim.

@bbugyi200
Copy link

bbugyi200 commented Apr 29, 2019

Here's a more up-to-date patch (it works with v2.2.0) that implements this if anyone is interested: https://gist.github.com/bbugyi200/c066a5b56819c629f41f8805804e5204

@vegerot
Copy link

vegerot commented Jan 17, 2020

The patch is very readable, but for the lazy you may be wondering how to access the old htop functionality previously mapped to "hkl".

The answer is:

k→x (kill)
l→L (lsof)
h→? (help)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests