WSL Nano scrolling up to see terminal

I run some commands on remote server (am connected with it via ssh using WSL ubuntu 20) and after running then I open nano editor, usually I was able to scroll up with my mouse witch allowed me to see my terminal without closing nano, I was able to copy the output of previously run commands. After setting up WSL on my new laptop I am trying to do it on the same exact remote server, but scrolling up doesn't show me my latest commands, it shows me lets say my commands without ~10 latest commands. I have to copy some parts of the output of the last command run before entering nano. Any ideas ? Thanks.

2 Answers

Short summary:

  • I can reproduce your desired behavior in Ubuntu/WSL using Windows Terminal
  • I can reproduce the behavior that you don't like in Ubuntu/WSL using the legacy Windows Console Host

More Detail:

The nano editor, and most other terminal-based editors, typically run in what is known as an alternate screen buffer. The usual (some would say "correct") behavior for a terminal when in this mode, as @pa4080 mentions in another answer that appeared while I was typing this is not to allow scrolling above the alternate buffer. Some terminals will send up/down keys in response to a scroll up/down while in this mode.

Oddly, this is an issue (Github issue link) in the new Windows Terminal, which you may have installed on your previous machine. The behavior does not occur in the (much) older Windows Console host, the default terminal on Windows 10 and (currently) Windows 11.

It sounds to me like you may be using the older console now, which is behaving correctly, but not as you want.

My recommendation is:

  • Install and switch to Windows Terminal
  • But don't rely on that behavior, since it will likely be fixed at some point. @pa4080 mentions one possibility of using Ctrl+Z to send the foreground app to the background, but I'd also point you to Tmux as an alternative, which will allow you to switch between multiple terminal windows inside of one Windows Terminal tab.

It's also possible that you are using Windows Terminal, and that behavior has already been fixed in a new release without marking the issue closed (and I might be running an older Terminal without the fix).

1

According to my experience, the explained behavior - scroll-up within nano to see the terminal - is observed only in WSL. In my opinion it looks like a bug rather than a feature, but maybe I'm wrong. Note: to achieve it - the history in the terminal should be long enough to scroll it without nano.

The proper way to do what you want is to press Ctrl+Z while nano (or some other application) is open. This will push it to the background and you will be able to operate in the terminal (list directories or history, copy text, , etc.). When you finish just type the command fg to bring nano to the foreground again.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like