PowerShell and bash smoother on remote host

This is an interesting one, I have the same phenomenon with both PowerShell and bash (Linux under WSL) on Windows 10 Pro.

If I start a shell (either) and run commands that update the screen, E.g.

While(1) {ps | sort -des cpu | select -f 15 | ft -a; sleep 1; cls}

or a bash script that uses tput and echo to redraw the screen, if it runs on the local machine, it flashes and blanks and looks horrible.

If I remote onto another Windows machine or ssh onto a remote Linux host, the same scripts run a lot smoother, there is little or no flashing, the response to key presses is faster and it is generally a better experience…

The above example, run locally blanks the window (cls at the end), pauses, then redraws the window. On the remote host, the blanked window is not shown, the list of processes is simply overwritten, which looks a lot better. It is as if there is a slight pause, locally, before the window is redrawn, whereas remotely it is redrawn so fast, that the cls is never seen.

Surely, if the commands are running locally, it should provide a more smooth experience than running them remotely?

(the above command is similar to Linux top, it displays the top 15 processes, by CPU usage, every second)

Conversation 1 comments

  • wright_is

    Premium Member
    13 April, 2018 - 6:01 am

    <p>I tried it another way, with the following script, essentially the same, but places the cursor instead of cls. This works smoothly both locally and remotely.</p><p><br></p><p>$saveY = [console]::CursorTop</p><p>$saveX = [console]::CursorLeft</p><p><br></p><p><br></p><p>While($true) {</p><p>&nbsp;&nbsp;&nbsp;Get-Process | Sort -Descending CPU | Select -First 30;</p><p>&nbsp;&nbsp;&nbsp;Sleep -Seconds 1;</p><p>&nbsp;&nbsp;&nbsp;[console]::setcursorposition($saveX,$saveY+3)</p><p>}</p><p><br></p><p>But all the same, it is still interesting that the original solution is a jerky mess locally, yet runs smoothly on a remote system.</p>

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC