Toggling alternate screen #933
I've recently discovered Kitty and I really like it and I'm considering switching to it from URxvt. There's one feature, though, that I use quite often and it seems missing from Kitty. It's toggling alternate screen. E.g. when you are inside vim editor and want to temporarily look 'behind' it for the previous screen output, or the other way round, when you want to see screen output from a closed vim window.
Is there a way to map a shortcut to switch to alternate screen?
It's possible to do in URrxvt with:
or for XTerm using:
I've tried a few different combinations for Kitty, but I couldn't find anything that would work. I was expecting this to work:
The text was updated successfully, but these errors were encountered:
If you want to look behind vim, simply use ctrl-z it works in all terminals and doesn't require any special setup. And it does not have the potential to break your screen if vim decides to write something to the terminal while you are peeking behind it.
Similarly if you want to switch to the alternate screen from the main screen use
Note however that if you entered the main screen by using ctrl-z use fg to get back to vim instead.
Thanks for the replies, I'm well aware of the
Additionally, I prefer to toggle alternate screen using terminal shortcuts as it's quicker than typing '^Z' and then 'fg' and also works on remote SSH connections without setting up shell in advance.
@kovidgoyal Will sending of control sequences to kitty work using a remote control protocol (by setting up allow_remote_control in the config) ?
So map alt+shift+x to send_text all 'tput rmcup\r' and similar, then you dont need to type anything. Toggling screens without the program you are running being aware of it is a really bad practice, it can lead to screen corruption. No terminal program expects the screen it is writing to to change at arbitrary points during its execution.
And no remote control will not help, it has no mechanism to write control codes from arbitrary child program to kitty.
I know what you mean. However, my shell really doesn't mind me changing to alternate screen at all. For programs like 'vim' or 'less', even if you mess up the screen, just hitting CTRL-L will refresh the screen back to normal.
On the other hand, XTerm finds the feature quite important and consider the lack of it in other terminals a bug.
From XTerm documentation: http://invisible-island.net/xterm/xterm.faq.html#xterm_tite
Sure but then that means that every program has to implement some manual redraw function to deal with the possibility that the screen could be arbitrarily corrupted at any time. This is a really bad idea, regardless of what the XTerm maintainer thinks. On what planet is deliberately causing undefined behavior ever a good idea?
And what's your actual use case anyway? You want to copy stuff from whichever screen is hidden? A much better implementation would be to have a function like the existing one for viewing the scrollback buffer in a separate window or an overlay, except that you do it with the contents of the alternate screen instead.
Just for completeness, here is how you would do it:
This will show you the contents of the hidden screen in an overlay window over the current window within less. Press q to close the overlay window when you are done doing whatever you need to do.
And this technique has no risk of screen corruption.
Just curious, is it possible to make a shortcut that will open new OS window (not overlay) with this content? This would be quite cool, I could put the two windows side by side if I need to often refer to the hidden screen.
This shows the current screen in a new window, so I assumed this would work, but it doesn't:
What is the correct syntax? 🙂