Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 20 down vote accepted

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

share|improve this answer
Great that you found the solution to your own problem. Don't forget to "accept" it when you are able. However, don't include another question; this isn't a discussion forum. You should open a new question. If it's related you can link to this one from the new question. – Al E. Oct 26 '11 at 20:40
Is there a way to tell the android shell to resize automatically to fit the screen size? Similar to the way it's done on other terminals in Unix? – Ehtesh Choudhury Apr 6 '13 at 20:19
i tried this, but it said "/system/bin/sh: stty: not found"... does it have to be installed or something? – Brad Parks Sep 24 '13 at 13:44
Brad: Yes, it should be part of BusyBox. – user46935 Sep 25 '13 at 8:48
For those who dont know BuxyBox: BusyBox is an app. that has a lot of common unix tools "inside" of it - it's particularly designed for embedded systems. To try it install BuxyBox app on your rooted android. – JohnTortugo Oct 10 '13 at 18:19

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

share|improve this answer

Typing resize after connecting to the device works for me:

shell@android:/ $ resize
share|improve this answer
This was busybox resize for me. – Victor Sergienko Jun 6 '15 at 12:43

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)'
share|improve this answer
You shouldn't have to eval the result. resize by itself just works (it does the proper ioctls) – Alexandre Jasmin Feb 26 at 23:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .