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.85k stars 579 forks source link

Add simple vim mode #959

Open lytedev opened 5 years ago

lytedev commented 5 years ago

This PR adds a "vim_mode" setting (false/0 by default) that causes keys to be remapped in the following way by the ScreenManager:

+ h -> LEFT
+ j -> DOWN
+ k -> UP
+ l -> RIGHT
+ LEFT  -> h (toggle help)
+ DOWN  -> j (noop)
+ UP    -> k (open kill menu)
+ RIGHT -> l (lsof current process)
+ K (Shift+K) -> k (open kill menu)
+ J (Shift+J) -> K (toggle show/hide kernel threads)
+ L (Shift+L) -> l (lsof current process)

I couldn't figure out where the manpage documentation is in the repo, though I admittedly did not look particularly hard.

I believe this change would be a welcome option for heavy vim users like myself who would like a familiar way to get around in htop.

AtomToast commented 4 years ago

I would like to have an option for vim bindings in normal htop though I prefer the shortcuts implemented by this fork: https://aur.archlinux.org/packages/htop-vim-git
Source code is here https://github.com/KoffeinFlummi/htop-vim

lytedev commented 4 years ago

I'll have to check that out! My implementation has issues with the may I remap the keys so that typing k when searching puts the character K into the input string, so this implementation is not particularly good at all. :laughing:

andys8 commented 4 years ago

See https://github.com/hishamhm/htop/issues/98

Would be nice to have a well maintained and packaged fork with vim bindings.

nycex commented 4 years ago

I like this patch overall, though I would leave the keys to what they do at the moment and do something like:

? -> h
q -> k
L -> l

instead, remapping the arrow keys like that wouldn't be very intuitive in my opinion.

andys8 commented 4 years ago

Btw there are other system monitors with vim bindings. I'm currently using bottom because it's configurable. There is also ytop and more. Depends on what you need.

https://github.com/ClementTsang/bottom https://github.com/cjbassi/ytop

vcfvct commented 4 years ago

Btw there are other system monitors with vim bindings. I'm currently using bottom because it's configurable. There is also ytop and more. Depends on what you need.

https://github.com/ClementTsang/bottom https://github.com/cjbassi/ytop

Thanks for the suggestions. Can finally switch to a modern one with more natural key-bindings. Bottom looks great.

natoscott commented 4 years ago

Merged here: htop-dev/htop@5c5a599