Search code examples
remote-accessredhatputtytty

how to refresh entire screen in putty


I have a redhat machine which I use remotely using putty and this is what have been bugging me a lot now...

Each time I open and close a file with any editor, my prompt shows up on the bottom line without the content of the screen being refreshed. This is really problematic because then I can't see previous outputs that were on the screen just before I opened that file which is still showing up after closing.

Is there a way to fix this. I want it to behave like the gnome-terminal. I don't think this use to happen when I was using an ubuntu server.

I understand that this is the traditional tty behavior, but I don't want it...

Thanks in advance.


Solution

  • If your terminal supports an alternate screen buffer, it should have rmcup and smcup define in its terminfo entry

    % infocmp | grep -e rmcup -e smcup
        ri=\EM, rmacs=^O, rmcup=\E[2J\E[?47l\E8, rmir=\E[4l,
        smcup=\E7\E[?47h, smir=\E[4h, smkx=\E[?1h\E=, smso=\E[7m,
    

    If enabling altscreen in your .screenrc doesn't fix it, try adding these 2 lines to your .vimrc:

    set t_ti=^[[?47h
    set t_te=^[[?47l
    

    (note that ^[ is escape, I typed ctrl-v esc)
    Vim will echo ti to the terminal on startup and te on exit, instructing the shell/xterm/screen to switch screen buffers.