While I recently had my Tmux moment and have used the program ever since to multiplex many shell sessions in a single window, I have noticed a couple of quircks. When using ssh in tmux to connect to remote servers, some programs such as htop and the nano text editor don’t act correctly when scrolling. Text that should not be visible anymore is still there and the cursor jumps to the middle of the screen instead of to the end. Also, the ‘home’ and ‘end’ keys are not properly mapped so it’s not possible to use these keys in nano to jump to the beginning and end of a line. After a bit of searching on the web, I found a number of tips and tricks which, when used in combination, fix all of this.
Fix The Cursor Problem with Aliases
The fix for the cursor jumping to the wrong location and leaving text in places where there should be no text is to modify the terminal type when programs are run that suffer from this. So far, I have found that this is needed for htop and nano. As changing the terminal type before running these programs is a bit cumbersome I found a cool tip to create aliases in ‘.bashrc‘ for these programs:
# For TMUX alias nano='TERM=gnome nano'; export nano alias sudo='TERM=gnome sudo'; export sudo alias htop='TERM=gnome htop'; export htop
As I often use both programs together with ‘sudo’ the same has to be done for this program as well.
And Some Key Bindings
And to get the ‘home’ and ‘end’ keys mapped for the use in nano here are the two keyboard bindings for ‘.tmux.conf‘ in the home directory:
# To make HOME + END keys work in nano bind -n End send-key C-e bind -n Home send-key C-a # Once the key bindings are in the config file # run the following command in tmux after # pressing the command sequence key combination: source-file ~/.tmux.conf
And with that, pretty much everything is back to normal!