How to set terminal size in Android adb shell?

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