28

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?

Journeyman Geek
  • 133,878
user46935
  • 1,331

4 Answers4

28

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)?

user46935
  • 1,331
24

Typing resize after connecting to the device works for me:

shell@android:/ $ resize
COLUMNS=192;LINES=44;export COLUMNS LINES;
madhead
  • 564
  • 1
  • 4
  • 18
17

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

COLUMNS=156
LINES=60
mgalgs
  • 2,472
-1

Using mksh, I had to run eval $(resize).

The resize command outputs the shell commands COLUMNS=#;LINES=#;export COLUMNS LINES; to stdout, but it does not actually execute them. For that, you can use eval and put it in your .profile or shell rc file. While you're in there, you can add an alias for easy resizing after the actual window is resized.

$ grep resize ~/.profile
eval $(resize)
alias rsz='eval $(resize)'
knh
  • 1