How to set terminal size in Android adb shell?

When I connect to Android using "adb shell" and run certain commands such as "vim" or "mc", they are restricted to a "window" of 25x80 characters. Since I'm connecting from a desktop computer where xterm has a much higher resolution, I'd like to use it.

How do I resize this console window to e.g. 60x156 characters?


The answer is

stty rows 60 cols 156

A follow-up question is how do I determine the size of my xterm I'm connecting from so that I can pass it to stty automatically (using a script)?


Typing resize after connecting to the device works for me:

shell@android:/ $ resize
COLUMNS=192;LINES=44;export COLUMNS LINES;

If you're on a recent release of Android that uses mksh you can simply do:

COLUMNS=156
LINES=60